COMPUTE_INT_PLUS_OVERFLOW¶
An integer arithmetic result exceeded the maximum value for the target type.
The result of addition, subtraction, multiplication, or negation on a TYPE I or TYPE INT8 value went beyond the type's range.
Symptom¶
ST22 shows:
Runtime Errors COMPUTE_INT_PLUS_OVERFLOW
Exception CX_SY_ARITHMETIC_OVERFLOW
Short text Overflow in integer arithmetic.
Cause¶
| Type | Range |
|---|---|
TYPE I |
−2,147,483,648 to +2,147,483,647 (~2.1 billion) |
TYPE INT8 |
−9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 (~9.2 × 10¹⁸) |
Common triggers:
- Multiplying two large
TYPE Ivalues (e.g. bytes × record count for total size). - Accumulating a count or sum that grows larger than ~2.1 billion.
- Negating
TYPE Iminimum value (-2147483648 * -1overflows). - Bit-shift operations on large values.
Reproduce¶
DATA: lv_a TYPE i VALUE 2000000000,
lv_b TYPE i VALUE 2000000000,
lv_result TYPE i.
lv_result = lv_a + lv_b. " 4 billion > 2.1 billion max — dumps
Fix¶
Use INT8 as the default for counters and sizes
TYPE INT8 costs no more performance than TYPE I on 64-bit systems and eliminates this class of overflow entirely for most practical values. Use it by default for any counter or accumulator that might exceed a few hundred million.
Prevention¶
- Use
TYPE INT8instead ofTYPE Ifor counters, sizes, and accumulators. - Use
TYPE DECFLOAT34for financial totals or any value with uncertain upper bounds. - When multiplying two
TYPE Ivalues, cast at least one toINT8before the operation:DATA(lv_result) = CONV int8( lv_a ) * lv_b.
See also¶
BCD_OVERFLOW— packed decimal overflowCOMPUTE_INT_ZERODIVIDE— integer division by zero- Transaction ST22 — ABAP runtime error analysis