‎2006 Sep 11 9:36 AM
What is the best way to fix this loop performance wise?
loop at i_vbak.
loop at i_vbap where vbeln = i_vbak-vbeln.
loop at i_vbep where vbeln = i_vbep-vbeln.
xxxxxxxx
xxxxxxxx
endloop.
endloop.
endloop.
and also .... do you see any errors/performance issues with these statements. Please donot take "select" query in to consideration. of course "sort i_vbak" is one that needs to be considered i guess
select * into i_vbak.
read table i_vbak where vbeln = 'xxx'
posnr = 'yyy'
vkorg = 'zzz'
binary search.
Thanks in advance. Enjoy! your weekends.
Mary
‎2006 Sep 11 9:40 AM
First of all nested loop is not good..we should always try and avoid it. As for your required since you dont want to use SELECT..is to surely sort the internal tables.
sort i_vbak.
sort i_vbap.
sort i_vbep.
loop at i_vbak.
clear i_vbap.
loop at i_vbap where vbeln = i_vbak-vbeln.
clear i_vbep.
read table i_vbep with key vbeln = i_vbap-vbeln
and posnr = i_vbap-posnr.
if sy-subrc = 0.
endif.
endloop.
endloop.
--Try the above logic..
Regards
Anurag
--Please try an avoid opening the same issue in multiple threads ..Cheers !!
‎2006 Sep 11 9:37 AM
loop at i_vbak.
*loop at i_vbap where vbeln = i_vbak-vbeln.
read table i_vbap with key vbeln = i_vbak-vbeln.
<b>loop at<b> i_vbep</b> where vbeln = <b>i_vbep-vbeln</b></b>.--->wrong what is use of that.
xxxxxxxx
xxxxxxxx
endloop.
*endloop.
*endloop.
it is better that u just send ur requirment.
we will try to code that.
‎2006 Sep 11 9:40 AM
First of all nested loop is not good..we should always try and avoid it. As for your required since you dont want to use SELECT..is to surely sort the internal tables.
sort i_vbak.
sort i_vbap.
sort i_vbep.
loop at i_vbak.
clear i_vbap.
loop at i_vbap where vbeln = i_vbak-vbeln.
clear i_vbep.
read table i_vbep with key vbeln = i_vbap-vbeln
and posnr = i_vbap-posnr.
if sy-subrc = 0.
endif.
endloop.
endloop.
--Try the above logic..
Regards
Anurag
--Please try an avoid opening the same issue in multiple threads ..Cheers !!
‎2006 Sep 11 9:44 AM
hi
good
loop at i_vbak. -Correct
loop at i_vbap where vbeln = i_vbak-vbeln.-Correct
loop at i_vbep where vbeln = i_vbep-vbeln.-Correct
xxxxxxxx
xxxxxxxx
endloop.
endloop.
endloop.
wrong->
select * into i_vbak.
read table i_vbak where vbeln = 'xxx'-Correct
posnr = 'yyy'
vkorg = 'zzz'
binary search.
right->
select * from tablename into i_vbak .
thanks
mrutyun^
‎2006 Sep 11 10:01 AM
Hello,
Avoid using nested loops wherever possible. Chk out the'read' statement/keyword.
Regards,
Shehryar