SAP New ABAP syntax, SAP New ABAP syntax (ABAP 7.4 / 7.5).
What is New ABAP / Modern ABAP syntax ?
SAP has introduce new ABAP syntax from ABAP 7.4 onwards. Often referred as New ABAP syntax / Modern ABAP. Which increases the efficiency of the code and also makes it easy for the developers.
The new language features have been added without taking away the old syntax, we can use the new syntax in both ECC and S/4 HANA system as it is based on ABAP release 7.4 onwards.
New features :
•Inline declaration, Table expressions, Read table syntax, Check particular value in internal table with line_exists, Get index number, Value keyword, Corresponding #, Case in select query, Union / Union all
•Conversion operator CONV, Casting operator CAST , Value operator, For operator , Reduce operator
•Concatenate, String functions, Loop at group by, Literals
Declaration of a variable and work area for a simple assignment :
Before 7.40
DATA text TYPE string.
text = `…`.
With 7.40
DATA(text) = `…`.
Declaration of table work areas
Before 7.40
DATA wa like LINE OF itab.
LOOP AT itab INTO wa.
…
ENDLOOP.
With 7.40
LOOP AT itab INTO DATA(wa).
…
ENDLOOP.
Concatenate old and new syntax :
data : gv_string type char100.
data : gv_string1 type char100.
select SINGLE bukrs, belnr, gjahr from bkpf into @data(gs_bkpf).
CONCATENATE ‘Accounting key’ gs_bkpf-bukrs gs_bkpf-belnr gs_bkpf-gjahr into gv_string.
write : / gv_string.
Accounting key100020000599662017
CONCATENATE ‘Accounting key’ gs_bkpf-bukrs gs_bkpf-belnr gs_bkpf-gjahr into gv_string1 SEPARATED BY space.
write : / gv_string1.
Accounting key 1000 2000059966 2017
New syntax :
data(gv_stringn) = | Accountigng Key { gs_bkpf-bukrs } { gs_bkpf-belnr } { gs_bkpf-gjahr } |.
write : / gv_stringn.
Accountigng Key 1000 2000059966 2017
data(gv_stringn1) = | Accountigng Key | && gs_bkpf-bukrs && gs_bkpf-belnr && gs_bkpf-gjahr && | Created Successfully |.
write : / gv_stringn1.
Accountigng Key 100020000599662017 Created Successfully
data(gv_stringn2) = | Accountigng Document { gs_bkpf-belnr } Created sucesfully |.
write : / gv_stringn2.
Accountigng Document 2000059966 Created successfully