Improving query performance
This piece of code is taking a long time and many times gives Abap runtime errors with SYSTEM_IMODE_TOO_LARGE. (Basically the performance of the query needs to improve. I have done ST05 and also ran the query and I would appreciate any input on improving performance. I have put my comments in brackets after every query.
SELECT vbeln auart audat kunnr qmnum vkbur
INTO CORRESPONDING FIELDS OF TABLE t_vbak
WHERE vbak~vkorg IN s_vkorg
AND vbak~audat IN s_erdat
AND vbak~kunnr IN s_kunnr.
(The above query is fine. Returns about 80,000 rows)
CHECK sy-subrc EQ 0.
SELECT erdat matnr posnr pstyv vbeln arktx werks abgru
INTO CORRESPONDING FIELDS OF TABLE t_vbap
FOR ALL ENTRIES IN t_vbak
WHERE vbeln = t_vbak-vbeln.
(The above query takes a long time to execute)
t_vbap_ra = t_vbap.
(The above statement takes a long time to execute)
WHERE pstyv <> 'ZRRA' AND
pstyv <> 'ZWRA'.
(This statement takes a long time to execute)