Monday, July 20, 2020

READ TABLE with KEY using ABAP 7.4



READ TABLE with KEY using ABAP 7.4

Syntax: <wa_data> = <ITAB>[ <COLUMN1> = <VALUE> <COLUMN2> = <VALUE>... ]


Example: READ TABLE WITH SINGLE KEY:

SELECT *
  FROM MARA
  INTO TABLE @DATA(IT_MARA)
  UP TO 10 ROWS
  WHERE MTART = 'RAW'.
TRY .
DATA(wa_mara) = it_mara[ matnr = '0001' ].
CATCH CX_SY_ITAB_LINE_NOT_FOUND.
WRITE:/ 'Error data not found'.
ENDTRY.


READ TABLE 7.4+ WITH MULTIPLE KEY:


SELECT * FROM MARA INTO TABLE @DATA(IT_MARA) UP TO 50 ROWS WHERE MTART = 'RAW'. TRY . DATA(wa_mara) = it_mara[ matnr = '0001' mtart = 'RAW' ]. CATCH CX_SY_ITAB_LINE_NOT_FOUND. WRITE:/ 'Error data not found'. ENDTRY.