Skip to Content
-3

How to Avoid Loop for improve report performance

Oct 23, 2017 at 05:45 AM

58

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sandra Rossi Oct 23, 2017 at 06:14 AM
1

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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0