Inline Declarations with examples
Inline Declarations with examples
4 is ABAP inline
declarations, this will help an ABAP Developer to simplify programming help to reduce
unnecessary data declarations in a program.
Inline declarations are most useful in reducing onetime and local data declarations in a
ABAP Object, for example If you want to store some value inside in a Function
Module/Perform and you don`t need to access them globally, you can declare a inline
variable and use it locally.
Now there is no need to declare a variable, work area or an internal table and then
assign value to it. With new ABAP we can do the above two steps process in a single
step.
OLD
DATA :go_obj TYPE REF TO CL_BSP_DLC_FA_VIEW.
CREATE OBJECT go_obj EXPORTING iv_component = ‘dummy value’
iv_viewname = ‘Value2’.
New
DATA(go_obj_new) = NEW CL_BSP_DLC_FA_VIEW( iv_component = ‘dummy value’ iv_vi
ewname = ‘Value2’ ).
OR
Below is the more example of declaring a plain variable to store some string.
Below is the example After ABAP 7.4, you need to use DATA keyword with open and close
brackets '(' to declare variable.
SELECT SINGLE *
FROM MARA
INTO WA_MARA WHERE MATNR = '0001'.
After ABAP 7.4, you need to use @ symbol for using variables in ABAP 7.4 Open SQL
statements