‎2007 Jul 05 4:16 PM
Hi everyone,
i have a very very strange error/exception trying to divide 2 Numbers:
The source code looks like this:
lv_alt_koeff = ABS( lv_alt_wrbtr_delta / ( lv_alt_wrbtr_h - lv_alt_wrbtr_s ) ).
Values are:
lv_alt_wrbtr_delta = 119201.40
lv_alt_wrbtr_h = 0.00
lv_alt_wrbtr_s = 4124.05
Can you please explain me what i'm doing wrong and how to get off this error.
Thank you very much in advance.
Andrey
‎2007 Jul 05 4:19 PM
lv_alt_wrbtr_delta, lv_alt_wrbtr_h, lv_alt_wrbtr_s are TYPE p DECIMALS 2
lv_alt_koeff is TYPE p DECIMALS 14
Andrey
‎2007 Jul 05 4:35 PM
Try changing:
lv_alt_koeff is TYPE p DECIMALS 14
to:
lv_alt_koeff is TYPE p DECIMALS 4.
Rob
‎2007 Jul 05 4:44 PM
Hello,
sorry, i can't, cause i need as much decimal places as possible (14).
Or else i get very big round errors in my later calculations.
The booking amount of an FI Document is multiplied by the result of this division...
ThankYou
Andrey
‎2007 Jul 05 4:57 PM
Well, this is your problem - either declare it with fewer decimal places or as float.
I take it back - you can also declare it:
lv_alt_koeff(16) TYPE p DECIMALS 14.
Rob
Message was edited by:
Rob Burbank
‎2007 Jul 05 4:23 PM
Hi Andrey,
I think the problem is not with the calculation.
Try leaving some spaces after the command and the brackets used.
The compiler might not be recognising it as a command.
try leaving a space between the variables used and the brackets.
Reward points if that solves ur problem
Kiran
‎2007 Jul 05 4:23 PM
Check the data declaration of the variable which holds this value. If the resultant value is too large then the ABAP throws this exception.
You may handle this using CATCH ENDCATCH statement.
Check this e.g.:
PARAMETERS fact TYPE i.
DATA: fact_save TYPE i,
res(16) TYPE p.
ARITHMETIC_ERRORS contains COMPUTE_BCD_OVERFLOW ***
CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 5.
res = fact_save = fact.
SUBTRACT 1 FROM fact.
DO fact TIMES.
MULTIPLY res BY fact. "<- COMPUTE_BCD_OVERFLOW
SUBTRACT 1 FROM fact.
ENDDO.
ENDCATCH.
IF sy-subrc = 5.
WRITE: / 'Overflow! Factorial of', fact_save,
'can not be calculated.'.
ELSE.
WRITE: / 'Factorial of', fact_save, 'gives', res.
ENDIF.
Thanks,
SKJ
‎2007 Jul 05 4:33 PM
Hello,
thank you for the quick answer!
How big the result can be to not to throw the exception. Cause i always need the result of the division to calculate other values.
The programm was already run for n times without any.
Only in this special case it throws the exception. And the results of other calculations had not always has less then 14 decimal places.
And Kiran, no, the problem is not with the formatting of the code, cause as i've written befor the programm already run for many times....
Thank you
Andrey
‎2007 Jul 05 4:32 PM
Hi,
May be this useful.
v_val = lv_alt_wrbtr_h - lv_alt_wrbtr_s
if v_val gt 0.
lv_alt_koeff = ABS( lv_alt_wrbtr_delta / ( lv_alt_wrbtr_h - lv_alt_wrbtr_s ) ).
endif.
aRs
‎2007 Jul 05 4:34 PM
Hi,
it's not the problem. In this case it would be 'DIVISION_BY_ZERO' exception...
Thank you anyway
Andrey