CX_SY_ZERODIVIDE — CX_SY_ZERODIVIDE runtime exception
CX_SY_ZERODIVIDE is the class-based exception the ABAP runtime raises when a division statement encounters a zero divisor in code that participates in the class-based exception model. If nothing catches it, the session terminates with an UNCAUGHT_EXCEPTION short dump naming CX_SY_ZERODIVIDE as the exception class, pointing at the exact ABAP statement that performed the division.
This page covers the CX_SY_ZERODIVIDE exception, the class-based counterpart to the classic COMPUTE_INT_ZERODIVIDE and COMPUTE_BCD_ZERODIVIDE dumps, and how to trace it back to the master data value or missing check that produced the zero divisor. It focuses on reading the ST22 trigger location correctly and on why silently catching the exception is the wrong fix.
Published 16 Sept 2026· 1,139 words
What the dump means
Division by zero is not allowed for any numeric ABAP type. Older, non-object-oriented code triggers this as an immediate runtime error (COMPUTE_INT_ZERODIVIDE for integers, COMPUTE_BCD_ZERODIVIDE for packed/decimal). Code written against the class-based exception model, or code that calls a method internally implemented with class-based exceptions, raises CX_SY_ZERODIVIDE instead, an instantiable exception object that a surrounding TRY/CATCH block could theoretically intercept. When no CATCH exists anywhere in the call stack for CX_SY_ZERODIVIDE or one of its superclasses, the runtime still terminates the session, but the dump is classified as UNCAUGHT_EXCEPTION with the exception class named in the header. Functionally the two families are the same defect, arriving through two different ABAP language mechanisms.
Root causes that actually produce it
- Zero quantity or zero conversion factor in a unit-price or unit-cost calculation: amount divided by quantity, or a base-to-alternate unit of measure conversion factor read from a material master or unit conversion table that has never been maintained for that combination.
- Missing or zero exchange rate: currency conversion logic dividing by a rate fetched from the exchange rate table for a rate type or date combination that does not exist, returning an initial value of zero instead of a valid rate.
- Average or percentage calculations over an empty result set: dividing a total by a record count, item count, or number of periods that turns out to be zero because a preceding SELECT or internal table build returned nothing, often after a filter change or a period with no postings.
- Custom code without a guard clause: enhancement, BAdI implementation, or user exit performing a division without checking the divisor first, commonly copied from a template that assumed the divisor would always be populated.
- Uninitialized work variable: a divisor declared but never assigned because a selection screen field was left blank, a configuration table read failed silently, or a prior branch of logic was skipped.
- Statistical or costing routines dividing by a lot size, batch quantity, or standard price field that is zero in a newly created or incompletely maintained master record.
What to inspect in ST22
- Short text and exception class at the top of the dump: confirms this is CX_SY_ZERODIVIDE rather than the classic COMPUTE_INT_ZERODIVIDE, which tells the calling context is object-oriented or class-based exception aware.
- Trigger location of exception: identifies the exact program, include, and line where the DIVIDE, computation with the division operator, or MOD operation executed, plus the class and method if it happened inside a method call.
- Source code extract: shows the actual statement and the variable names on both sides of the division, which is the fastest way to see which field is the divisor.
- Active calls and local variables section: use it to find the value each variable held at the moment of termination, in particular confirming the divisor was zero or initial rather than some unexpected type mismatch.
- Follow into SE80 or SE38 to view the full routine, then ST05 or debugging with a breakpoint at the identified line to see how the divisor was populated, tracing it back to the SELECT or table read that supplied it.
Resolution path
If the divisor came from master data, such as a conversion factor, exchange rate, or price field, correct the master record; this is a data fix, not a code change, and does not need a transport. If the divisor came from a missing exchange rate table entry or missing unit conversion entry, maintain the missing entry through the relevant configuration or master data transaction. If the divisor is computed by custom code with no zero check, add a guard clause immediately before the division that either skips the calculation, defaults to a defined fallback value, or raises a meaningful business error instead of letting the runtime divide by zero; this requires an ABAP change and a transport through the normal development and testing cycle. If the division happens inside standard SAP code and the input data is genuinely valid, treat it as a possible program error and raise it with SAP support after confirming no configuration gap explains the zero value, since a code correction to standard objects should not be applied locally without going through the proper channel.
The fix people try first (and why it fails)
The reflex is to wrap the offending statement in TRY CATCH CX_SY_ZERODIVIDE, catch it, and move on with the result set to zero or left unchanged. This stops the dump but leaves the zero divisor unexplained. The calculation now silently produces a zero unit price, a zero converted amount, or a skipped average, and that wrong number propagates into pricing, costing, or reporting without any error visible to the user. Other divisions elsewhere in the same program, or in a different program reading the same bad master record, are not protected by the local catch and will dump again later, so the underlying data defect resurfaces unpredictably.
Prevention
Enforce a code review rule that no division statement is written without a preceding check on the divisor, ideally through a shared helper method or macro used consistently across custom developments rather than ad hoc IF statements repeated everywhere. For master data prone to zero values, such as conversion factors and standard prices, add a validation check at data entry so the field cannot be saved as zero when it is used as a divisor downstream. Periodic data quality reports scanning for zero conversion factors, missing exchange rates, or zero standard costs catch the condition before it reaches a production calculation.
Whose problem this is
Master data and configuration causes, such as a missing exchange rate or a zero conversion factor, belong to the functional team responsible for that master data. Missing validation in custom code belongs to ABAP development. The handover note should include the ST22 trigger location, the exact field identified as the divisor, its value at the time of the dump, and the master record or table entry that supplied it.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-abap-dumps/cx-sy-zerodivideERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.