Inline Declarations in Netweaver ABAP 7.40

1
5763

Hello everyone,

In this blog you will learn about Inline Declarations in Netweaver ABAP 7.40. There are many new features introduced in ABAP Netweaver 7.4 and the ABAP stack is optimized for SAP HANA. SAP Netweaver 7.4 is minimum requirement to move to SAP Business Suite on HANA. With these new features introduced from SAP Netweaver 7.4 SAP HANA database in-memory computing can be leveraged at ABAP level. So, let look at these features, learn it and implement them.

Are you working on SAP ABAP Netweaver 7.40 ?

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.

Below are list of main features among different sections

[su_box title=”1. Inline Declarations” style=”soft” box_color=”#f0ab00″]Now you can declare the variables and field-symbols at the same position where you are using them. Inline declarations are possible only for DATA and FIELD-SYMBOL.

#LEFT ASSIGNMENT

Old Syntax
DATA  lv_name TYPE string.

lv_name = 'SAPLEARNERS.COM'.
 New Syntax
DATA(lv_name) = 'SAPLEARNERS.COM'.

#LOOP STATEMENT

Old Syntax
DATA: lw_mara TYPE ty_mara,

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

#READ STATEMENT

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.

 #SELECT STATEMENT

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 
       ersda 
       ernam 
       laeda 
       aenam
       FROM mara
       INTO TABLE lt_mara UP TO 10 ROWS.
New Syntax
SELECT matnr 
       ersda 
       ernam 
       laeda 
       aenam
       FROM mara
       INTO TABLE @DATA(lt_mara) UP TO 10 ROWS.

[/su_box]

[su_box title=”2. Constructor Expressions” style=”soft” box_color=”#f0ab00″]A new type of expression called constructor Expressions are introduced to construct results of specified types and their contents. Below are the list of constructor expressions[su_list]

  • NEW creates object
  • VALUE creates values
  • REF get references
  • EXACT perform a lossless assignment or calculation
  • CONV convert values
  • CAST performs an up cast or down cast
  • COND and SWITCH enable conditional expression

[/su_list]

[su_highlight]Syntax: VALUE Operator                                                              [/su_highlight]

Old Syntax
TYPES: BEGIN OF ty_old,
         f1 TYPE c,
         f2 TYPE c,
         f3 TYPE c,
       END OF ty_old.

DATA: ls_old  TYPE ty_old.

ls_old-f1 = 'A'.
ls_old-f2 = 'B'.
ls_old-f3 = 'C'.

WRITE: ls_old-f1,ls_old-f2,ls_old-f3.
 New Syntax
TYPES: BEGIN OF ty_new,
         f1 TYPE c,
         f2 TYPE c,
         f3 TYPE c,
       END OF ty_new.

* creating intial values using constructor expression - VALUE
DATA(ls_new) = VALUE ty_new( f1 = 'A'
                             f2 = 'B'
                             f3 = 'C').

WRITE: ls_new-f1,ls_new-f2,ls_new-f3.

* changing the initial values using '#' 
ls_new = VALUE #( f1 = 'X'
                  f2 = 'Y'
                  f3 = 'Z').

WRITE: ls_new-f1,ls_new-f2,ls_new-f3.

[/su_box]

Congrats! You have successfully created Synonym in SAP HANA. Please stay tuned for SAP HANA tutorials. Leave a comment in the below comment section and let us know your feedback.