ABAP 2 min read

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.

Akshay Palimkar
Akshay Palimkar

Founder & Principal SAP Consultant

Abstract teal and navy illustration of data being processed close to the database

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

  1. 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).
  2. 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.
  3. ABAP — orchestration, business rules, and anything that must call released APIs. Keep it thin.

Patterns that pay off immediately

  • Kill the N+1. A SELECT inside a LOOP becomes a single join or a FOR 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 BY for 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.

Akshay Palimkar

Written by

Akshay Palimkar

Akshay 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.