This is particularly useful for declaring data objects at the operand positions where you actually need them.
In this way, you can avoid an extra declaration of the structure in different contexts.
You can use the declaration operator using DATA(...). The FINAL declaration operator is used to create immutable variables.
You can also create structures using the VALUE operator (and also fill them as shown below). Without specifying component values in the parentheses, you create an initial structure.
"Structures created inline instead of an extra declared variable
DATA struc_9 LIKE struc_1.
struc_9 = struc_1
"Type is derived from the right-hand structure; the content of struc is assigned, too.
DATA(struc_10) = struc_1.
FINAL(struc_11) = struc_9.
"Using the VALUE operator
"A structure declaration as follows (without providing component
"value assignments) ...
DATA(struc_a) = VALUE struc_type( ).
"... is similar to the following declaration.
DATA struc_b TYPE struc_type.
"Structures declared inline instead of an extra declared variable
"Example: SELECT statement
"Extra declaration
DATA struc_12 TYPE zdemo_abap_fli.
SELECT SINGLE *
FROM zdemo_abap_fli
WHERE carrid = 'LH'
INTO @struc_12.
"Inline declaration
SELECT SINGLE *
FROM zdemo_abap_fli
WHERE carrid = 'LH'
INTO @DATA(struc_13).
"Example: Loop over an internal table
DATA itab TYPE TABLE OF zdemo_abap_fli WITH EMPTY KEY.
... "itab is filled
"Extra declaration
DATA wa_1 LIKE LINE OF itab.
LOOP AT itab INTO wa_1.
...
ENDLOOP.
"Inline declaration
LOOP AT itab INTO DATA(wa_2).
...
ENDLOOP.
Serkan AKKAVAK
Computer Engineer BSc
Head of SAP & Software Department
Contact : serkurumsal@yandex.com

0 Comments