‎2008 Jun 09 11:51 AM
hi all ,
LOOP AT ist_mseg INTO wa_mseg.
LOOP AT ist_bseg_temp INTO wa_bseg_temp
WHERE ebeln = wa_mseg-ebeln AND ebelp = wa_mseg-ebelp.
IF ( wa_bseg_temp-hkont = c_hkont1 OR wa_bseg_temp-hkont = c_hkont2 OR wa_bseg_temp-hkont = c_hkont5 ).
wa_price_diff-matnr = wa_mseg-matnr.
wa_price_diff-dmbtr = wa_bseg_temp-dmbtr.
wa_price_diff-belnr = wa_bseg_temp-belnr.
wa_price_diff-bukrs = wa_bseg_temp-bukrs.
wa_price_diff-gjahr = wa_bseg_temp-gjahr.
wa_price_diff-buzei = wa_bseg_temp-buzei . " added by srinivas on 13/05/08
wa_price_diff-shkzg = wa_bseg_temp-shkzg.
APPEND wa_price_diff TO ist_price_diff.
ENDIF.
ENDLOOP.
ENDLOOP.
in one of my report , it is taking more than 40 min & giving time out error .
here ist_mseg_temp table has 230000(23 lakhs records ) .
how can i reduce the execution time .
plz give me any suggestions .
thanks in advance .
regards ,
srinivas .
‎2008 Jun 09 11:54 AM
Hi Srinivas,
Use READ statement with binary search instead of inner loop.
Check the below code.
SORT IST_BSEG_TEMP BY EBELN EBELP.
LOOP AT ist_mseg INTO wa_mseg.
READ TABLE ist_bseg_temp INTO wa_bseg_temp WITH KEY
ebeln = wa_mseg-ebeln ebelp = wa_mseg-ebelp BINARY SEARCH.
IF ( wa_bseg_temp-hkont = c_hkont1 OR wa_bseg_temp-hkont = c_hkont2 OR wa_bseg_temp-hkont = c_hkont5 ).
wa_price_diff-matnr = wa_mseg-matnr.
wa_price_diff-dmbtr = wa_bseg_temp-dmbtr.
wa_price_diff-belnr = wa_bseg_temp-belnr.
wa_price_diff-bukrs = wa_bseg_temp-bukrs.
wa_price_diff-gjahr = wa_bseg_temp-gjahr.
wa_price_diff-buzei = wa_bseg_temp-buzei . " added by srinivas on 13/05/08
wa_price_diff-shkzg = wa_bseg_temp-shkzg.
APPEND wa_price_diff TO ist_price_diff.
ENDIF.
ENDLOOP.
Thanks,
Vinay
‎2008 Jun 09 11:54 AM
Hi Srinivas,
Use READ statement with binary search instead of inner loop.
Check the below code.
SORT IST_BSEG_TEMP BY EBELN EBELP.
LOOP AT ist_mseg INTO wa_mseg.
READ TABLE ist_bseg_temp INTO wa_bseg_temp WITH KEY
ebeln = wa_mseg-ebeln ebelp = wa_mseg-ebelp BINARY SEARCH.
IF ( wa_bseg_temp-hkont = c_hkont1 OR wa_bseg_temp-hkont = c_hkont2 OR wa_bseg_temp-hkont = c_hkont5 ).
wa_price_diff-matnr = wa_mseg-matnr.
wa_price_diff-dmbtr = wa_bseg_temp-dmbtr.
wa_price_diff-belnr = wa_bseg_temp-belnr.
wa_price_diff-bukrs = wa_bseg_temp-bukrs.
wa_price_diff-gjahr = wa_bseg_temp-gjahr.
wa_price_diff-buzei = wa_bseg_temp-buzei . " added by srinivas on 13/05/08
wa_price_diff-shkzg = wa_bseg_temp-shkzg.
APPEND wa_price_diff TO ist_price_diff.
ENDIF.
ENDLOOP.
Thanks,
Vinay
‎2008 Jun 09 11:57 AM
Hi,
Instead of nested loop use read statement. clear work areas.
LOOP AT ist_mseg INTO wa_mseg.
read ist_bseg_temp INTO wa_bseg_temp
WHERE ebeln = wa_mseg-ebeln AND ebelp = wa_mseg-ebelp binary search.
IF ( wa_bseg_temp-hkont = c_hkont1 OR wa_bseg_temp-hkont = c_hkont2 OR wa_bseg_temp-hkont = c_hkont5 ).
wa_price_diff-matnr = wa_mseg-matnr.
wa_price_diff-dmbtr = wa_bseg_temp-dmbtr.
wa_price_diff-belnr = wa_bseg_temp-belnr.
wa_price_diff-bukrs = wa_bseg_temp-bukrs.
wa_price_diff-gjahr = wa_bseg_temp-gjahr.
wa_price_diff-buzei = wa_bseg_temp-buzei . " added by srinivas on 13/05/08
wa_price_diff-shkzg = wa_bseg_temp-shkzg.
APPEND wa_price_diff TO ist_price_diff.
clear: wa_price, wa_mseg.
ENDIF.
ENDLOOP.
‎2008 Jun 09 12:04 PM
Hi Srinivas,
If you have many entries in the internal table try to reduce the no. of entries, if that internal table data is not used further.
In your case delete all the entries from the temp table if HKONT is not in 1,2,3 constants declared.
instead of using nested loop sort the inner internal table and use read statement. if you have more than 1 entry with that key field. after processing 1 record delete that record.
Best regards
‎2008 Jun 10 5:15 AM
hi good morning ,
by using read statement it is reading only first record , but there is number of records related to it .
but i need all those records .
can u give me any other alternative to avoid nested loop .
thanks ,
regards ,
srinivas .