Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Nested Loops

Hi, I am new to ABAP and would like to know how to loop at two internal tables. The following is my scenario:

ITAB and ITAB_1 are internal tables with same data and the data is sorted on Fiscal Year Period. Now I want to do is as :

loop at ITAB.

loop at ITAB_1.

endloop.

endloop.

During the first pass through ITAB, I should loop at ITAB_1 zero times. During the second pass through ITAB, I should loop at ITAB_1 1 time and so on. Basically I want to loop through all records in ITAB_1 that are just above my current record in ITAB.

How can I do this? Any ideas.

Thanks and regards.

Tags:
Former Member
Former Member replied
data: current_idx type sy-tabix.
loop at ITAB.
current_idx = sy-tabix - 1.

if sy-tabix > 1.
loop at ITAB_1 to current_idx.

endloop.
endif.

endloop.
0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question