In NetWeaver 7.4, getting the index of a row in an internal table is simple with a table expression line_index
, it will return index number of the row, if row does not exist, it will return 0
SYNTAX: <lv_index> = line_index( <ITAB> [ <COLUMN1> = <VALUE> <COLUMN2> = <VALUE> ... ] ).
Example using line_index SAP ABAP 7.4
With Single condition
SELECT * FROM MARA INTO TABLE @DATA(IT_MARA) UP TO 50 ROWS WHERE MTART = 'FERT'. DATA(lv_index) = line_index( it_mara[ matnr = '0001' ] ). IF lv_index > 0. "Line exists WRITE:/ lv_index. ENDIF.
With multiple conditions
SELECT * FROM MARA INTO TABLE @DATA(IT_MARA) UP TO 50 ROWS WHERE MTART = 'FERT'. DATA(lv_index) = line_index( it_mara[ matnr = '0001' matkl = '0001' ] ). IF lv_index > 0. "Line exists WRITE:/ lv_index. ENDIF.
Learner Questions
No Questions by learners, be first one to ask ..!!
Was this lesson helpful to you? Yes No 2 People out of 2 think this lesson helpful