Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

4/26/2020 AMDP Statement performance trace | SAP Blogs

Community

Ask a Question Write a Blog Post

Technical Articles

Ankit Rastogi
February 13, 2019 4 minute read

AMDP Statement performance trace


Follow RSS feed Like

9 Likes 2,402 Views 6 Comments

1. Objective
The objective of this blog is to explain step-by-step process to trace AMDP method to analyze the performance
and pin-point any performance bottlenecks.

2. Requirement
Requirement is to analyze performance of any AMDP method which gives us a fair idea about its execution
times across it’s modularization units such as subsequent AMDP method calls within any AMDP method. The
developer would like to leverage AMDP statement trace utility to address this requirement.

3. Understanding limitation in regular performance traces

3.1 Transaction SAT


SAT transaction gives us performance snapshot across processing blocks in given transaction or report
program. This transaction provides the execution time of any given method, any given subroutine or any
function module etc. along with its percentage with respect to total. With new code push down techniques now
more and more code is being pushed to database layer, we are seeing increase in AMDP methods. However, SAT

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 1/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

transaction gives us idea that AMDP method is taking how much time, but it is displayed as single row in SAT
analysis snapshot mentioning as database procedure (DB: Exec).

The limitation arises when AMDP method is not so much straight forward. What if AMDP method itself has
thousands of lines of code with multiple AMDP methods call with in an AMDP method. See below screenshot.

One can see here one AMDP method CL_FR_DAYS_CALCULATION=CALC_FR_DAYS_PLAN takes majority time
approx. 28% of total (5.2 secs) in it’s processing. When we see this AMDP method, we nd that it has around
1500 lines of code with multiple AMDP method calls from with in. So it becomes di cult to pin point the
bottleneck in performance by seeing SAT results.

3.2 Transaction ST05


Transaction ST05 is also powerful tool to analyze performance. It provides various traces such as SQL Trace,
Bu er Trace, RFC Trace etc to trace and analyze the results. In case of AMDP methods, SQL trace provides
results similar to SAT Transaction. It provides one line of result that this database procedure is taking how much
of the time. But what is causing that much time is not clear by looking at the result. See below screenshot.

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 2/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

One can see here ST05 trace also provides high level view on AMDP method performance. It tells us that around
5.3 sec is execution time of our AMDP method, but it does not provide any further information on what caused
this execution time.

4. Steps to trace AMDP method

The following steps explain step by step process for AMDP method trace:

4.1 Run Transaction AMDP_UTILS


This transaction provides list of AMDP utilities present in our system.

4.2 RS_AMDP_STMT_TRACE Report


Double click on the line having RS_AMDP_STMT_TRACE report name and following screen appears.

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 3/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

Here we see self-explanatory buttons similar to transaction ST05 where one can switch on and switch o AMDP
statement trace.

Click on button ‘Activate Trace’ and then run your transaction.

Once your transaction is complete, click on button ‘Deactivate trace’ and then button ‘Display Trace Entries’ to
display the trace result.

5. Understanding AMDP trace with an example


In our current example, we have seen that the method CL_FR_DAYS_CALCULATION=>CALC_FR_DAYS_PLAN
takes 5.2 secs. Let’s trace it with AMDP_UTILS transaction and try to identify its performance bottlenecks.

Step 5.1: Activate the AMDP trace for current user


Run transaction AMDP_UTILS and then choose statement RS_AMDP_STMT_TRACE.

Click on button ‘Activate Trace’.

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 4/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

Con rmation message is displayed that trace is switched on for current user.

Step 5.2:
Now run your transaction and once your transaction is nished click on ‘Deactivate Trace’ button.

Step 5.3:
Now click on ‘Display Trace Entries’ button.

Following screen appears.

It list down all the AMDP method calls within your transaction and also displays execution time against each
AMDP method. Once can see here our AMDP method

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 5/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

CL_FR_DAYS_CALCULATION=>CALC_FR_DAYS_PLAN_AMDP takes 5.4 secs

Scroll to the right

We see a column ‘Display’. We can click on this button against any particular AMDP and it will display details
about each processing block with in AMDP method.

Step 5.4:
Click display button in front of AMDP method CL_FR_DAYS_CALCULATION=>CALC_FR_DAYS_PLAN_AMDP

Following screen appears.

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 6/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

We can see from here that out of 5.4 secs, 3.35 secs were spent while executing one underlying AMDP
CL_FR_DAYS_CALCULATION=>CALC_OUTB_QTY_EXTEN. Rest other AMDP’s are executing at fairly normal
level.

Step 5.5:
As we now know the performance pain point, we can focus our analysis in this AMDP only. After analyzing this
AMDP CL_FR_DAYS_CALCULATION=>CALC_OUTB_QTY_EXTEN, it was found that we have put SELECT
DISTINCT unnecessarily in one of it’s select query. This SELECT DISTINCT was causing underlying select query
to run slow.

Once we removed this SELECT DISTINCT, the performance is greatly improved. We can see the stats after this
change.

AMDP Trace after the code change:

SAT Trace after the code change:

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 7/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

Once can see the improvement in the performance.

Alert Moderator
Earlier same AMDP method was taking approx. 5.4 secs (28% of total), now after code changes, it takes only
0.3 secs to execute less than 2% of total execution time.

Assigned tags

ABAP Development | SAP S/4HANA | AMDP execution plan | AMDP Optimization | AMDP Performance |

View more...

Related Blog Posts

Call AMDP(ABAP Managed Database Procedure) Inside AMDP Method


By Amol Samte , Feb 26, 2015
ABAP for SAP HANA Reference Scenario - Video Tutorials
By Carine Tchoutouo Djomo , Oct 21, 2013

Handling Internal-table inside AMDP.


By Amol Samte , Apr 29, 2015

Related Questions

AMDP DUMP ISSUE


By Niket Gupta , Sep 13, 2019
AMDP take too much time to run when execute program, but when debug in DB it is very quick
By Dan Dan , Nov 14, 2019

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 8/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

ABAP CDS table with complex AMDP coding


By Bo Zhang , Dec 05, 2017

6 Comments

Badal Bhasin

February 13, 2019 at 11:02 am

Very informative blog..Very well explained!!

Like (1) Reply Alert Moderator

Jonathan Bourne

February 13, 2019 at 2:26 pm

The AMDP trace tool is not yet available in S/4 1610.

Like (0) Reply Alert Moderator

Ankit Rastogi | Post author

February 13, 2019 at 2:48 pm

It is available in 1709

Like (0) Reply Alert Moderator

Vijayakumar Mukunthan

February 14, 2019 at 7:09 am

Hi Ankit

The blog is very clearly explained step by step execution and new learning to me. Keep it up. Good job.

Thanks and Regards

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 9/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

Vijay

Like (1) Reply Alert Moderator

Gaurav Sharan

February 19, 2019 at 9:57 am

Thanks for sharing.. Very Informative.

Like (1) Reply Alert Moderator

Venkata Sreekar Krothapalli

May 22, 2019 at 1:51 am

Thanks for the detailed steps.

We are on SAP BW 750, SP 08 and don’t have the the transaction: AMDP_UTILS or some of the other programs
you’ve mentioned in this blog. What’s the minimum system requirement to perform the various AMDP traces
you’ve outlined in your blog ?

Like (0) Reply Alert Moderator

Add Comment

Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Newsletter Support

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 10/11
4/26/2020 AMDP Statement performance trace | SAP Blogs

https://blogs.sap.com/2019/02/13/amdp-statement-performance-trace/ 11/11

You might also like