Reputation: 611
I have the following problem and I need an idea how to overcome?
I have 2 identical ITABs: ITAB1 and ITAB2 with 60 records.
I am looping in the 1st ITAB and when I am finding a record I am looping in the 2nd ITAB with INDEX = sy-tabix of the 1st one:
LOOP at ITAB1 where COL = '001'.
lv_tabix = sy-tabix.
* Do STH.
LOOP at ITAB2 FROM lv_tabix
* do sth
EXIT.
ENDCASE.
ENDCASE.
Lets suppose that I am looping the 2nd ITAB with lv_tabix = 17 and, I am exiting from the 2nd when its tabix=22.
So I am returning in the 1st ITAB do sth and, I am starting the loop of the 2nd ITAB with lv_tabix=21.
I have noticed that the loop of the 2nd ITAB cannot start from a record (21) which is less than the one it was stopped (22).
Am I right?
How can I overcome this problem?
Thanks
Elias
Upvotes: 1
Views: 8101
Reputation: 5051
Cannot reproduce your problem.
DATA(table_1) = VALUE string_table( ( `A` ) ( `B` ) ( `C` ) ( `D` ) ).
DATA(table_2) = VALUE string_table( ( `A` ) ( `B` ) ( `C` ) ( `D` ) ).
LOOP AT table_1 INTO DATA(row_1).
DATA(start_index) = sy-tabix.
LOOP AT table_2 INTO DATA(row_2) FROM start_index.
IF row_2 = `C`.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
works fine, although in the first outer loop iteration it exits the inner loop at sy-tabix = 3
and in the second outer loop iteration restarts the inner loop with the lower start_index = 2
.
Upvotes: 1