Skip to Content
0
Feb 18, 2009 at 10:39 AM

please help

47 Views

Hi Experts,

Please look at the below code and suggest me the better way to improve the performance.

DATA: lt_erdk LIKE STANDARD TABLE OF erdk WITH HEADER LINE,

lt_erch LIKE STANDARD TABLE OF erch WITH HEADER LINE,

lt_dberdl LIKE STANDARD TABLE OF dberdl WITH HEADER LINE,

lt_dberdlb LIKE STANDARD TABLE OF dberdlb WITH HEADER LINE,

lt_dberchz1 LIKE STANDARD TABLE OF dberchz1 WITH HEADER LINE,

lt_dberchz3 LIKE STANDARD TABLE OF dberchz3 WITH HEADER LINE,

lt_but000 LIKE STANDARD TABLE OF but000 WITH HEADER LINE.

  • Find Print Documents for Date range,

  • limiting selection to totals over 40,000

SELECT opbel budat vkont partner sto_opbel

INTO CORRESPONDING FIELDS OF TABLE lt_erdk

FROM erdk

WHERE budat IN r_budat

AND druckdat NE '00000000'

AND stokz EQ space

AND intopbel EQ space

AND total_amnt GT 40000.

SORT lt_erdk BY opbel.

IF lt_erdk[] IS NOT INITIAL.

SELECT DISTINCT printdoc billdoc vertrag

INTO CORRESPONDING FIELDS OF TABLE lt_dberdlb

FROM dberdlb

WHERE printdoc IN ( SELECT opbel FROM erdk

WHERE budat IN r_budat

AND druckdat NE '00000000'

AND stokz EQ space

AND intopbel EQ space

AND total_amnt GT 40000 ).

IF lt_dberdlb[] IS NOT INITIAL.

SELECT belnr belzart ab bis aus01

v_zahl1 n_zahl1 v_zahl3 n_zahl3

INTO CORRESPONDING FIELDS OF TABLE lt_dberchz1

FROM dberchz1

FOR ALL ENTRIES IN lt_dberdlb

WHERE belnr EQ lt_dberdlb-billdoc

AND belzart IN ('ZUTAX1', 'ZUTAX2', 'ZUTAX3').

ENDIF. "lt_dberdlb

ENDIF. "lt_erdk

SELECT DISTINCT partner name_last name_first name_org1

INTO CORRESPONDING FIELDS OF TABLE lt_but000

FROM but000

WHERE partner IN ( SELECT partner FROM erdk

WHERE budat IN r_budat

AND druckdat NE '00000000'

AND stokz EQ space

AND intopbel EQ space ).

  • break techdev2.

REFRESH lt_itab4.

LOOP AT lt_erdk.

CLEAR lt_itab4.

MOVE: lt_erdk-partner TO lt_itab4-partner,

lt_erdk-vkont TO lt_itab4-vkont.

IF lt_erdk-sto_opbel NE space.

MOVE 'R' TO lt_itab4-index.

ENDIF.

  • Partner Detail

READ TABLE lt_but000 WITH KEY partner = lt_erdk-partner.

IF sy-subrc = 0.

IF lt_but000-name_last NE space OR lt_but000-name_first NE space.

MOVE: lt_but000-name_last TO lt_itab4-name_last,

lt_but000-name_first TO lt_itab4-name_first.

ELSE.

MOVE: lt_but000-name_org1 TO lt_itab4-name_first.

ENDIF.

ENDIF.

  • Revenue & Tax

LOOP AT lt_dberdlb WHERE printdoc EQ lt_erdk-opbel.

LOOP AT lt_dberchz1 WHERE belnr EQ lt_dberdlb-billdoc.

CASE lt_dberchz1-belzart.

WHEN 'ZUTAX1'.

lt_itab4-s1revenue = lt_itab4-s1revenue

+ ( lt_dberchz1-v_zahl1 + lt_dberchz1-n_zahl1 ).

lt_itab4-s1tax = lt_itab4-s1tax

+ ( lt_dberchz1-v_zahl3 + lt_dberchz1-n_zahl3 ).

WHEN 'ZUTAX2'.

lt_itab4-s2revenue = lt_itab4-s2revenue

+ ( lt_dberchz1-v_zahl1 + lt_dberchz1-n_zahl1 ).

lt_itab4-s2tax = lt_itab4-s2tax

+ ( lt_dberchz1-v_zahl3 + lt_dberchz1-n_zahl3 ).

WHEN 'ZUTAX3'.

lt_itab4-s3revenue = lt_itab4-s3revenue

+ ( lt_dberchz1-v_zahl1 + lt_dberchz1-n_zahl1 ).

lt_itab4-s3tax = lt_itab4-s3tax

+ ( lt_dberchz1-v_zahl3 + lt_dberchz1-n_zahl3 ).

ENDCASE.

ENDLOOP. "lt_dberchz1

ENDLOOP. "lt_dberdlb

lt_itab4-totrevenue = lt_itab4-s1revenue + lt_itab4-s2revenue + lt_itab4-s3revenue.

lt_itab4-tottax = lt_itab4-s1tax + lt_itab4-s2tax + lt_itab4-s3tax.

  • APPEND lt_itab4.

COLLECT lt_itab4.

ENDLOOP.

Please use a meaningful subject

And everyone - please use code tags!

Edited by: Rob Burbank on Feb 18, 2009 10:54 AM