10-23-2017 6:45 AM
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-23-2017 7: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.
10-23-2017 11:27 AM
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.