12-20-2012 2:35 PM
I have to make loop inside a loop ı am looking fastest way to do
my internal tables likes these (not exactly but similiar)
data begin of itabex
matnr like mara-matnr
lgort like mspr-lgort
charg like mspr-charg
data end of itabex
data begin of itabin
matnr like mara-matnr
lgort like mspr-lgort
charg like mspr-charg
data end of itabin
loop at itabex
loop at itabin where matnr eq itabex-matnr
and lgort eq itabex-lgort
endloop
endloop.
or
sort itabin by matnr lgort.
loop at itabex.
read table itabin with key matnr = itabex-matnr
lgort = itabex-lgort binary search.
if sy-subrc eq 0.
lv_tabix = sy-tabix.
loop at itabin from lv_tabix.
if itabin-matnr ne itabex-matnr or
itabin-lgort ne itabex-lgort.
exit.
endif.
endloop
endif.
endloop
or much more better way to do
Moderator message: duplicate post.
Message was edited by: Thomas Zloch
12-20-2012 4:08 PM
Hi Oldun,
In the second example you are doing double work, once reading (search in table itabex) and then loop (new search in the same table), so it's better the first solution you gave with only one loop.
On the other hand if in the table itabex you are looking for only one register you could only do reading search with no loop necessary.
Regards,