In SAP NetWeaver 7.4, SAP has simplified user defined structures with inline declaration in very simple and easier way, this will be very helpful for ABAP developers who mostly deal with user defined structures/table in ABAP objects.
Below is the example using user defined internal tables in SAP ABAP 7.4
In the below example we will use OPEN SQL to read multiple records with specific fields from database table.
Before ABAP 7.4
TYPES: BEGIN OF TY_MARA, MATNR TYPE MARA-MATNR, MTART TYPE MARA-MTART, MEINS TYPE MARA-MEINS, MATKL TYPE MARA-MATKL, END OF TY_MARA. DATA: IT_MARA TYPE TABLE OF TY_MARA, WA_MARA TYPE TY_MARA. SELECT MATNR MTART MEINS MATKL FROM MARA INTO TABLE IT_MARA WHERE MTART = 'FERT'. LOOP AT it_MARA INTO WA_MARA. WRITE:/ wa_mara-MATNR, wa_Mara-mtart, wa_mara-meins. ENDLOOP.
Using user defined internal tables in Select statements ABAP 7.4
SELECT MATNR, MTART, MEINS, MATKL FROM MARA INTO TABLE @DATA(IT_MARA) WHERE MTART = 'FERT'. LOOP AT it_MARA INTO DATA(WA_MARA). WRITE:/ wa_mara-MATNR, wa_Mara-mtart, wa_mara-meins. ENDLOOP.