Skip to main content

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
HANA Philosophy

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).
Result

Less data transfer, fewer loops, better performance. ::

3. Pushdown Options in ABAP

TechniquePushdown Level
Open SQL (advanced)Medium
CDS ViewsHigh
CDS Table FunctionsVery High
AMDPMaximum
SAP Recommendation

Prefer Open SQL → CDS → AMDP in that order.

4. Performance Comparison

Scenario: 1 Million Records

ApproachData TransferApp Server LoadPerformance
Loop-based ABAPHighHighPoor
Open SQL expressionsMediumLowGood
CDS ViewLowVery LowExcellent
AMDPMinimalMinimalBest
Interview Trap

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

Separation of Concerns

Database = data logic Application server = business & orchestration logic

6.3 Small Data Volumes

Rule of Thumb

If dataset is small, clarity > pushdown.

7. When NOT to Push Down (Clear Rules)

Do NOT Push Down When
  • 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

Avoid These
  • 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.

Use This Answer

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

Learning Tip
  • Good developers push code down.
  • Great developers know when not to.