CX_SY_ZERODIVIDE¶
Raised when an integer or packed arithmetic division by zero is attempted.
Purpose¶
CX_SY_ZERODIVIDE is thrown by the /, DIV, and MOD operators when the divisor is zero and the operands are integer (TYPE I, INT8) or packed (TYPE P) types.
Inheritance chain:
CX_SY_ZERODIVIDE → CX_SY_ARITHMETIC → CX_DYNAMIC_CHECK → CX_ROOT
Float division behaves differently
TYPE F (floating point) division by zero does not raise this exception — it produces +Infinity. Only integer and packed types raise CX_SY_ZERODIVIDE. If not caught, the runtime dumps with COMPUTE_INT_ZERODIVIDE.
How to catch¶
REPORT z_zerodiv_cond.
START-OF-SELECTION.
DATA: lv_actual TYPE p DECIMALS 1 VALUE '75',
lv_total TYPE p DECIMALS 1 VALUE '0',
lv_pct TYPE p DECIMALS 1.
" Guard total > 0 before dividing — COND #( ) infers type from lv_pct
lv_pct = COND #(
WHEN lv_total > 0
THEN lv_actual * 100 / lv_total
ELSE 0 ).
WRITE: / 'Percentage:', lv_pct, '%'.
Key attributes¶
| Attribute | Type | Description |
|---|---|---|
Inherited: get_text( ) |
string |
Short message: "Division by zero" |
Inherited: get_longtext( ) |
string |
Extended description |
See also¶
COMPUTE_INT_ZERODIVIDE— dump raised when this exception is not caughtBCD_OVERFLOW— related packed arithmetic dump- Clean ABAP Quick Reference — TRY/CATCH patterns