READ TABLE with KEY using ABAP 7.4



From NetWeaver 7.4, reading a record using key  from an internal table is much simpler, but you can not use sy-subrc for checks, you need to use exception CX_SY_ITAB_LINE_NOT_FOUND

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

Example program using READ TABLE KEY ABAP 7.4

With Single key

SELECT *
  FROM MARA
  INTO TABLE @DATA(IT_MARA)
  UP TO 50 ROWS
  WHERE MTART = 'FERT'.
TRY .
DATA(wa_mara) = it_mara[ matnr = '0001' ].
CATCH CX_SY_ITAB_LINE_NOT_FOUND.
WRITE:/ 'Error Reading Record'.
ENDTRY.
WRITE:/ wa_mara-matnr.

With multiple Ksys

SELECT *
  FROM MARA
  INTO TABLE @DATA(IT_MARA)
  UP TO 50 ROWS
  WHERE MTART = 'FERT'.

TRY .
DATA(wa_mara) = it_mara[ matnr = '0001' mtart = 'FERT' ].
CATCH CX_SY_ITAB_LINE_NOT_FOUND.
WRITE:/ 'Error Reading Record'.
ENDTRY.
WRITE:/ wa_mara-matnr.

Learner Questions

No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question


    Was this lesson helpful to you? Yes No 0 People out of 0 think this lesson helpful

    Lesson Navigation

    ←Previous Chapter
    Next Chapter →