Inline declaration is a feature introduced with ABAP 7.40 version. With this, when obtaining a value without declaring a variable beforehand, a variable of the type of the value to be obtained is automatically created. This is achieved using the syntax DATA(lv_variable).
Examples
Variables
The value
keyword in ABAP is used when declaring data and assigning a default value. When you use value #(value)
, ABAP assigns a type that matches the value you provide within the value
keyword. If you want to specify a particular type, you can use #
instead of type
.
data(lv_string) = |This is text|. "string
data(lv_date) = value datum( '20241796' ). "date
data(lv_integer) = value i( '1453' ). "integer
data(lv_boolean) = value abap_bool( 'X' ). "char
Loops
"data
loop lt_lines into data(ls_line).
"todo
endloop.
"field-symbol
loop lt_lines assign field-symbol(<fs_line>).
"todo
endloop.
Standard ABAP Utils
"split
data(lv_text) = |item1;item2;item3;item4|.
split lv_text at ';' into table data(lt_lines).
"sql query
select * from dumy_table
where field1 eq 'dumy'
into table @data(lt_itab).
* note : If you do not specify `OPTIONAL`
* and the line is not found, it will result in a dump.
data(ls_data) = value #( lt_itab[ 1 ] optional ).
"call transformation - xml to html with xslt
call transformation zxslt
source xml lv_xml
result lv_html.
"class declaration
data(lo_json) = new /ui2/cl_json( ).
"importing and returning parameters
"dumy method
lo_json->convert( importing
param1 = data(lv_param1)
param2 = data(lv_param2)
returning
return_param = data(lv_return)
).
data(lv_return) = lo_json->check( exporting
json = lv_json). "returning parameter