Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Short Dump... Help?

Former Member
0 Likes
877

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
803

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

3 REPLIES 3
Read only

Former Member
0 Likes
804

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

Read only

Former Member
0 Likes
803

Please search forums before posting.

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
803

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.