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

Perofrmance tuning

Former Member
0 Likes
2,094

HI,

when i execute my program it taking lot of time.

when i do runtime analysis it showing Abap 99% and Database 1%... what is it exactly mean...

where is the problem..

how can i find which statement has the problem..

in debug i didn't get the statement which has problem directly..

what shud be a ideal run time analysis graph shud be?

Thanx

Basha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,035

Hi Basha,

sorry for the late answer, but maybe it still helps...

(1) the substance BAPIs are pretty complex and especially reading valuations (properties) makes them slow. So it is recomended that you only read those properties that you really need. If t_estvh contains all neccessary entries your code makes sense:


    LOOP AT t_estvh.
      CLEAR: t_prop_header.
      t_prop_header-recno_root = t_listsub-recnroot.
      t_prop_header-subchacat = t_estvh-estcat.
      APPEND t_prop_header.
    ENDLOOP.

(2) You should check the delete flag (DELFLG) in estrh when determining the subid:

SELECT SINGLE * FROM estrh WHERE recn = t_prop_comp-comproot.

... or you use the API C1A0_TRANSLATE_RECN_TO_SUBID instead

(3) The most performance critical statement in my opinion is the CALL FUNCTION 'BAPI_BUS1077_GET_COMP_TREE'.

You call it inside 4 nested LOOPs and it always reads exactly the same data. You call it for a subid that you set earlier.

Is this BAPI call really necessary at all? Just to check if there are no components there are easier ways (see (4)).

(4) You should think also about to read all data with the substance BAPI BAPI_BUS1077_GETDETAIL at once. It is also possible to read identifier and the material join at once. It is not necessary to determine them manually with db select (if you do so, don't forget the DELFLG...)

Best regards,

Andreas

22 REPLIES 22
Read only

Former Member
0 Likes
2,035

hi Basha,

Run <b>ST05</b> Transaction ... i.e, SQL Trace

<b>SQL trace</b>http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm

Regards,

Santosh

Read only

Former Member
0 Likes
2,035

Since 99% of the time is spent in ABAP, I think your processing logic is very complicated or improper logic(not to be confused with incorrect!).

Check your loops in particular. Go in debugging and see which particular routine, it is spending much time on. In your runtime analysis, see if much the 99% is spent in a particular piece of code. Publish that code here for us to help you in optimizing.

Read only

0 Likes
2,035

HI,

i think this routine has problem........

check it once...

let me know where i have to modify it.

Message was edited by: syed basha

Read only

0 Likes
2,035

Of course that is the culprit. You have like 10 nested loops in there. Is there any way you can avoid them?

Read only

0 Likes
2,035

Hi Syed,

Remove all your nested loops and you could use the suggestion which i have given above.

Cheers,

Abdul Hakim

Read only

0 Likes
2,035

You cannot simply replace LOOPs with READ if there are going to be more than one record in the table that satisfies the criteria and if there is exactly one, then it doesn't make much of a difference whether it is a LOOP or a READ.

Syed, why do you have so many loops? You also have some BAPI calls and also some SELECTs. You have to really work on this piece of code.

Read only

0 Likes
2,035

i debugged again......... the statement select single * from estrh and also move statements taking long time than others...

can anybody have idea... how can i write those move statements and select statements

Read only

0 Likes
2,035

if you want to avoid this select statement, you can pick all the records at one shot by

select * from ESTRH into table i_ESTRH for all entries of itab where ......

and then use read statement in the LOOP.

Regds

Manohar

Read only

0 Likes
2,035

The program is pretty complex. If you post the requirements or specs you have, that might be better.

Rob

Read only

0 Likes
2,035

the input paprametes are rep_cat and matnr.

rep_cat is obligatory...

if i provide particular matnr... then output is very fast with all the loops and select statements.

bcos of matnr is optional if we leave it blank .. it taking much time to sort out and look for all matnr in rep_ cat category.

may be this can help for u to suggest me.

Basha

Read only

0 Likes
2,035

Looks like even though you introduced SELECT ENDSELECT loops, you are interested in only one set of values. Why don't you then exit from the all the 3 selects as soon as you find one record? Also see if you can use join instead of nested selects and UP TO 1 ROWS option.

Read only

0 Likes
2,035

Look at these nested LOOPs. Why are appending and refreshing the internal tables in these loops? This does not look correct at all.


  LOOP AT t_listsub." from 3 to 3.
    REFRESH: t_prop_header, <b><--refreshing here</b>
             t_prop_val,
             t_prop_data,
             t_prop_comp,
             t_prop_usage,
             t_sub_header. <b><--refreshing here</b>
    CLEAR:   t_prop_header,
             t_prop_val,
             t_prop_data,
             t_prop_comp,
             t_prop_usage,
             t_sub_header,
             t_ret.
    t_sub_header-record_no = t_listsub-recnroot.
    t_sub_header-recno_root = t_listsub-recnroot.
    APPEND t_sub_header. <b><-- appending here</b>

    REFRESH: t_prop_header, t_ret. <b><--refreshing here</b>
    LOOP AT t_estvh. 
<b><-- no linking between this loop and superior loop. 
so why is this here inside the other loop.</b>
      CLEAR: t_prop_header.
      t_prop_header-recno_root = t_listsub-recnroot.
      t_prop_header-subchacat = t_estvh-estcat.
      APPEND t_prop_header. <b><-- appending here</b>
    ENDLOOP.
  ENDLOOP.

Read only

0 Likes
2,035

ya, problem in that only... we have a standard sap report.. name REHS_SARA31X when i execute it and then run time analysis then it showing ABAP 97% DATABASE 1.5% and SYSTEM 1.5%

is showing ABAP 97% is OK for standard program?

i think my case is with select statements.

let me know how can i join those 4 select and endselect statements and also 4 move statements.

Read only

0 Likes
2,035

Why is it simply not like this?


  REFRESH: t_prop_header,
           t_prop_val,
           t_prop_data,
           t_prop_comp,
           t_prop_usage,
           t_sub_header.
  CLEAR:   t_prop_header,
           t_prop_val,
           t_prop_data,
           t_prop_comp,
           t_prop_usage,
           t_sub_header,
           t_ret.
  LOOP AT t_listsub." from 3 to 3.
    t_sub_header-record_no = t_listsub-recnroot.
    t_sub_header-recno_root = t_listsub-recnroot.
    APPEND t_sub_header.
    CLEAR t_sub_header.
  ENDLOOP.

  LOOP AT t_estvh.
    CLEAR: t_prop_header.
    t_prop_header-recno_root = t_listsub-recnroot.
    t_prop_header-subchacat = t_estvh-estcat.
    APPEND t_prop_header.
  ENDLOOP.

Read only

0 Likes
2,035

Also see if there are any function modules that give you all this data.

Read only

0 Likes
2,035

cos in t_listsub there are more values......

after every time clearing the memory....

Read only

0 Likes
2,035

is there any other way to populate the mr_matnr instead of using move statement?

Read only

0 Likes
2,035

Syed,

You can check which statements are taking more time in ST05 by looking at the trace.

You can look at STAD also how the tables are read and number of records.

You can go to performance analysis and take a look at more details just besides graph by creating your own variant in SE30.

If you can paste the code we can tell you how you can optimize it for better performance.

Thanks,

Message was edited by: Naren Somen

Read only

abdul_hakim
Active Contributor
0 Likes
2,035

99% in ABAP means your program is taking almost all the time for executing your application logic at the application server level.Means there is no problem at your database server level ie,your OPEN SQL is very much fine.

How to solve this?

This is mostly due to the incorrect looping at your program.replace the nested loops and use the below variants..

LOOP AT ITAB1.

READ TABLE ITAB2...

ENDLOOP.

Don't call any function module between LOOP and ENDLOOP.

Could you plz paste your code here.so that we could give you the exact solution to your problem..

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
2,035

Hi syed basha,

after u excute u r program goto SM50 there u can find out which statement is taking lot of time.

as database was taking such a low percentage then there should not be problem in the database table see if u can do anything in the SELECT statements .

Thanks

Vikrant Khimavath

Read only

Former Member
0 Likes
2,036

Hi Basha,

sorry for the late answer, but maybe it still helps...

(1) the substance BAPIs are pretty complex and especially reading valuations (properties) makes them slow. So it is recomended that you only read those properties that you really need. If t_estvh contains all neccessary entries your code makes sense:


    LOOP AT t_estvh.
      CLEAR: t_prop_header.
      t_prop_header-recno_root = t_listsub-recnroot.
      t_prop_header-subchacat = t_estvh-estcat.
      APPEND t_prop_header.
    ENDLOOP.

(2) You should check the delete flag (DELFLG) in estrh when determining the subid:

SELECT SINGLE * FROM estrh WHERE recn = t_prop_comp-comproot.

... or you use the API C1A0_TRANSLATE_RECN_TO_SUBID instead

(3) The most performance critical statement in my opinion is the CALL FUNCTION 'BAPI_BUS1077_GET_COMP_TREE'.

You call it inside 4 nested LOOPs and it always reads exactly the same data. You call it for a subid that you set earlier.

Is this BAPI call really necessary at all? Just to check if there are no components there are easier ways (see (4)).

(4) You should think also about to read all data with the substance BAPI BAPI_BUS1077_GETDETAIL at once. It is also possible to read identifier and the material join at once. It is not necessary to determine them manually with db select (if you do so, don't forget the DELFLG...)

Best regards,

Andreas