Skip to main content

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
Key Principle

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​

TypeDescription
Direct Mapping1:1 mapping
ConstantFixed value
FormulaSimple expressions
DerivationRule-based
Best Practice

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
info

Start Routine → Package-level logic

warning

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
info

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​

Legacy Pattern

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
Strong Warning

Expert routines should be avoided in BW/4HANA 2.0 unless unavoidable.


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​

AreaBenefit
PerformanceVery high
ScalabilityExcellent
PushdownFull
ParallelizationNative

Typical Use Cases​

  • Lookups
  • Complex joins
  • Calculations
  • Data enrichment
  • Conditional logic
Best Practice

If logic can be expressed in SQL → use AMDP.


5.2 AMDP vs ABAP Routines​

AspectABAP RoutinesAMDP
ExecutionApp ServerHANA DB
PerformanceModerateHigh
PushdownNoYes
FutureLegacyStrategic

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
Best Practice

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
info

AMDP errors are easier to analyze using HANA tools.


7. Transformation Design Best Practices (VERY IMPORTANT)​

General Rules​

DOs

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'Ts

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​

AspectBW/4HANA 1.0BW/4HANA 2.0
RoutinesCommonDiscouraged
AMDPOptionalPreferred
PushdownPartialStrong
Expert RoutinesUsedAvoided

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

Learning Tip

In BW/4HANA, pushdown is not optional — it's mandatory.