Skip to Content
avatar image
Former Member

How to Avoid Loop for improve report performance

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.
delete it_shpqty where lfimg eq 0.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 23, 2017 at 06:14 AM

    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.

    Add comment
    10|10000 characters needed 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.