Dear SCNers,
I need some help with optimization of this code for a BW end routine. The Code is correct but the full load is going over 3 days now and still going on.
The code reads the DSO and populates internal tables with CO document number, Fiscal year period, a custom fiscal year period and a Quantity which is summed . In the look up I would like to stamp the fiscal year and Quantity if Docuement number and Fiscal year match.
I would appreciate any help. Thanks.
*Definition of Internal Tables
DATA: BEGIN OF I_S_COEPR,
Quantity type /BIC/OIZPRHRS,
CO_DOC_NO type /BI0/OICO_DOC_NO,
REF_DOC_NO type /BI0/OIREF_DOC_NO,
fiscper type /BI0/OIFISCPER,
END OF I_S_COEPR.
DATA: i_t_coepr like table of I_S_COEPR.
*Then I have the end routine to read from internal tables
SELECT co_doc_no
fiscper
/bic/zaccfpper
SUM( quantity ) as quantity
INTO CORRESPONDING FIELDS OF TABLE i_t_coepr
FROM /bic/azskfwbs00
GROUP BY co_doc_no fiscper /bic/zaccfpper.
IF sy-subrc EQ 0.
SORT i_t_coepr BY co_doc_no.
ENDIF.
* looping through result packages to assign the values if the conditions are met. I already tried using read table but it did not work
* read table i_t_COEPR into I_S_COEPR with key
* CO_DOC_NO = <RESULT_FIELDS>-CO_DOC_NO FISCPER =
* <RESULT_FIELDS>-FISCPER.
* this did not work so had to have additional loop
loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
LOOP AT i_t_COEPR into I_S_COEPR
Where
CO_DOC_NO = <RESULT_FIELDS>-CO_DOC_NO and
fiscper = <RESULT_FIELDS>-FISCPER.
if sy-subrc eq 0.
<RESULT_FIELDS>-/bic/zFISCPER = I_S_COEPR-FISCPER.
<RESULT_FIELDS>-/BIC/zprhrs = I_S_COEPR-Quantity.
endif.
ENDLOOP.
endloop.