Sap Abap 7.4
Sap Abap 7.4
Sap Abap 7.4
4 Inline Declarations
Gopal Karmakar
Declaration of a variable
For example :
For Example :
Data l_index TYPE sy-tabix.
Data(l_index) = sy-tabix.
l_index = sy-tabix.
Declaration of table work areas
DATA(document) = ixml->create_document( ).
ixml = cl_ixml=>create( ).
stream_factory = ixml->create_stream_factory( ).
document = ixml->create_document( ).
Declaration of a READ TABLE Statement
DATA(flight_schedule) = flight_schedules
READ TABLE flight_schedules INTO [carrid = 'AA' connid = '0017' ].
DATA(flight_schedule) WITH KEY
carrid = 'AA' connid
= '0017'.
laeda
aenam
FROM mara
TYPES: tt_route_config TYPE SORTED TABLE OF ty_route_config ( route = 'R0003' c_type = 'RTYPE' c_value = 'WH' )
WITH UNIQUE KEY route c_type. ( route = 'R0004' c_type = 'RTYPE' c_value = 'DSD' )
TYPES: ).
BEGIN OF ty_routes,
name TYPE char40, TYPES: tt_names TYPE STANDARD TABLE OF char40 WITH DEFAULT KEY.
).
Nested LOOP with multiple tables
* Nested FOR - 3 levels DATA(t_routes_max) =
TYPES: VALUE tt_routes_max(
BEGIN OF ty_routes_max, FOR ls_cust_2 IN t_customres
route TYPE char10, FOR ls_route_2 IN t_routes WHERE ( route =
ls_cust_2-route )
name TYPE char40,
FOR ls_rc_2 IN t_rc WHERE ( route =
c_value TYPE char40,
ls_route_2-route AND c_type = 'MAX' )
END OF ty_routes_max.
( route = ls_route_2-route
name = ls_route_2-name
TYPES: tt_routes_max TYPE STANDARD TABLE OF
c_value = ls_rc_2-c_value )
ty_routes_max WITH DEFAULT KEY.
).
LET with specific (and default) value with FOR
Here you can see the FOR is used with LET. The LV_NAME is read using the tabular expression or [ ]
from the table. The LV_ROUE is also read using the tabular expression but for only first row [1].
TYPES: DATA(t_routes_cust) =
BEGIN OF ty_routes_cust, VALUE tt_routes_cust(
route TYPE char10, FOR ls_cust_l IN t_customres
name TYPE char40,
INDEX INTO cust_index
customer TYPE char10,
"where ( customer = 'C0001' )
END OF ty_routes_cust.
LET lv_name = t_routes[ route = t_customres
TYPES: tt_routes_cust TYPE STANDARD TABLE OF [ cust_index ]-route ]-name
ty_routes_cust WITH DEFAULT KEY.
lv_route = t_routes[ 1 ]-route