I am wondering if anyone can optimize following code:
LOOP AT dispinstock.
SELECT matnr SUM( gesme ) SUM( verme ) SUM( einme ) SUM( ausme )
INTO (dispinstock-matnr, dispinstock-gesme,
dispinstock-verme, dispinstock-einme, dispinstock-ausme)
FROM lqua
WHERE matnr = dispinstock-matnr
AND lgnum = 'xxxxx'
AND ( lgtyp IN zsd_t301_n
OR ( lgtyp >= '900' AND lgtyp <= '903' ) )
GROUP BY matnr.
MODIFY dispinstock.
ENDSELECT.
ENDLOOP.
dispinstock 170.000 records,
LQUA 210.000 records (will be larger > 1.500.000 records soon)
This loop take more than 3 minutes. Would it be better to use hashed table instead? Any help or idea would be appreciated.
Take the select out of the loop - pull all the data you need from lqua into a separate internal table in a single select statement. Then do a read on the second table inside the loop. Use a hash/sorted table or use a binary search.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With