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

Strange error: COMPUTE_BCD_OVERFLOW

0 Likes
1,554

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

9 REPLIES 9
Read only

0 Likes
1,457

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

Read only

0 Likes
1,457

Try changing:

lv_alt_koeff is TYPE p DECIMALS 14

to:

lv_alt_koeff is TYPE p DECIMALS 4.

Rob

Read only

0 Likes
1,457

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

Read only

0 Likes
1,457

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

Read only

Former Member
0 Likes
1,457

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

Read only

Former Member
0 Likes
1,457

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

Read only

0 Likes
1,457

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

Read only

former_member194669
Active Contributor
0 Likes
1,457

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

Read only

0 Likes
1,457

Hi,

it's not the problem. In this case it would be 'DIVISION_BY_ZERO' exception...

Thank you anyway

Andrey