Module 18: Code Pushdown Concept
Code pushdown means moving data-intensive logic from the ABAP application server to the database layer.
With SAP HANA’s in-memory architecture, pushdown is a core performance principle, not an optimization afterthought.
1. Why Code Pushdown?
Traditional ABAP Model (Pre-HANA)
- Database → Data retrieval only
- Application server → Heavy processing
- Large data transfers
HANA Model
- Database → Data retrieval + processing
- Application server → Orchestration & business logic
Move data-intensive logic to where the data lives.
2. DB vs Application Server Logic
Application Server Logic (Classic)
SELECT * FROM zsales
INTO TABLE @DATA(lt_sales).
LOOP AT lt_sales INTO DATA(ls_sale).
IF ls_sale-amount > 1000.
ls_sale-category = 'HIGH'.
ELSE.
ls_sale-category = 'LOW'.
ENDIF.
ENDLOOP.
Database Pushdown (Modern)
SELECT *,
CASE
WHEN amount > 1000 THEN 'HIGH'
ELSE 'LOW'
END AS category
FROM zsales
INTO TABLE @DATA(lt_sales).
Less data transfer, fewer loops, better performance. ::
3. Pushdown Options in ABAP
| Technique | Pushdown Level |
|---|---|
| Open SQL (advanced) | Medium |
| CDS Views | High |
| CDS Table Functions | Very High |
| AMDP | Maximum |
Prefer Open SQL → CDS → AMDP in that order.
4. Performance Comparison
Scenario: 1 Million Records
| Approach | Data Transfer | App Server Load | Performance |
|---|---|---|---|
| Loop-based ABAP | High | High | Poor |
| Open SQL expressions | Medium | Low | Good |
| CDS View | Low | Very Low | Excellent |
| AMDP | Minimal | Minimal | Best |
Pushdown is not about writing SQL everywhere — it is about placing logic correctly.
5. What Should Be Pushed Down?
Good Candidates
-
Filtering
-
Aggregations
-
Calculations
-
Joins
-
Grouping
-Sorting
SELECT carrid,
SUM( price ) AS total_price
FROM zflight
GROUP BY carrid
INTO TABLE @DATA(lt_totals).
6. What Should NOT Be Pushed Down?
6.1 Complex Business Logic
❌ Poor Pushdown Candidate
IF user_role = 'ADMIN' AND system_state = 'CLOSED'.
Reason:
-
Depends on application context
-
Hard to express in SQL
-
Poor readability
6.2 UI & Authorization Logic
-
UI behavior
-
User messages
-
Authorization checks
Database = data logic Application server = business & orchestration logic
6.3 Small Data Volumes
If dataset is small, clarity > pushdown.
7. When NOT to Push Down (Clear Rules)
-
Logic is procedural or stateful
-
Code becomes unreadable
-
Business rules change frequently
-
You need reuse across DBs
-
Performance gain is negligible
8. Code Pushdown Anti-Patterns
-
Moving everything into SQL
-
Writing unreadable monster queries
-
Using Native SQL unnecessarily
-
Ignoring maintainability
-
Overusing AMDP for simple logic
9. Interview-Grade Answer Template
Q: When should code be pushed down to HANA?
Answer:
Push down logic when it is data-intensive, set-based, and independent of application context. Avoid pushdown for complex business logic, UI behavior, or small datasets. Prefer Open SQL → CDS → AMDP based on complexity.
This framing is exactly what interviewers want to hear.
10. Summary
-
Pushdown improves performance by reducing data transfer
-
HANA enables in-memory processing
-
Not all logic should be pushed down
-
Choose the right pushdown technique
-
Maintainability matters as much as performance
11. Practice Exercises
-
Convert loop-based logic into SQL CASE expression.
-
Replace ABAP aggregation with GROUP BY.
-
Identify pushdown candidates in a report.
-
Decide when NOT to push down.
-
Compare Open SQL vs CDS pushdown.
12. What’s Next?
➡️ Module 19: CDS Views – Fundamentals
- Good developers push code down.
- Great developers know when not to.