A Comprehensive Guide to AMDP Performance Analysis in SAP Using Transaction AMDP_UTILS
If you develop with ABAP Managed Database Procedures (AMDP), you already know how incredibly powerful they are — pushing complex logic down to SAP HANA for lightning-fast execution.
However, when an AMDP suddenly becomes a performance bottleneck due to long runtime, high memory consumption, or unexpected behavior, identifying the exact source of the issue within SQLScript code can be challenging.
That’s where transaction AMDP_UTILS comes in. This powerful utility provides a comprehensive suite of tracing and profiling tools specifically designed for AMDP.
In this blog post, I’ll walk you through the key utilities available in AMDP_UTILS, along with step-by-step instructions, column breakdowns, interpretation tips, and real-world usage scenarios to help you effectively analyze and optimize your AMDP implementations.
Let’s get started.
Code Walkthrough: AMDP Enrichment Class
Class Definition: ZCL_TEST_ENRICH_PERF
The screenshot below shows the ABAP class definition for ZCL_TEST_ENRICH_PERF, an AMDP-enabled class that exposes multiple class methods for enriching POS reconciliation transaction data.
Key points:
- The class implements IF_AMDP_MARKER_HDB, which identifies it as an AMDP class designed to execute on SAP HANA.
- ENRICH_TRANSACTIONS1 accepts a complete set of POS reconciliation data (IT_DATA) along with mode and variant parameters, and returns the enriched results through ET_DATA.
- ENRICH_TRANSACTIONS is a simplified variant that accepts only mode and variant parameters as inputs and returns the enriched dataset through ET_ENRICHED_DATA, while handling data retrieval internally.
SQLScript Implementation: ENRICH_TRANSACTIONS
The screenshot below shows the SQLScript body of the ENRICH_TRANSACTIONS AMDP method. As an AMDP database procedure, the method executes directly on SAP HANA using SQLScript.
Key points:
- The method is declared using BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY, indicating it executes entirely on HANA without modifying data.
- The main IT_DATA variable selects a curated set of fields from IT_DATA_TEMP, hardcoding ‘2’ as PROC_STATUS to mark these records as processed.
- The enrichment logic itself is delegated to the nested AMDP method ZCL_TEST_ENRICH_PERF=>ENRICH_TRANSACTIONS1, passing the pre-filtered dataset along with mode, store type (IS_STYP=‘D’), and variant reference, and collecting the result in ET_ENRICHED_DATA.
- This two-stage pattern — filtering the data first, then performing enrichment via a dedicated AMDP is a common performance optimization technique. By reducing the volume of data passed to the enrichment procedure, it helps improve overall execution efficiency and resource utilization.
Getting Started – Running AMDP_UTILS
Transaction: AMDP_UTILS
AMDP_UTILS serves as the central cockpit for all AMDP-related utilities in your SAP systems, including, ECC on HANA, S/4HANA, and BW/4HANA.
When you execute the transaction, a list of available prototypes and reports is displayed, including:
-
AMDP PlanViz trace
-
AMDP Statement trace
-
AMDP Plan profiler
-
AMDP Coverage trace
-
AMDP monitoring trace
-
AMDP debugger traces
-
Compare Dependencies.
These utilities help developers analyse AMDP execution from different perspectives, ranging from statement-level performance and memory consumption to code coverage, debugging, and dependency validation.
Note: All traces are user-specific and session-specific, ensuring that trace activities do not impact other developers or system users.
-
AMDP PlanViz Trace Prototype (RS_AMDP_PLANVIZ_TRACE)
Purpose: The AMDP PlanViz Trace provides access to the full SAP HANA Execution Plan Visualizer (PlanViz) for an AMDP. It delivers the same detailed graphical execution analysis available in SAP HANA Studio, but can be triggered directly from the ABAP environment using transaction AMDP_UTILS.
When to Use It:
Use this trace when you need to analyse the internal execution behavior of an AMDP at the database level. It provides detailed insights into:
-
SQL operators such as JOIN, AGGREGATE, and FILTER
-
Estimated versus actual row counts
-
Memory consumption
-
CPU and execution time
-
Data flow between processing steps
Deep HANA-specific tuning
Step-by-Step Guide to Capturing a PlanViz Trace
-
Run AMDP_UTILS.
-
Select RS_AMDP_PLANVIZ_TRACE.
3. Click Activate Trace.
4. Go to Eclipse/ADT → Execute your AMDP class/method or run the program/DTP that calls it.
5. Return to AMDP_UTILS → Deactivate Trace.
6. Click Display Trace Entries.
7. Review the execution details and select Display.
8. The PlanViz document opens in HTML or graphical view.
-
HTML View
-
Graphical View
What you will see:
-
A graphical representation of the AMDP execution flow and HANA operators.
-
Runtime details, including execution time, CPU usage, and memory consumption for each processing step.
-
Options to zoom, filter, and export the execution plan for further analysis.
Pro Tip: Always compare PlanViz results before and after implementing your performance optimizations such as adding filters or modifying join orders, to measure their impact.
2. RS_AMDP_STMT_TRACE – The Most Popular One (Statement Performance Trace)
Purpose: The Statement Performance Trace breaks down each individual processing block (SQL statement) within an AMDP method and shows the execution time and memory memory consumption for every processing block.
For most AMDP performance issues, this is the first and most frequently used analysis tool.
Step-by-Step:
-
Run AMDP_UTILS and select RS_AMDP_STMT_TRACE.
2. Click Activate Trace.
3. Execute the required AMDP method.
4. Return to AMDP_UTILS and Deactivate Trace.
5. Click Display Trace Entries.
6. Select the Display icon to view detailed execution statistics.
The trace output provides a detailed breakdown of the execution time and memory utilization for each processing block within the AMDP.
Key Columns Explained
Column Meaning Why it matters
| #Exce | Number of times the statement or processing block was executed | A high execution count combined with a long runtime can indicate a significant performance bottleneck |
| Mat Mem | Materialization memory used for temporary tables and intermediate results | High values may indicate excessive memory consumption and potential memory pressure |
| Mat Time | Time spent creating temporary tables and intermediate results | Often reveals hidden performance bottlenecks that are not visible from execution time alone |
| Nav | Navigates directly to the corresponding ABAP source code line | Simplifies troubleshooting and accelerates debugging |
| Stmlen | Length of the SQL statement in characters | Longer statements are typically more complex and may require closer analysis |
How to Use the Results:
-
Sort the trace entries by Mat Time or Total Time descending order.
-
Focus on the statement with the highest execution time, as it is often the primary performance bottleneck.
-
Use the Nav option to jump directly to the corresponding line in the AMDP source code for further analysis.
Common Optimization Techniques
-
Remove unnecessary DISTINCT statements.
-
Apply filters as early as possible in the processing flow.
-
Use table variables efficiently and avoid excessive temporary tables.
-
Replace inefficient subqueries with optimized joins where appropriate.
Real-World Example: In one project, a SELECT DISTINCT on a large table inside a loop accounted for most of the runtime. By removing the unnecessary DISTINCT and applying a more selective WHERE clause, the execution time was reduced from approximately 45 seconds to less than 2 seconds.
3. AMDP Plan Profiler Trace Prototype
Purpose: In SAP systems (especially ECC on HANA, S/4HANA, or ABAP environments with HANA backend), the AMDP Plan Profiler Trace Prototype is an advanced utility available in transaction AMDP_UTILS.
It provides a hierarchical, tree-structured view of the entire execution flow of an ABAP Managed Database Procedure (AMDP), including:
-
Calls from ABAP code into the AMDP method.
-
Nested calls between AMDP procedures.
-
Individual SQL statement executions within the AMDP.
-
Resource consumption metrics such as execution time, CPU usage, memory consumption at each level.
When to Use It
-
An AMDP method invokes other AMDP procedures (nested or modular AMDPs).
-
You need to understand the complete call hierarchy and identify where execution time or memory is being consumed.
-
A statement-level trace is insufficient because the performance bottleneck may reside in a called procedure rather than the parent AMDP.
Key Difference from Other Traces
-
RS_AMDP_STMT_TRACE focuses on individual SQL blocks within an AMDP method and presents the results as a flat list with execution metrics for each statement.
-
AMDP Plan Profiler Trace provides a hierarchical call tree that shows parent-child relationships between procedures and statements, along with aggregated metrics such as Total Time, Self Time, Total Memory, and Self Memory.
In short, the Statement Trace helps identify slow SQL statements, while the Plan Profiler helps determine where time and resources are consumed across the entire AMDP execution hierarchy.
When to Use It:
-
Your AMDP implementation contains nested AMDP calls or complex call chains.
-
You need a CPU and memory breakdown across multiple execution layers.
What the Tree View Shows
-
Top-level ABAP calls into an AMDP.
-
Procedure calls from one AMDP to another.
-
Individual SQL statement executions.
Step-by-Step: How to Use AMDP Plan Profiler Trace Prototype via AMDP_UTILS
-
Run Transaction AMDP_UTILS
-
Select AMDP Plan Profiler Trace Prototype
3. Click Activate Trace
4. Execute the required AMDP method, report, transformation, or application process.
5. Return to AMDP_UTILS and click Deactivate Trace.
6. Click Display Trace Entries to view the captured executions.
7. Select the required trace entry and click Display.
8. Expand the tree nodes to analyze the call hierarchy and execution details.
Analyzing the Results
-
Expand the nodes to view nested AMDP calls and SQL statement executions.
-
Compare Total Memory and Self Memory to determine where resources are being consumed.
-
Use the Nav option to jump directly to the relevant source code.
-
Sort by execution time or memory-related columns to quickly identify bottlenecks.
Core Features & Columns
Column Meaning Why It Matters / Interpretation Tips
| Tot Mem | Total Memory consumed by the operation including all child calls | Helps identify resource-intensive branches within the execution hierarchy |
| Self Mem | Memory consumed by the current node only, excluding child operations. | High values indicate that the current operation itself is a major memory consumer |
| Nav | Navigate directly to the related ABAP source code | Speeds up analysis by allowing quick access to the relevant AMDP implementation |
| Operator I | Internal HANA operator identifier | Useful for correlating profiler results with HANA PlanViz analysis |
| Parent Ope | Parent operator identifier | Helps understand the execution hierarchy and parent-child relationships |
| Operator H | HANA host or server executing the operation | Useful when analysing distributed HANA landscapes (rarely an issue). |
| Operator P | HANA operator port information | Primarily used for advanced troubleshooting and system-level analysis. |
Tip: Comparing these two columns is often the quickest way to identify performance bottlenecks in complex AMDP call chains.
4. AMDP Coverage Trace Prototype
Purpose: The AMDP Coverage Trace Prototype is a specialized utility available in transaction AMDP_UTILS that performs statement-level code coverage analysis for ABAP Managed Database Procedures (AMDPs).
Unlike performance-focused utilities such as RS_AMDP_STMT_TRACE and AMDP Plan Profiler, the Coverage Trace focuses on code execution coverage. It helps answer a simple but important question: Which lines of my AMDP method were executed, which were not?
This utility is particularly useful for:
-
Unit testing and test-driven development of AMDPs.
-
Identifying unused or unreachable code within SQLScript blocks.
-
Verifying that all execution paths, including IF conditions, CASE statements, and loops, are properly tested.
-
Supporting code quality and coverage targets in projects.
The results are presented at the ABAP source code level, allowing you to view the original AMDP method with execution coverage indicators. This provides an experience similar to the ABAP Coverage Analyzer, but specifically tailored for AMDP development.
Key Output Fields and Features
Field / Button Meaning Interpretation Tips
| Execution Time | Total runtime of the traced AMDP execution | Provides overall execution context but is not the primary focus of coverage analysis |
| List of Executed Methods | AMDP methods executed during the trace | Helps identify which methods were actually invoked |
| %cov | Percentage of executable statements covered during execution | Higher values indicate better test coverage; aim for high coverage in critical AMDPs |
| %Tot | Number or percentage of executed statements relative to the total statements | Indicates the overall extent of code coverage |
| ABAP | Opens the corresponding ABAP source code | Allows direct navigation to the AMDP implementation |
| Raw data | Displays detailed coverage information and technical data | Useful for advanced analysis and reporting |
| Object Method View | Displays the AMDP source code with color highlighting | Executed statements are highlighted in green lines separately from non-executed statements in red lines, making coverage gaps easy to identify |
Step-by-Step Execution
-
Run Transaction AMDP_UTILS
-
Select AMDP Coverage Trace Prototype from the list of available utilities.
3. Click Activate Trace
4. Execute the required AMDP method, report, DTP, or application process. To obtain meaningful coverage results, execute multiple test scenarios that exercise different code paths and conditions
5. Return to AMDP_UTILS and click Deactivate Trace
6. Click Display Trace Entries to view the captured executions
7. Select the required trace entry and click Display.
Coverage Results
-
The coverage analysis provides:
-
A summary view containing coverage metrics such as %cov and %Tot.
-
A list of executed AMDP methods captured during the trace.
-
The AMDP source code with coverage highlighting (executed in green and non-executed in red), allowing you to identify executed and non-executed code paths.
5. AMDP Monitoring Trace Prototype
Purpose: The AMDP Monitoring Trace Prototype is a specialized utility available in transaction AMDP_UTILS.
Unlike RS_AMDP_STMT_TRACE, which focuses on statement-level analysis, or the AMDP Plan Profiler, which provides a hierarchical execution view, the Monitoring Trace serves as a lightweight health-check tool for identifying expensive operations.
It helps you instantly identify:
-
Resource-intensive SQL statements within an AMDP.
-
Relevant information from the SAP HANA Plan Cache, including execution plan usage and reuse.
This utility is particularly useful when you need a high-level view of performance hotspots before performing a more detailed analysis with PlanViz or Statement Trace.
Two powerful buttons:
Button Full Name What it Shows
| DisExp | Display Expensive Statements | Displays the most resource-intensive statements and procedures along with their performance metrics |
| DisPlan | Display Plan Cache | Displays HANA Plan Cache entries, showing how execution plans are generated, stored, and reused for the AMDP |
Step-by-Step Execution
-
Run Transaction AMDP_UTILS
-
Select AMDP Monitoring Trace Prototype from the list of available utilities.
3. Activate the Trace
4. Execute the AMDP method, report, transformation, or application process that you want to analyze.
5. Return to AMDP_UTILS and click Deactivate Trace.
6. Click Display Trace Entries to view the list of executed AMDP methods with basic runtime info.
7. Analyze the Monitoring Data
-
Click DisExp → Opens the Expensive Statements view with the columns listed above.
-
Click Display Plan Cache to analyze execution plan generation and reuse within SAP HANA.
This utility serves as a quick health check for AMDP performance and resource consumption.
6. AMDP Debugger Trace & Debugger Prototype
These are two related utilities available in transaction AMDP_UTILS. Unlike the performance-focused traces such as Statement Trace, Plan Profiler, and Monitoring Trace, they are designed specifically for debugging and troubleshooting AMDP execution.
AMDP Debugger Trace
Purpose: The AMDP Debugger Trace logs the various debugging events that occur when an AMDP method is executed through Eclipse/ADT. It captures the internal flow of debugging activities, including breakpoint hits, stepping, variable inspection, debugger activation and deactivation, context switches between ABAP and SAP HANA layers.
Key Characteristics
-
Focuses on debugger event logging rather than performance analysis.
-
Records the sequence of debugging activities during AMDP execution.
-
Does not provide execution times, memory statistics, or execution plans.
-
Helps diagnose debugger-related issues, such as breakpoints not being triggered or unexpected debugger behavior.
Result for AMDP Debugger Trace
The debugger trace displays a chronological log of debugging events captured during AMDP execution. This includes debugger activation, breakpoint hits, step execution, context switches between ABAP and HANA, and other debugging-related activities.
AMDP Debugger Prototype
Purpose: The AMDP Debugger Prototype provides a prototype implementation of AMDP debugging within SAP ECC. It allows developers to debug AMDP methods using the standard ABAP Debugger, even though the actual execution takes place in the SAP HANA database layer.
Key Characteristics
-
Opens the AMDP method in the standard ABAP Debugger.
-
Acts as a bridge between the SAP HANA execution environment and the ABAP debugging framework.
-
Helps troubleshoot AMDP logic using familiar debugging tools and techniques.
Result for AMDP Debugger Prototype
The prototype opens the AMDP method in the standard SAP GUI debugger, allowing developers to debug the AMDP execution flow directly from the ABAP environment.
When the AMDP method is executed from Eclipse/ADT, the system automatically switches to the SAP GUI debugger and displays the corresponding AMDP code in debugging mode.
Step-by-Step Execution
-
Run Transaction AMDP_UTILS
-
Select the desired prototype:
-
AMDP Debugger Trace for debugger event logging.
-
AMDP Debugger Prototype for interactive debugging.
-
-
Click Activate Trace or Activate.
-
Execute the AMDP method from Eclipse/ADT or from the calling application.
-
For the Debugger Prototype, the ABAP Debugger opens automatically when the breakpoint is reached.
-
Return to AMDP_UTILS and click Deactivate Trace.
-
For the Debugger Trace, select Display Trace Entries to review the captured debugger events.
7. Compare Dependencies Between ABAP and HANA
Purpose: The Compare Dependencies Between ABAP and HANA utility is a diagnostic tool available in transaction AMDP_UTILS.
It performs a side-by-side comparison of object dependencies for AMDP classes and methods from two perspectives.
-
ABAP side (ABAP repository objects): Includes the AMDP class, method definitions, referenced ABAP Dictionary objects (tables, views, data elements), and other ABAP classes.
-
HANA side (database catalog): Includes the automatically generated HANA database procedures, functions, table functions, and their dependencies within the SAP HANA schema (e.g., _SYS_BIC, your package schema, or _SYS_REPO).
Why it exists: When an AMDP class is activated, SAP automatically creates or updates corresponding HANA procedures. In some cases these two layers get out of sync due to:
-
Transport issues
-
Partial activations
-
Manual HANA changes
-
Missing dependent objects
-
Schema or package mismatches
This utility helps identify and resolve such inconsistencies quickly, making it especially useful before transporting AMDP objects to QA or production systems or during troubleshooting activation or runtime errors.
Typical Output
The utility displays a list or tree view of object dependencies.
Two display modes are available through a checkbox (typically labeled “HANA Only” or “Show Only HANA Objects”):
-
Without the checkbox selected: Displays a full comparison of objects from both the ABAP repository and the HANA catalog, including indicators for matches and mismatches.
-
With the checkbox selected: Displays only HANA-side objects, making it easier to review what has been generated in the database.
Step-by-Step Execution
-
Run transaction AMDP_UTILS in SAP GUI.
-
Select Compare Dependencies Between ABAP and HANA from the list of available utilities.
3. (Optional) Select the HANA only check box.
4. Click Execute or Display. Since this is a static analysis utility, there is no need to activate a trace or execute an AMDP beforehand.
5. Review the results:
-
Objects are displayed along with their type (table, view, procedure, etc.).
-
ABAP object names can be compared with their corresponding HANA technical names.
-
Mismatches or missing objects are typically highlighted.
Result Without Selecting the Checkbox
Results With Selecting the Checkbox
This view is particularly useful for identifying missing or inconsistent objects before transport activities.
Best Practices & Pro Tips
-
Activate only one trace at a time to avoid collecting unnecessary or confusing trace data.
-
Run traces in a dedicated test environment or with a smaller dataset whenever possible.
-
After each optimization, re-run the same trace and compare the results.
-
Combine utilities for deeper analysis: use Statement Trace to identify the slow statement and PlanViz to understand why it is slow at the HANA level.
-
These utilities work effectively with AMDP routines used in BW transformations and DTPs.
-
Keep AMDP methods modular and focused to simplify tracing, debugging, and performance analysis.
Conclusion
Transaction AMDP_UTILS is one of the most underutilized yet powerful tools available to SAP HANA and ABAP developers. Whether you need statement-level performance analysis, graphical execution plans through PlanViz, code coverage insights, debugging support, or dependency validation, AMDP_UTILS provides a comprehensive set of utilities to help you analyze, troubleshoot, and optimize your AMDP implementations.
Read More Technology Blog Posts by Members articles
#abap