ABAP Developmentintermediate
Rule of Thumb: DB First
Why tuning ABAP loops before SQL is usually wrong.
Explanation
Most performance problems are database problems. Aggregate in SQL (SUM/GROUP BY), avoid SELECT * (project explicit columns), use INNER JOINs over nested SELECTs, and consider CDS or AMDP for HANA-native processing. Only tune ABAP loops after the SQL is confirmed efficient.
Code example
ABAP Code
SELECT bukrs, SUM( dmbtr ) AS total FROM bkpf WHERE budat BETWEEN @lv_from AND @lv_to GROUP BY bukrs INTO TABLE @DATA(lt_totals).Real project scenario
Aggregating in SQL cut a 900k-row report from 15 minutes to 4 seconds โ no ABAP change needed.
Common mistakes
SELECT * INTO INTERNAL TABLE then LOOP + SUM on the app server; FOR ALL ENTRIES with duplicates.
Best practices
Explicit columns; join in DB when possible; measure before and after with ST05.
Interview angle
When does aggregating in ABAP still make sense?