2013 Jan 02 4:19 PM
I received this abap dump. Any suggestions on how to adjust the code?
Runtime Errors BCD_ZERODIVIDE
Exception CX_SY_ZERODIVIDE
Date and Time 01/02/2013 10:50:01
Short text
Division by 0 (type P) in program "/ITS/MM_PPV_REP"
What happened?
Error in the ABAP Application Program
The current ABAP program "/ITS/MM_PPV_REP" had to be terminated becaus
come across a statement that unfortunately cannot be executed.
* Accounting clearing in KP PPV
WHEN 'K'.
<GS_ATAB>-KPPPV = <GS_ATAB>-KPPPV +
( RSEG-MENGE * <GS_ATAB>-GR_PRI ).
ENDCASE.
* Delete entry
DELETE TABLE GT_RSEG FROM RSEG.
ENDLOOP.
* Calculate price
PERFORM CALC_PRIC USING <GS_ATAB>-IR_QTY <GS_ATAB>-IR_VAL
CHANGING <GS_ATAB>-IR_PRI.
IF <GS_ATAB>-IR_VAL = 0.
<GS_ATAB>-PPV_INV = 0.
ELSE.
<GS_ATAB>-PPV_INV = ( <GS_ATAB>-IR_PRI - <GS_ATAB>-GR_PRI )
* <GS_ATAB>-IR_QTY.
ENDIF.
* Calculate the total
<GS_ATAB>-TOTAL_PPV = <GS_ATAB>-PPV + <GS_ATAB>-PPV_INV.
* Calculate variance
CLEAR: <GS_ATAB>-VARIA, <GS_ATAB>-VARIP.
" <GS_ATAB>-VARIA = <GS_ATAB>-IR_PRI - <GS_ATAB>-STPRS. " MSP 10MAY12
" NEW Formula: Variance := Total PPV / GR Quantity
<GS_ATAB>-VARIA = <GS_ATAB>-TOTAL_PPV / <GS_ATAB>-GR_QTY. " MSP 10MAY12
* in %
IF NOT <GS_ATAB>-STPRS EQ 0.
<GS_ATAB>-VARIP = <GS_ATAB>-VARIA * 100 / <GS_ATAB>-STPRS.
ENDIF.
ENDLOOP.
2013 Jan 02 5:05 PM
The same check which you have performed here:
IF NOT <GS_ATAB>-STPRS EQ 0. <--- this check
<GS_ATAB>-VARIP = <GS_ATAB>-VARIA * 100 / <GS_ATAB>-STPRS.
ENDIF.
You should check if the field which you are using the formulas to divide should not be 0
2013 Jan 02 5:05 PM
The same check which you have performed here:
IF NOT <GS_ATAB>-STPRS EQ 0. <--- this check
<GS_ATAB>-VARIP = <GS_ATAB>-VARIA * 100 / <GS_ATAB>-STPRS.
ENDIF.
You should check if the field which you are using the formulas to divide should not be 0
2013 Jan 02 7:27 PM
2013 Jan 02 7:28 PM
It's hard to believe this could not be resolved without help from SCN. What analysis have you done before posting on SCN?
This is a catchable exception, so it should be treated in the code instead of waiting for a short dump. Like this, for example (check Help for what exception handling is available in your SAP version):
TRY.
<...>
CATCH cx_sy_arithmetic_error.
<...>
ENDTRY.
If division by zero occurs, it might also indicate that there is some error before that, e.g. a value was not calculated correctly or is missing.