‎2010 Mar 06 9:04 AM
Hi,
I am facing a problem when i am executing the report for a purticular materail type,it is giving the below mentioned error and when i execute it for a some materails it is displaying the output.
Is there any way to remove it....
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_ZERODIVIDE', was not caught and therefore caused a runtime error.
The reason for the exception is:
In the current program "ZNEW04", an arithmetic operation ('DIVIDE', '/', 'DIV' or 'MOD') with a type P operand attempted to divide
by 0.
IF W_TAB1-MEINS = 'G'.
W_FINAL-TOTWT = W_TAB1-LBKUM / 1000000.
ELSEIF W_TAB1-MEINS = 'KG'.
W_FINAL-TOTWT = W_TAB1-LBKUM / 1000.
ELSEIF W_TAB1-MEINS <> 'TO'.
W_FINAL-TOTWT = W_TAB1-LBKUM * W_TAB1-WTKG / 1000.
ENDIF.
W_FINAL-TOTWT1 = W_FINAL-SALK3 / W_FINAL-LBKUM.
--> (Error occur here) W_FINAL-TOTWT2 = W_FINAL-SALK3 / W_FINAL-TOTWT.
‎2010 Mar 06 9:13 AM
Hi
As a general Rule whenever you devide you need check that you are not deviding it by zero
5 / 0 is inifinity but in SAP it give run time error Hope this is clear to you.
so before deviding you need to chek it
if not W_FINAL-LBKUM = 0. " or '0.00' if packed decimal
W_FINAL-TOTWT1 = W_FINAL-SALK3 / W_FINAL-LBKUM.
endif.
if not W_FINAL-TOTWT = 0. " or '0.00' If packed decimal
W_FINAL-TOTWT2 = W_FINAL-SALK3 / W_FINAL-TOTWT.
endif.Cheerz
Ram
‎2010 Mar 06 9:13 AM
Hi
As a general Rule whenever you devide you need check that you are not deviding it by zero
5 / 0 is inifinity but in SAP it give run time error Hope this is clear to you.
so before deviding you need to chek it
if not W_FINAL-LBKUM = 0. " or '0.00' if packed decimal
W_FINAL-TOTWT1 = W_FINAL-SALK3 / W_FINAL-LBKUM.
endif.
if not W_FINAL-TOTWT = 0. " or '0.00' If packed decimal
W_FINAL-TOTWT2 = W_FINAL-SALK3 / W_FINAL-TOTWT.
endif.Cheerz
Ram
‎2010 Mar 06 9:16 AM
Hi,
This is a Simple Arithmatic Error Divide By Zero .
Here due to some reason a field W_FINAL-TOTWT contain 0 value.
Mean W_FINAL-TOTWT EQ 0.
So debug your code and make a validation that if W_FINAL-TOTWT GT 0 only then devision occurs.
This way dump will not occur,
Thanks.