Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

issues

Former Member
0 Likes
558

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
526

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 !!

4 REPLIES 4
Read only

Former Member
0 Likes
526

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.

Read only

Former Member
0 Likes
527

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 !!

Read only

Former Member
0 Likes
526

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^

Read only

Former Member
0 Likes
526

Hello,

Avoid using nested loops wherever possible. Chk out the'read' statement/keyword.

Regards,

Shehryar