Inline declaration of variables
Use the operators
DATA
and
FIELD-SYMBOL
to combine the declaration and initial value assignment
of a variable or field symbol.
Allowed at write positions for which a type can be determined statically from the context. This inferred type is given to the declared symbol.
DATA(text) = `This is a string`.
" old style
DATA text TYPE string.
text = `This is a string`.DATA(result) = method_with_returning( ).
" old style
DATA result TYPE accounts_table.
result = method_with_returning( ).method_with_exporting( IMPORTING parameter = DATA(accounts) ).
" old style
DATA accounts TYPE accounts_table.
method_with_exporting( IMPORTING parameter = accounts ).LOOP AT accounts INTO DATA(account).
ENDLOOP.
" old style
DATA account TYPE account_structure.
LOOP AT accounts INTO account.
ENDLOOP.READ TABLE accounts INTO DATA(account_sap) WITH KEY id = 5.
" old style
DATA account_sap TYPE account_structure.
READ TABLE account INTO account_sap WITH u id = 5.LOOP AT accounts ASSIGNING FIELD-SYMBOL(<account>).
ENDLOOP.
" old style
FIELD-SYMBOLS <account> TYPE account_structure.
LOOP AT accounts ASSIGNING (<account>).
ENDLOOP.ASSIGN COMPONENT id OF account_sap TO FIELD-SYMBOL(<account_id>).
" old style
FIELD-SYMBOLS <account_id> TYPE account_id_type.
ASSIGN COMPONENT id OF account_sap TO <account_id>.SELECT * FROM t000 INTO TABLE @DATA(clients).
" old style
DATA clients TYPE STANDARD TABLE OF t000.
SELECT * FROM t000 INTO TABLE clients.