Application Development 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: 

How to Avoid Loop for improve report performance

Former Member
0 Kudos

form get_shpqty .
loop at t_order.
select * into corresponding fields of wa_shpqty
from lips
where vgbel = t_order-vbeln.
select single vkorg into wa_shpqty-vkorg from vbak
where vbeln = t_order-vbeln.
collect wa_shpqty into it_shpqty.
endselect.
endloop.
delete it_shpqty where lfimg eq 0.

endform.

2 REPLIES 2

Sandra_Rossi
Active Contributor

Basic question: you may use SELECT ... FOR ALL ENTRIES or database joins, but you need to test which option is the best, check the execution plans, etc.

The big questions are: which fields are taken from LIPS (which ones are in WA_SHPQTY), and how do you determine T_ORDER?

And you forgot to say that you ask the question because there is a warning "select in a loop" by the static check (?) Note that both solutions above are also equivalent to a "select in a loop", but produce a better performance because they group several selections at a time.

0 Kudos

In addiction, the 2 selects if they cannot be put into a previous join for any reason, they can be used as join themselves and refined even more adding the condition " lfimg <> 0" to reduce the amount of read data.

Even more, i see a collect so i guess a SUM could work fair better in the Select.