Constructor operator VALUE
constructs a value for a specified type.
The syntax for the VALUE constructor expressions is as follows:
... VALUE dtype|#( ... ) ...
This will construct a variable of type type
with the initial value.
Create A Variable
Variables can be constructed like this:
* int
DATA(int) = VALUE i( ).
* float
DATA(float) = VALUE f( ).
* DDIC type MATNR
DATA(matnr) = VALUE matnr( ).
Create A Structure
Structures can be constructed like this where for each component a value can be assigned:
… VALUE dtype|#( comp1 = a1 comp2 = a2 … ) …
TYPES: BEGIN OF ty_sflight,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
END OF ty_sflight.
DATA(sflight) = VALUE ty_sflight( carrid = 'LH'
connid = '0123' ).
* DDIC type BAPIMATHEAD
DATA(bapimathead) = VALUE bapimathead( ).
* DDIC type BAPIMATHEAD with values
DATA(bapimathead) = VALUE bapimathead( material = '1234567890'
basic_view = abap_true
purchase_view = abap_true
account_view = abap_true ).
Create An Internal Table
Internal Tables can be constructed like this where for each line a value can be assigned:
… VALUE dtype|#( ( … ) ( … ) … ) …
TYPES: BEGIN OF ty_sflight,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
END OF ty_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF ty_sflight WITH DEFAULT KEY.
DATA(sflight) = VALUE tt_sflight( ( carrid = 'LH' connid = '0123' )
( carrid = 'AA' connid = '3210' ) ).
* DDIC type STRINGTAB
DATA(stringtab_empty) = VALUE stringtab( ).
* DDIC type STRINGTAB with values
DATA(stringtab) = VALUE stringtab( ( `Hello` )
( `World` ) ).