Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

please help

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi!

Here remove the 'INTO CORRESPONDING FIELDS OF ' from the code .

align the fields in the select query as they are defined or define a type statement and the way u define it in the types the same order maintain in the fetching query.....this will not give u a dump in the program....and u can avoid 'INTO CORRESPONDING FIELDS OF '.

In order for the SELECT Query to Run faster, it is important to include all the Primary Key Fields in the WHERE Clause so that the Query runs Faster and thus improving the Performance of your code.

this will reduce your runtime in your program...

8 REPLIES 8

Former Member
0 Kudos

hi....

in select quary dont use 'INTO CORRESPONDING FIELDS OF'

AND in where clause use key fields in order in which it is given in data base table

regards

Former Member
0 Kudos

Hi,

Take the Select statements out of the IN (.....) statements. Declare a separate internal table then use that internal table as the condition. That way it will not hit the database everytime. It help improve performance greatly. Make such changes elsewhere too.

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 ).

Regards,

Rajan.

Edited by: rajan roy on Feb 18, 2009 11:45 AM

Edited by: rajan roy on Feb 18, 2009 11:47 AM

viquar_iqbal
Active Contributor
0 Kudos

Hi

what you can do is instead of

LOOP AT lt_dberdlb WHERE printdoc EQ lt_erdk-opbel.

LOOP AT lt_dberchz1 WHERE belnr EQ lt_dberdlb-billdoc.

try this LOOP AT lt_dberdlb.

if printdoc EQ lt_erdk-opbel.

statements.

endif.

endloop.

It would improve performance

also while selecting there are many conditions so just get the data as whole and then when displaying them use if conditions

Thanks

Viquar Iqbal

Former Member
0 Kudos

Hi,

Dont use table wtih header lines. Use work area instead

Former Member
0 Kudos

Hi,

Since your internal table have the whole structure,

write your select queries as

Select * from tabname into table itab

instead of corresponding fields of

Similarly, Use FOR ALL ENTRIES for the forthcoming select queries. as shown below

IF lt_erdk[] IS NOT INITIAL.

SELECT DISTINCT *

INTO TABLE lt_dberdlb

FROM dberdlb FOR ALL ENTRIES it_erdk

WHERE printdoc IN it_erdk-printdoc

Former Member
0 Kudos

Hi,

There are few things that can be useful in performance tunning:

1.Always declare an internal table without header line, use work are

2.Never use MOVE CORRESPONDING OR INTO CORRESPONDING FIELDS

3.Never use nested select queries.....instead go for Joins or FOR ALL ENTERIES

4.Avoid nested and complex conditions/comparisons in where clause

5.check for sy-subrc value for 0 before using FOR ALL ENTERIES

6.Use compare operators (=,<,> etc) instead EQ,LT,GT

Hope this will help you out,moreover forum has plenty of links on performance tunning.

Pooja

Edited by: Pooja Gupta on Feb 18, 2009 11:58 AM

Former Member
0 Kudos

Hi Vishal,

For advanced performance improved techniques.

Refer to the below link.

https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/advanced%252bperformance%252boptimization%25...

Regards,

Phani.

Former Member
0 Kudos

Hi!

Here remove the 'INTO CORRESPONDING FIELDS OF ' from the code .

align the fields in the select query as they are defined or define a type statement and the way u define it in the types the same order maintain in the fetching query.....this will not give u a dump in the program....and u can avoid 'INTO CORRESPONDING FIELDS OF '.

In order for the SELECT Query to Run faster, it is important to include all the Primary Key Fields in the WHERE Clause so that the Query runs Faster and thus improving the Performance of your code.

this will reduce your runtime in your program...