Debug with a question in mind
Debugging is not random clicking. Start with a question: Does the total become 8 after the two quantities are added? In your own ABAP development environment, set a breakpoint at a meaningful point and inspect the relevant variable.
Follow the value
DATA(total) = 0.
LOOP AT quantities INTO DATA(quantity).
total = total + quantity.
ENDLOOP.
For quantities 3 and 5, trace the accumulator:
| Moment | total |
|---|---|
| Before the loop | 0 |
| After the first row | 3 |
| After the second row | 8 |
If the value is wrong, inspect the input row and accumulator at each iteration. A watchpoint or breakpoint can help answer a focused question in a real debugger; the exact tools and steps vary by environment.
A simple debugging routine
- Reproduce the issue with a small input.
- Set a breakpoint before the calculation or at the suspected branch.
- Step through and inspect the values that determine the result.
- Change one thing, then repeat the same check.
This webpage provides a trace and quiz only. It does not compile code or open an SAP debugger.
Sources
- SAP Samples, ABAP Cheat Sheets overview
- SAP Help Portal, ABAP Keyword Documentation
Developer practice · ABAP
Practice: predict the value at a breakpoint
The loop processes quantities 3 and 5. At the breakpoint after the loop, what total is shown? Choose the answer, then check.
Choose one answer for each question.