SAP DIVIDE ABAP Statements

Get Example source ABAP code based on a different SAP table
  


Standard SAP Help for DIVIDE

DIVIDE

Short Reference
• DIVIDE ABAP Statement
• BY DIVIDE


ABAP Syntax DIVIDE dobj1 BY dobj2.


What does it do? This statement has the same effect as the statement dobj1 = dobj1 / dobj2. The content of dobj1 is divided by the content of dobj2 and the result is assigned to dobj1. The data objects dobj1 and dobj2 have to be numeric. Predefined functions or functional methods cannot be specified. The calculation type is determined like an arithmetic expression. ABAP_PGLS Preventing Division by Zero Using Operator Format

Latest notes:Division by the value 0 is undefined and raises a handleable exception. The only situation where division by 0 does not raise an exception is if the dividend is also 0. Here, the result is set to 0.
One obsolete form of the statement DIVIDE is DIVIDE-CORRESPONDING.



Runtime Exceptions

Catchable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
Reason for error:
Overflow in arithmetic operation (type p)
Runtime error:
BCD_OVERFLOW
Reason for error:
Integer overflow in division
Runtime error:
COMPUTE_INT_DIV_OVERFLOW

CX_SY_CONVERSION_OVERFLOW
Reason for error:
Overflow in arithmetic operation (type p, with specified length)
Runtime error:
BCD_FIELD_OVERFLOW

CX_SY_ZERODIVIDE
Reason for error:
Division by 0 (type p)
Runtime error:
BCD_ZERODIVIDE
Reason for error:
Division by 0 (type f)
Runtime error:
COMPUTE_FLOAT_ZERODIVIDE
Reason for error:
Division by 0 (type i)
Runtime error:
COMPUTE_INT_ZERODIVIDE


Non-catchable Exceptions
Reason for error:
p field does not contain the correct BCD format
Runtime error:
BCD_BADDATA

Return to menu