Application Development and Automation 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: 
Read only

report performance

former_member206396
Active Participant
0 Likes
1,087

hi all.,

my report displays ESNs ( Serial numbers ) as on date.

so first i am going to mkpf and mseg.. here i am not using primary or secondary index. instead i am seleting based on other fields like matnr, werks, lgort, budat, bwart etc., ( total 6 fields ).. i don't have other option, i have to pick data based on these. ( no index is available on this )

next, to get serial numbers i am hitting objk and then ser03 tables...

And processing internal tables based on requirement. (deletion.... )

->to modify a value i am looping a inter table within itself...

<b>loop at xyz.

loop at xyz where <cond>

endloop.

endloop.</b>

Is that taking more time???

could any one help me out...!

Thanks

RK

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,057

Hi Rama:

This can help minus loop times:

DATA: lt_xyz LIKE xyz[] OCCURS 10.

APPEND LINES OF xyz TO lt_xyz.

SORT lt_xyz BY <b>matnr, werks, lgort, budat, bwart</b>." (Fields in cond).

DELETE ADJACENT DUPLICATES FROM lt_xyz COMPARING <b>matnr, werks, lgort, budat, bwart</b>.

loop at lt_xyz.

loop at xyz where <cond>

endloop.

endloop.

10 REPLIES 10
Read only

Former Member
0 Likes
1,058

Hi Rama:

This can help minus loop times:

DATA: lt_xyz LIKE xyz[] OCCURS 10.

APPEND LINES OF xyz TO lt_xyz.

SORT lt_xyz BY <b>matnr, werks, lgort, budat, bwart</b>." (Fields in cond).

DELETE ADJACENT DUPLICATES FROM lt_xyz COMPARING <b>matnr, werks, lgort, budat, bwart</b>.

loop at lt_xyz.

loop at xyz where <cond>

endloop.

endloop.

Read only

Former Member
0 Likes
1,057

HI,

AS for performance we should not use Loop inside Loop unless and until reuired , for e.d the inner loop has multiple values for every value in the outer loop.

Nect never use a midify statment in a loop instead use filed synbols, thses are reference pointer to the meory location so they do not need modiy statements,

also so not delet values inside loop insteda use logical deletion and then delete thses values after the loop.

Regards,

Vaibhav B Gawali.

Read only

0 Likes
1,057

hi vaibhav,

thanks alot... but how to use field-symbles. i have never used..

can you give one example with syntax.. and how it helps in my situation?

thanking you.,

RK

Read only

0 Likes
1,057

Hi Rama:

Use this:

FIELD-SYMBOLS: <FS> LIKE xyz.

LOOP AT xyz ASSIGNING <FS> WHERE cond.

<FS>-field = 'xxx'.

ENDLOOP.

Read only

Former Member
0 Likes
1,057

Please check this:

/people/rob.burbank/blog/2006/02/07/performance-of-nested-loops

Also, MSEG <b>does</b> have a secondary index on matnr, so if you go to MSEG using matnr and then MKPF using the document number from MSEG, you should be OK.

Rob

Message was edited by:

Rob Burbank

Read only

christian_wohlfahrt
Active Contributor
0 Likes
1,057

Hi,

besides the comments about the DB select, you can make your internal access faster by using a SORTED internal table. Then the where-clause of your inner loop will be faster (like a key access, not a complete loop for checking each line).

You might also avoid the inner loop by using AT NEW / AT END syntax of the loop. Check the help of loop for details.

Regards,

Christian

Read only

0 Likes
1,057

hi christain.,

pls check the following code. where program taking more time...

  • it_final_temp[] = it_final[]. " both tables are of type <b>STANDARD</b>

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-FAULTY'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-CHURN'.

  • APPEND R_BWTAR.

*

  • LOOP AT LT_FINAL INTO LW_FINAL WHERE BWTAR IN R_BWTAR OR

  • BWART = '351' .

*

  • LW_FINAL-AG_DATE = LW_FINAL-BUDAT.

  • LW_FINAL-AG_MBLNR = LW_FINAL-MBLNR.

  • MODIFY LT_FINAL FROM LW_FINAL TRANSPORTING AG_DATE AG_MBLNR.

  • CLEAR LW_FINAL-AG_DATE.

  • ENDLOOP.

  • REFRESH : R_BWTAR.

*

    • -New ESNs...

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'ABUCAPNEW'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'HNICAPNEW'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'MASSCAPNEW'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-NEW-IND'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-NEW-IMP'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'NEW-IM-PRE'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'NEW-IM-POS'.

  • APPEND R_BWTAR.

*

  • R_BWART-OPTION = 'EQ'.

  • R_BWART-SIGN = 'I'.

  • R_BWART-LOW = '101'.

  • APPEND R_BWART.

*

  • R_BWART-OPTION = 'EQ'.

  • R_BWART-SIGN = 'I'.

  • R_BWART-LOW = '105'.

  • APPEND R_BWART.

*

  • R_BWART-OPTION = 'EQ'.

  • R_BWART-SIGN = 'I'.

  • R_BWART-LOW = 'Z51'.

  • APPEND R_BWART.

*

  • R_BWART-OPTION = 'EQ'.

  • R_BWART-SIGN = 'I'.

  • R_BWART-LOW = 'Y51'.

  • APPEND R_BWART.

*

  • R_BWART-OPTION = 'EQ'.

  • R_BWART-SIGN = 'I'.

  • R_BWART-LOW = '301'.

  • APPEND R_BWART.

*

  • R_BWART-OPTION = 'EQ'.

  • R_BWART-SIGN = 'I'.

  • R_BWART-LOW = '561'.

  • APPEND R_BWART.

**sort lt_final by sernr.

  • LOOP AT LT_FINAL_TEMP INTO LW_FINAL_TEMP WHERE BWTAR IN R_BWTAR.

  • ON CHANGE OF LW_FINAL_TEMP-SERNR.

  • LOOP AT LT_FINAL INTO LW_FINAL WHERE BWART IN R_BWART AND

  • SERNR = LW_FINAL_TEMP-SERNR.

  • LW_FINAL-AG_DATE = LW_FINAL-BUDAT.

  • LW_FINAL-AG_MBLNR = LW_FINAL-MBLNR.

  • MODIFY LT_FINAL FROM LW_FINAL TRANSPORTING AG_DATE AG_MBLNR WHERE SERNR = LW_FINAL_TEMP-SERNR.

  • CLEAR : LW_FINAL-AG_DATE, LW_FINAL-BUDAT.

  • EXIT.

  • ENDLOOP.

  • ENDON.

  • ENDLOOP.

*

    • -REFURB ESNs

  • REFRESH : R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-REFURB'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-REF-POS'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-REF-PRE'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-DOA'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'DOA'.

  • APPEND R_BWTAR.

*

  • R_BWTAR-OPTION = 'EQ'.

  • R_BWTAR-SIGN = 'I'.

  • R_BWTAR-LOW = 'TR-BER'.

  • APPEND R_BWTAR.

*

**sort lt_final by sernr.

  • LOOP AT LT_FINAL_TEMP INTO LW_FINAL_TEMP WHERE BWTAR IN R_BWTAR.

  • ON CHANGE OF LW_FINAL_TEMP-SERNR.

  • LOOP AT LT_FINAL INTO LW_FINAL WHERE SERNR = LW_FINAL_TEMP-SERNR.

  • IF ( LW_FINAL-BWART = '315' ) OR ( LW_FINAL-BWART = '316' ) .

  • CONTINUE.

  • ELSE.

  • IF ( LW_FINAL-BWART = 'Z51' ) OR ( LW_FINAL-BWART = 'Y51' ) OR

  • ( LW_FINAL-BWART = '561' ) OR ( LW_FINAL-BWART = '101' ) OR

  • ( LW_FINAL-BWART = '301' ).

*

  • LW_FINAL-AG_DATE = LW_FINAL-BUDAT.

  • LW_FINAL-AG_MBLNR = LW_FINAL-MBLNR.

  • ELSE.

  • IF ( LW_FINAL-SHKZG = 'S' ) AND ( LW_FINAL-BWTAR <> LW_FINAL-UMCHA ).

  • LW_FINAL-AG_DATE = LW_FINAL-BUDAT.

  • LW_FINAL-AG_MBLNR = LW_FINAL-MBLNR.

  • ELSE.

  • CONTINUE.

  • ENDIF.

  • ENDIF.

  • MODIFY LT_FINAL FROM LW_FINAL TRANSPORTING AG_DATE AG_MBLNR WHERE SERNR = LW_FINAL_TEMP-SERNR.

  • CLEAR : LW_FINAL.

  • EXIT.

  • ENDIF.

  • ENDLOOP.

  • ENDON.

  • ENDLOOP.

----


can we write above code effectively?

could any one help me out...!

Ramu

Read only

0 Likes
1,057

I answered this question in your other post. Please close this one.

Rob

Read only

Former Member
0 Likes
1,057

hi Rama

if you are not having all indexing keys to use in select statement wat you can do is you can add those field in selection screen with <b>no-display</b> option fror ex.

select-options: s_budat for mkpf-budat no-display.

this will include indexing keys to your select and will improve your report performance.

regarding your second query you can use control break for example inspite of using two loops wat you can use at-new event for example

loop at xyz.

at new matnr.

.....statement.

endat.

.....statement.

endloop.

if your condition requires combination of two fields then you can use <b>on change of</b> inspite of at-new.

regards

Deepak

Read only

Former Member
0 Likes
1,057

Hello,

Instead of looping the internal tables like u have, loop like this,

<u>YOUR WAY</u>:


loop at xyz.
loop at xyz where <cond>
endloop.
endloop.


More sophisticated way:
------------------------------------

I = 1.
LOOP AT ITAB1 INTO WA1.
  LOOP AT ITAB2 INTO WA2 FROM I.
    IF WA2-K <> WA1-K.
      I = SY-TABIX.
      EXIT.
    ENDIF.
    " ...
  ENDLOOP.
ENDLOOP.

courtesy: Tips n Tricks in SE30

Regards,

Shehryar Dahar