Module 19: BW/4HANA & AMDP (ABAP Managed Database Procedures)
AMDP is the most powerful pushdown tool available to BW developers.
It allows BW logic to run directly inside SAP HANA, combining ABAP governance with SQLScript performance.
This module covers:
- AMDP basics
- AMDP transformations
- SQLScript usage in BW
- Performance-driven use cases
- Debugging AMDP logic
1. AMDP Basics
1.1 What is AMDP?
AMDP (ABAP Managed Database Procedures):
- Are ABAP methods implemented in SQLScript
- Executed directly in SAP HANA
- Managed and transported via ABAP
ABAP Class
↓
AMDP Method
↓
SQLScript (HANA Execution)
AMDP combines ABAP lifecycle management with database-native execution.
1.2 Why AMDP is Important in BW/4HANA
- Enables full HANA pushdown
- Eliminates ABAP loops
- Handles massive datasets efficiently
- Scales with data growth
AMDP is the bridge between BW and HANA.
2. AMDP Transformations (Strategic Replacement)
2.1 What is an AMDP Transformation?
An AMDP-based transformation replaces:
- Start routines
- Field routines
- End routines
- Expert routines
With:
- One HANA-executed SQLScript logic
Benefits Over ABAP Routines
| Aspect | ABAP Routines | AMDP |
|---|---|---|
| Execution | App Server | HANA DB |
| Performance | Medium | Very High |
| Pushdown | No | Yes |
| Scalability | Limited | Excellent |
If logic is complex and data volume is large → use AMDP.
3. SQLScript in BW Context
3.1 What is SQLScript?
SQLScript is:
- SAP HANA's procedural SQL language
- Set-based and declarative
- Optimized for parallel execution
Typical SQLScript Operations in BW
- Joins
- Aggregations
- Lookups
- Conditional logic
- Window functions
SELECT
customer,
SUM(amount) AS total_sales
FROM :source
GROUP BY customer;
SQLScript replaces ABAP loops with set-based logic.
4. Performance Use Cases for AMDP
4.1 Ideal Use Cases
Data volume is very large
Complex joins are required
Heavy calculations are involved
Lookups span multiple tables
4.2 Typical BW Scenarios
| Scenario | Why AMDP |
|---|---|
| Currency conversion | High volume |
| Time-dependent joins | Complex logic |
| Delta calculations | Performance |
| Data harmonization | Scalability |
4.3 When NOT to Use AMDP
Logic is trivial
Data volume is very small
ABAP-only APIs are required
5. Debugging AMDP Logic (Important & Often Ignored)
5.1 Why AMDP Debugging is Different
- Logic runs in HANA
- ABAP debugger cannot step through SQLScript
- Requires different tools
5.2 Debugging Techniques
1. SQL Console Testing
- Test SQLScript independently
- Validate logic step-by-step
2. Temporary Result Tables
- Output intermediate results
- Validate transformations
3. Error Stack Analysis
- Analyze DTP error stack
- Check SQLScript exceptions
4. HANA Studio / DB Explorer
- Analyze execution plans
- Check runtime behavior
Always test AMDP logic with realistic data volumes.
6. AMDP Error Handling
Common Error Types
| Error | Cause |
|---|---|
| SQL syntax error | Invalid SQLScript |
| Data type mismatch | Incorrect mapping |
| Runtime exception | Logic issue |
| Performance timeout | Inefficient query |
Error Handling Strategy
- Validate inputs early
- Handle NULL values
- Use controlled exits
- Log errors where possible
7. BW/4HANA 2.0 vs 1.0 (AMDP Usage)
| Aspect | BW/4HANA 1.0 | BW/4HANA 2.0 |
|---|---|---|
| AMDP adoption | Optional | Strongly recommended |
| ABAP routines | Common | Discouraged |
| Pushdown | Partial | Mandatory |
| Performance tuning | Mixed | Pushdown-first |
8. Common AMDP Design Mistakes
Rewriting ABAP logic blindly
Using SELECT * in SQLScript
Not handling NULLs
Overcomplicating logic
9. Interview-Grade Questions
Q1. Why is AMDP preferred over ABAP routines?
Answer: Because AMDP executes logic directly in HANA, enabling pushdown, parallel execution, and significantly better performance for large datasets.
Q2. How do you debug AMDP transformations?
Answer: By testing SQLScript independently, analyzing error stacks, using HANA tools, and validating intermediate results.
10. Summary
- AMDP is core to BW/4HANA pushdown
- SQLScript replaces ABAP-heavy logic
- AMDP transformations are strategic
- Performance gains are substantial
- Debugging requires HANA-centric tools
11. What's Next?
➡️ Module 20: Advanced Performance Optimization & Tuning
In BW/4HANA, AMDP is not an optimization — it's a design choice.