Push logic down: CDS, AMDP and the HANA mindset
The single biggest performance lever in S/4HANA is doing the work in the database. A practical guide to code pushdown with CDS and AMDP.
Founder & Principal SAP Consultant
A lot of “slow ABAP” isn’t slow ABAP — it’s ABAP doing work the database should do.
The classic pattern: SELECT a wide result set, loop over it in the application
layer, and aggregate or filter in memory. On HANA, that throws away the engine’s
biggest advantage. The Clean Core fix is code pushdown.
The mindset shift
Move the calculation to the data, not the data to the calculation.
In practice that means expressing joins, filters, aggregations and even moderately complex logic in CDS views, and reserving ABAP for orchestration and business rules that genuinely can’t live in SQL.
The tools, in order of reach
- CDS views — joins, associations, filters, aggregations, calculated fields and parameters. This handles the large majority of reporting and read logic, and it’s the foundation of the virtual data model (VDM).
- AMDP — when you need procedural, set-based logic that’s still best run in the database (e.g. a multi-step transformation), an ABAP-Managed Database Procedure keeps it close to the data while staying in your transport.
- ABAP — orchestration, business rules, and anything that must call released APIs. Keep it thin.
Patterns that pay off immediately
- Kill the N+1. A
SELECTinside aLOOPbecomes a single join or aFOR ALL ENTRIES/CDS association. This is usually the biggest single win. - Aggregate in CDS, not in an internal table after the fact.
- Use table expressions and
FILTER/REDUCE/GROUP BYfor the in-memory work that genuinely remains.
How to find the wins
Don’t guess. Profile first — ST03N, SAT, and ST05 will point at the real hot
spots, and lightweight instrumentation pins down the slow method. (Our open-source
utilities include a small profiler/stopwatch for exactly that.) Then
push the offending logic down.
The Clean Core bonus
Pushdown isn’t only about speed. CDS views are released, cloud-ready building blocks that double as the data layer for RAP and Fiori — so the same refactor that makes a report fast also moves it toward a clean core. Want the hot spots found and fixed? Book an assessment.
Written by
Akshay PalimkarAkshay is an SAP ABAP engineer with 15 years across ECC, S/4HANA, RAP and Clean Core. He builds the open-source tools and training he consults with.