Skip to Content
0
Former Member
Dec 04, 2011 at 05:29 PM

End Routine ABAP running slow

61 Views

We have written the following end routine but performance is too slow because of the number of loops.

We have introduced the third loop since we need the records in the specific order to populate ZCUST. Can someone advise on how we can optimize

Thanks

$$ begin of routine - insert your code only below this line -

data: TEMP_RESULT_PACKAGE like RESULT_PACKAGE,

WA_RESULT_PACKAGE type TYS_TG_1,

WA type TYS_TG_1.

TEMP_RESULT_PACKAGE[] = RESULT_PACKAGE[].

delete adjacent duplicates from RESULT_PACKAGE

comparing DIVISION DISTR_CHAN SALESORG CUST_SALES.

loop at RESULT_PACKAGE into WA_RESULT_PACKAGE.

clear WA.

loop at TEMP_RESULT_PACKAGE into WA

where DIVISION = WA_RESULT_PACKAGE-DIVISION

and DISTR_CHAN = WA_RESULT_PACKAGE-DISTR_CHAN

and SALESORG = WA_RESULT_PACKAGE-SALESORG

and CUST_SALES = WA_RESULT_PACKAGE-CUST_SALES.

if not WA-SHIP_TO is initial.

WA_RESULT_PACKAGE-SHIP_TO = WA-SHIP_TO.

endif.

if not WA-CUST_HIE01 is initial.

WA_RESULT_PACKAGE-CUST_HIE01 = WA-CUST_HIE01.

endif.

if not WA-CUST_HIE02 is initial.

if not WA-BILLTOPRTY is initial.

WA_RESULT_PACKAGE-BILLTOPRTY = WA-BILLTOPRTY.

endif.

if not WA-PAYER is initial.

WA_RESULT_PACKAGE-PAYER = WA-PAYER.

endif.

if not WA-/BIC/OSSLSREP is initial.

WA_RESULT_PACKAGE-/BIC/ZSREP = WA-/BIC/ZSREP.

endif.

if not WA-/BIC/OSBRO is initial.

WA_RESULT_PACKAGE-/BIC/ZBRO = WA-/BIC/ZBRO.

endif.

if not WA-/BIC/OSCTREMP is initial.

WA_RESULT_PACKAGE-/BIC/ZREMP = WA-/BIC/ZREMP.

endif.

if not WA-/BIC/OSOPR is initial.

WA_RESULT_PACKAGE-/BIC/ZPRI = WA-/BIC/ZPRI.

endif.

endloop.

sort TEMP_RESULT_PACKAGE by DIVISION DISTR_CHAN SALESORG CUST_SALES /BIC/ZBRO /BIC/ZSREP /BIC/ZREMP.

clear WA.

loop at TEMP_RESULT_PACKAGE into WA

where DIVISION = WA_RESULT_PACKAGE-DIVISION

and DISTR_CHAN = WA_RESULT_PACKAGE-DISTR_CHAN

and SALESORG = WA_RESULT_PACKAGE-SALESORG

and CUST_SALES = WA_RESULT_PACKAGE-CUST_SALES.

IF NOT WA-/BIC/ZCUST IS INITIAL.

WA_RESULT_PACKAGE-/bic/ZCUST = WA-/BIC/ZCUST.

ENDIF.

endloop.

modify RESULT_PACKAGE from WA_RESULT_PACKAGE.

clear WA_RESULT_PACKAGE.

endloop.