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

How do I optimize my code?

Former Member
0 Likes
1,278

Hello Experts,

I have attached my code for your reference. I have used too many select query and nested loop. I am still new to development, could you please look into my program and tell me how can I reduce database access, when i checked with SE30(run time analysis)

i got the below graph:

ABAP = 3.3

DATABASE = 97

SYSTEM = 0


The program will run in background. Could you please suggest how can i reduce the database graph??

Thanks in advance,

Sarnava.

12 REPLIES 12
Read only

ceedee666
SAP Champion
SAP Champion
0 Likes
1,239

Hi Sarnava,

please start here if you want to know how to analyse and optimize your ABAP program:

Christian

Read only

Former Member
0 Likes
1,239

Hello Christian,

Thanks for your reply, but we don't have access to SAT transaction.

Regards,

Sarnava

Read only

0 Likes
1,239

On old system use SE30

Try also to use as less as possible the FOR ALL ENTRIES option, as it will quickly impair performance for huge volumn of data, prefer JOIN or SUBQUERY.

Regards,

Raymond

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,239

sarnava bose wrote:

but we don't have access to SAT transaction.

Then you should ask for it. I don't see any reason why a developer should not have access to SAT.

Read only

Former Member
0 Likes
1,239

Hi,

Actually Its better for you to optimize the code based on some of the performance tuning methods , Rather than we are doing and giving,

Please Follow the below mentioned steps,

1. Try to fetch the data from table based on the primary index. This is the most fastest way for          fetching data.

Primary index  comprises all the key fields of the corresponding table.So in where condition try to use all these fields.

2. Try to avoid using more conditions in where clause as it creates load for database optimizer.

3. Try to avoid select inside loop.

4. Use Joins / For all entries for  fetching data from related tables rather than using nested selects.

5. Avoid using select *.

6. Avoid using into corresponding fields.

7. Avoid using operators like < , > ,<= etc if possible.

8. Before using for all entries, Check the Reference internal table is initial or not.

Go to se30 and execute the report, Then take the report and find out which select statement is taking more time and try to optimize that select statement by above methods, Do the same for all select statement and try to bring down database utilization from 97 to less than 50 always.

There are lot of documents available for performance tuning, Please go through that documents for more information.

Thanks and Regards,

Sajeesh

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,239

2. Try to avoid using more conditions in where clause as it creates load for database optimizer.

6. Avoid using into corresponding fields.

Where did you get these fads from? Get your facts correct before posting.

Read only

0 Likes
1,239

Sorry for that, Actually i didn't meant that not to use more where where condition in the select statement, Just meant, to avoid unwanted comparisons and all that makes the Fetching process bit  more time consuming.

Read only

Former Member
0 Likes
1,239

Hi sarnava,

Sorry for making my reply bit confusing.

The second point which i gave in my first reply was,

2. Try to avoid using more conditions in where clause as it creates load for database optimizer.

Please consider it as ,

Try to avoid " unwanted " comparison and other condition which could increase the fetching time.

And the point that i have mentioned above cannot be implemented everywhere , But try to use that if possible based on the input data we are getting.


Regarding the 6th point,


6.Try to avoid " into corresponding " clause if possible, Instead of this directly specify the the table or work area having similar structure as of selecting data.

Regards,


sajeesh

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,239
6.Try to avoid " into corresponding " clause if possible, Instead of this directly specify the the table or work area having similar structure as of selecting data.

It's wrong as well. Search in the forums for a blog about INTO CORRESPONDING.

Read only

0 Likes
1,239

Hi,

I went through the following blogs and it explains the use of " into corresponding " clause.

But in some blog it is showing that to avoid using "into corresponding".

ABAP Performance tips - Contributor Corner - SCN Wiki

Thanks and regards,

sajeesh

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,239

The former is with facts, while the latter is without. Which is more credible?

Anyway i think the OP should perform some trace on his code and then get back to the forums with his results. Until then the thread remains closed.

Read only

Former Member
0 Likes
1,239

Hi sarnava,

Please go to the following blog which explains most of the performance tuning tricks.

ABAP Performance tips - Contributor Corner - SCN Wiki

Regards,

sajeesh