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

Performance wise which one is better: loop inside select single or select outside loop and reading inside loop

Former Member
0 Likes
492

Hi All,

I am having code like shown below...

loop at it_vbeln.

   SELECT * FROM vbfa  WHERE vbeln = it_vbeln-vbeln.

   SELECT SINGLE * FROM vbkd WHERE vbeln = vbfa-vbelv.

endloop.

whether can i use the select statements outside the loop?

select VBELN

          POSNR

          KDGRP

          PLTYP

from vbfa

into table it_vbfa

for all entries in it_vbeln

where vbeln = it_vbeln-vbeln.

after that...

loop at it_vbeln.

read table it_vbfa into wa_vbaf with key vbeln = it_vbeln-vbeln.

  1. endloop.

Which one is better....inside loop select single is better or use select outside the loop and read the table...

But when i seen the execution time select single inside loop is taking less time as compared with select outside loop and reading inside loop.

Please advise.

Ram

1 REPLY 1
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
412

Moderator message : There are several discussions already available to related topics. Please search for it in SCN. Do the performance analysis yourself using the various transactions available in SAP( please search for it again ).