COMPUTE_INT_ZERODIVIDE¶
An integer division by zero was attempted.
ABAP integer arithmetic (TYPE I, INT8) does not produce infinity or NaN — dividing by zero immediately dumps the program.
Symptom¶
ST22 shows:
Runtime Errors COMPUTE_INT_ZERODIVIDE
Exception CX_SY_ZERODIVIDE
Short text Division by zero (integer arithmetic).
The dump line is the / or DIV or MOD operation where the divisor is zero.
Cause¶
Any division where the divisor evaluates to zero at runtime:
- A loop counter or aggregate that legitimately reaches zero (e.g. empty result set).
- A user-supplied denominator that was not validated.
- A calculated field that becomes zero in edge cases.
MODandDIV(integer division) behave the same as/— all three dump on zero.
Floating point behaves differently
TYPE F (float) division by zero does not dump — it produces +Infinity. Only integer (TYPE I, INT8) and packed (TYPE P) division dumps with this error. Packed division dumps as BCD_OVERFLOW, not COMPUTE_INT_ZERODIVIDE.
Reproduce¶
DATA: lv_total TYPE i VALUE 100,
lv_count TYPE i VALUE 0,
lv_avg TYPE i.
lv_avg = lv_total / lv_count. " <-- dumps
Fix¶
Prevention¶
- Treat every division as a potential zero-divide: add an
IF divisor > 0check orCONDbefore each/,DIV, orMOD. - When the divisor comes from a database aggregate (
COUNT(*),SUM), always test for the empty-result case. - Add a unit test with a zero denominator for any method that performs division.
See also¶
CX_SY_ZERODIVIDE— exception class for zero-divideBCD_OVERFLOW— packed decimal overflowCOMPUTE_INT_PLUS_OVERFLOW— integer arithmetic overflow- Transaction ST22 — ABAP runtime error analysis