‎2006 Jun 15 6:59 PM
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
‎2006 Jun 28 1:15 PM
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
‎2006 Jun 15 7:02 PM
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
‎2006 Jun 15 7:05 PM
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.
‎2006 Jun 15 7:24 PM
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
‎2006 Jun 15 7:26 PM
Of course that is the culprit. You have like 10 nested loops in there. Is there any way you can avoid them?
‎2006 Jun 15 7:26 PM
Hi Syed,
Remove all your nested loops and you could use the suggestion which i have given above.
Cheers,
Abdul Hakim
‎2006 Jun 15 7:34 PM
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.
‎2006 Jun 15 7:42 PM
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
‎2006 Jun 15 7:49 PM
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
‎2006 Jun 15 7:51 PM
The program is pretty complex. If you post the requirements or specs you have, that might be better.
Rob
‎2006 Jun 15 7:51 PM
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
‎2006 Jun 15 7:55 PM
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.
‎2006 Jun 15 8:00 PM
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.
‎2006 Jun 15 8:02 PM
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.
‎2006 Jun 15 8:02 PM
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.
‎2006 Jun 15 8:03 PM
Also see if there are any function modules that give you all this data.
‎2006 Jun 15 8:08 PM
cos in t_listsub there are more values......
after every time clearing the memory....
‎2006 Jun 15 8:10 PM
is there any other way to populate the mr_matnr instead of using move statement?
‎2006 Jun 15 7:07 PM
Hi syed,
check the links:
http://www.sap-basis-abap.com/sapta002.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
http://www.sappoint.com/faq/faqsql.pdf
http://www.planetsap.com/usefull_transactions.htm
award if helpful.
regards,
keerthi.
‎2006 Jun 15 7:13 PM
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
‎2006 Jun 15 7:12 PM
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
‎2006 Jun 15 9:15 PM
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
‎2006 Jun 28 1:15 PM
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