Skip to Content
0
Feb 26, 2021 at 03:29 PM

Read Statement in internal table

64 Views

program:

REPORT ZDEMO.
DATA: BEGIN OF REC,
COL1 TYPE I,
COL2 TYPE I,
END OF REC.
DATA:ITAB1 LIKE TABLE OF REC WITH NON-UNIQUE KEY COL1.
DO 3 TIMES.
REC-COL1 = SY-INDEX. REC-COL2 = SY-INDEX ** 3.
APPEND REC TO ITAB1.
ENDDO.
LOOP AT ITAB1 INTO REC.
WRITE: / REC-COL1, REC-COL2.
ENDLOOP.
ULINE.
ULINE.
REC-COL1 = 5. REC-COL2 = 8.
READ TABLE ITAB1 FROM REC INTO REC COMPARING COL2.
WRITE: / 'SY-SUBRC = ', SY-SUBRC.
SKIP.
WRITE: / REC-COL1, REC-COL2.

Output:

Ques: why the sy-subrc is coming 4 (not found any entry) while I was searching as: COMPARING COL2. and col2 = 8 is there in the internal table.

Attachments

4evtu.png (3.1 kB)