Ansicht
Dokumentation
ABENDIVISION_ZERO_GUIDL - DIVISION ZERO GUIDL
CL_GUI_FRONTEND_SERVICES - Frontend Services BAL_S_LOG - Application Log: Log header dataThis documentation is copyright by SAP AG.
Division by Zero
Division by zero is forbidden in all recognized programming languages and raises an exception. This is also the case in ABAP, but with the difference that the exception cx_sy_zerodivide is not raised if the dividend is also zero when divided by zero. In this case, the division in ABAP produces the result 0.
Prevent division by zero
Do not exploit the fact that ABAP allows division by zero if the dividend itself is zero.
This ABAP behavior is arbitrary and does not produce the result expected by the user. Avoid using it if at all possible. Instead, set preconditions that avoid division by zero or specify explicitly that the correct exception is raised for the case 0/0.
Example
The following source code always raises an exception when the divisor has the value 0.
IF divisor <> 0.
result = dividend / divisor.
ELSE.
RAISE EXCEPTION TYPE cx_sy_zerodivide.
ENDIF.
RFUMSV00 - Advance Return for Tax on Sales/Purchases PERFORM Short Reference
This documentation is copyright by SAP AG.
Length: 1139 Date: 20240426 Time: 125628 sap01-206 ( 25 ms )