Module 9: Transformations & Data Flow Logic (BW/4HANA 2.0)
Transformations define how data is converted, enriched, and validated as it flows through BW/4HANA.
In modern BW/4HANA, transformations are no longer ABAP-heavy — they are pushdown-oriented and HANA-optimized.
This module covers:
- Field-level mapping
- Routines (Start / Field / End)
- Expert routines
- AMDP-based transformations
- Error handling strategies
1. What is a Transformation?
A Transformation maps data from:
- Source object (DataSource / aDSO / Open ODS)
- to a Target object (usually aDSO)
It defines:
- Field mappings
- Business rules
- Enrichments
- Data validation
Source → Transformation → Target
Transformations define business logic, not reporting logic.
2. Field-Level Mapping (Basic & Most Common)
What is Field-Level Mapping?
Direct mapping of:
- Source field → Target InfoObject
Example:
SOURCE.SALES_AMT → 0NETVALUE
Types of Field Mapping
| Type | Description |
|---|---|
| Direct Mapping | 1:1 mapping |
| Constant | Fixed value |
| Formula | Simple expressions |
| Derivation | Rule-based |
Always start with simple field-level mapping before adding routines.
3. Routines in Transformations (Classic Logic)
Routines allow custom ABAP logic during data transformation.
3.1 Start Routine
When It Runs
- Once per data package
- Before field mappings
Typical Use Cases
- Data filtering
- Pre-calculation
- Global checks
Start Routine → Package-level logic
Start routines execute in ABAP — use sparingly.
3.2 Field Routine
When It Runs
- For each record
- For one target field
Typical Use Cases
- Field derivation
- Conditional mapping
Field Routine → Row-level logic
3.3 End Routine
When It Runs
- After all records are processed
- Once per package
Typical Use Cases
- Aggregations
- Final adjustments
- Lookup logic
Performance Consideration
Start / Field / End routines are ABAP-based and reduce HANA pushdown.
4. Expert Routines (Advanced ABAP Logic)
What is an Expert Routine?
An Expert Routine replaces:
- Field mappings
- Individual routines
With:
- One single ABAP logic block
Characteristics
- Full control over source & target
- Highly flexible
- Executes entirely in ABAP
When Expert Routines Were Used (Historically)
- Very complex transformations
- Legacy BW 7.x logic
- Non-SQL-friendly logic
Expert routines should be avoided in BW/4HANA 2.0 unless unavoidable.
5. AMDP-Based Transformations (Recommended)
5.1 What is AMDP Transformation?
AMDP-based transformations:
- Execute logic in SAP HANA
- Use SQLScript
- Enable maximum pushdown
They are the strategic replacement for ABAP routines.
Key Advantages
| Area | Benefit |
|---|---|
| Performance | Very high |
| Scalability | Excellent |
| Pushdown | Full |
| Parallelization | Native |
Typical Use Cases
- Lookups
- Complex joins
- Calculations
- Data enrichment
- Conditional logic
If logic can be expressed in SQL → use AMDP.
5.2 AMDP vs ABAP Routines
| Aspect | ABAP Routines | AMDP |
|---|---|---|
| Execution | App Server | HANA DB |
| Performance | Moderate | High |
| Pushdown | No | Yes |
| Future | Legacy | Strategic |
6. Error Handling in Transformations
6.1 Why Error Handling Matters
Errors in transformations can:
- Break data loads
- Corrupt downstream data
- Cause delta inconsistencies
6.2 Error Handling Mechanisms
Error Stack
- Invalid records are written to error stack
- Valid records continue processing
Always enable error handling for business-critical loads.
Record-Level Errors
Examples:
- Conversion errors
- Mandatory field missing
- Invalid master data
Package-Level Errors
Examples:
- Short dumps
- Logic exceptions
- AMDP SQL errors
6.3 Error Handling in AMDP
- SQLScript exception handling
- Logging to error tables
- Controlled termination
AMDP errors are easier to analyze using HANA tools.
7. Transformation Design Best Practices (VERY IMPORTANT)
General Rules
Keep transformations simple
Centralize business logic
Prefer AMDP routines
Avoid duplicate logic
Performance Rules
- Avoid field routines for heavy logic
- Avoid expert routines
- Reduce lookups inside loops
Architecture Rules
Don't put reporting logic in transformations
Don't hardcode values
Don't bypass semantic layers
8. BW/4HANA 2.0 vs BW/4HANA 1.0
| Aspect | BW/4HANA 1.0 | BW/4HANA 2.0 |
|---|---|---|
| Routines | Common | Discouraged |
| AMDP | Optional | Preferred |
| Pushdown | Partial | Strong |
| Expert Routines | Used | Avoided |
9. Interview-Grade Questions
Q1. Why are AMDP transformations preferred?
Answer: Because they execute logic directly in SAP HANA, enabling pushdown, parallelization, and significantly better performance compared to ABAP-based routines.
Q2. When would you still use ABAP routines?
Answer: Only when logic cannot be expressed in SQLScript or requires complex ABAP-only processing.
10. Summary
- Transformations define data logic
- Field-level mapping should be default
- ABAP routines are legacy
- AMDP is the strategic choice
- Proper error handling is critical
11. What's Next?
➡️ Module 10: Delta Management & Request Handling
In BW/4HANA, pushdown is not optional — it's mandatory.