Inline Declarations in ABAP 7.4 – A Definitive Guide


Dear SAPLearners, Inline Declarations will change way the we declare variables in SAP ABAP.

DATA TYPE declarations is the first thing we do when we start ABAP coding. We declare the variables at the start of the subroutine, method and report program etc.. Most of the program lines we write are only for these data type declarations.

With ABAP 7.4 version, these data type declarations can be completely avoided. Whaat..? No more DATA TYPE declaration? then How my ABAP code works with out them?

Don’t worry Inline Declaration will help and save you from those extra keyboard strokes for DATA TYPE declarations.

ABAP 7.4

In this blog you will learn about Inline Declarations in ABAP 7.4. There are many new features introduced in ABAP 7.4 and the ABAP stack is optimized for SAP HANA.

Inline Declarations

You can declare the variables, immutable variable and field-symbols at the same position where you are using them. Inline declarations are possible for below operators:

  • DATA

Inline Declaration for Variables

In ABAP, variables are declared using DATA keyword. The syntax for inline declaration to declare variable:

DATA(var) = 'Hello World!'.

The data type of the variable is determined by the operand type, which means in above example the data type of var is string.

Inline Declaration for Immutable Variables

In ABAP, immutable variables are declared using FINAL keyword. The syntax for inline declaration for immutable variables works similar as an inline declaration with DATA, while DATA declares a regular variable, FINAL declares an immutable variable.

FINAL(var) = 'Hello World!'.

Inline declaration for Field Symbols

In ABAP, field symbols are declared using FIELD-SYMBOLS keyword to which a memory area is assigned.


Before ABAP 7.4 Syntax:

DATA lv_name TYPE string.
lv_name = 'SAPLEARNERS.COM'.

After ABAP 7.4 Syntax:



Below code examples show how to use inline declaration while using LOOP statement.

Old Syntax:

DATA: lw_mara TYPE ty_mara, 

LOOP AT lt_mara INTO lw_mara. 
  WRITE: lw_mara-matnr,lw_mara-ernam. .... 

New Syntax after ABAP 7.4:

LOOP AT lt_mara INTO DATA(lw_mara). 
   WRITE: lw_mara-matnr,lw_mara-ernam. .... 


Old Syntax:

DATA: lw_mara TYPE ty_mara. 

READ TABLE lt_mara INTO lw_mara INDEX 1.

New Syntax:

READ TABLE lt_mara INTO DATA(lw_mara) INDEX 1.


Old Syntax

TYPES: BEGIN OF ty_mara, 
       matnr TYPE matnr, 
       ersda TYPE ersda, 
       ernam TYPE ernam, 
       laeda TYPE laeda, 
       aenam TYPE aenam, 
       END OF ty_mara. 

DATA: lt_mara TYPE STANDARD TABLE OF ty_mara. 

SELECT matnr 
       aenam FROM mara 
             INTO TABLE lt_mara UP TO 10 ROWS.

New Syntax

SELECT matnr 
       aenam FROM mara 
             INTO TABLE @DATA(lt_mara) UP TO 10 ROWS.

So, now you know this new ABAP 7.4 feature, try and implement it next time you write any ABAP code and let me know how you feel about it.

When to use Inline Declaration in ABAP?

Given the fact the inline declaration can be used to make declaration at time usage, below guidelines should keep mind for better code readability

  • Use inline declaration locally, in the current statement block.
  • Don’t use them globally.

Are you working on SAP ABAP 7.4?

To answer this question, log on to your SAP system.

  • In the menu bar navigate to System → Status.
  • In the popup window, under SAP system data section click on display button under “Product Version” field.

You can see list of installed software component versions like below

SAP Netweaver 7.40

From list of installed software components, look for the Release version of SAP_BASIS and SAP_ABA components to check the SAP Netweaver version.

Congrats! You have successfully learned about new syntax in ABAP 7.4 and stay tuned for more tutorials.

Please feel free to comment and let us know your feedback. Subscribe for updates

Comments are closed.