SAP ABAP development · LessonBy Arjun, SAP Solution Architect · Published · SAP S/4HANA 2023 · all levels
Performance
ABAP performance is mostly about how you access the database and process internal tables. A handful of well-known rules separate fast custom code from the slow programs that plague many SAP systems.
Quick answer
On HANA, push logic to the database (CDS, Open SQL with aggregation) and avoid row-by-row ABAP processing.
Key takeaways
- Never SELECT inside a loop, read all needed data once, then work in memory.
- Select only needed columns and rows, avoid SELECT * and always use a WHERE.
- Use appropriate indexes, ensure your WHERE matches an index; add one if needed.
- Watch out: SELECT in a loop, the number-one offender.
The database rules (most important)
- Never SELECT inside a loop, read all needed data once, then work in memory.
- Select only needed columns and rows, avoid SELECT * and always use a WHERE.
- Use appropriate indexes, ensure your WHERE matches an index; add one if needed.
- Aggregate/join in the database (Open SQL, CDS) rather than in ABAP loops, especially on HANA (code-to-data).
Internal-table rules
- Use SORTED/HASHED tables (or BINARY SEARCH) for repeated lookups instead of linear READ.
- Loop with ASSIGNING FIELD-SYMBOL to avoid copying rows.
- Avoid nested loops over large tables; use keyed access or joins.
Measure, do not guess
" tools: SAT (runtime analysis), ST05 (SQL trace),
" ST12 (single-transaction trace), ST03 (workload)HANA changes emphasis
On HANA, push logic to the database (CDS, Open SQL with aggregation) and avoid row-by-row ABAP processing. The classic anti-patterns (SELECT in loop, SELECT *) hurt even more when the database is fast and the bottleneck becomes needless round-trips.
Common pitfalls
- SELECT in a loop, the number-one offender.
- SELECT * / no WHERE, reading too much.
- Linear reads and nested loops on big internal tables.
Practice challenge
+0 XPStreak ×0
Question 1 of 3
Which statement is true of Performance?
Frequently asked questions
What does the term Performance refer to in SAP?
ABAP performance is mostly about how you access the database and process internal tables. A handful of well-known rules separate fast custom code from the slow programs that plague many SAP systems.
What is another point to note about Performance?
On HANA, push logic to the database (CDS, Open SQL with aggregation) and avoid row-by-row ABAP processing.
What else is worth knowing about Performance?
Never SELECT inside a loop, read all needed data once, then work in memory. Select only needed columns and rows, avoid SELECT * and always use a WHERE. Use appropriate indexes, ensure your WHERE matches an index; add one if needed.
What tends to go wrong with Performance?
SELECT in a loop, the number-one offender. SELECT * / no WHERE, reading too much. Linear reads and nested loops on big internal tables.