2010 Apr 07 1:51 PM
hi
I am having a problem while trying to divide a variable with another.
There is an amount field (konv-kbetr) which is a currency type field (length 11 dec 2).
And then there is field for storing exchange rate (like vbkd-kursk) which is decimal type field (lenght 9 dec 5).
When I am trying the divide field1 by field2 then result is coming as zero.
Any idea why it might happen.
Thanx in advance
2010 Apr 07 1:56 PM
what is data type of result variable?can you tell what values are you getting in both variables?Also,go to program attributes and check if "FIxed point Arithmetic" is checked or not..if not check the check box
2010 Apr 07 2:02 PM
data: w_kursk like vbkd-kursk. " This is a decimal type field
Data w_rate like konv-kbetr. " This is a currency type field
Now I am getting the some value in w_rate from some data source.
After that I am getting exchange rate from vbkd into w_kursk var.
Now I want to divide the w_rate variable by w_kursk and store the value into the same variable i.e. w_rate.
Sample code is given below.
select single kursk
into w_kursk
from vbkd
where vbeln = komp-aubel.
if sy-subrc = 0.
w_rate = w_rate / w_kursk.
endif.
2010 Apr 07 2:05 PM
what is data type of w_rate?Is fixed point arithmetic checked in program attributes?
2010 Apr 07 2:24 PM
The variable w_rate is currency type field.
It was declared as w_rate like konv-kbetr.
The prg which i am using is ALT Condition type routine
(Created from VOFM->formulas->condition value).
Here in the prg attribute section fixed point arithmetic box not appearing.
2010 Apr 07 2:27 PM
in such cases its better that u create a function and carryout computations inside it.The main program of function group will have fixed point arithmetic checked and these problems will not occur there.
2010 Apr 07 2:29 PM
Like Mr. Abapuser told you, you can now:
1. Change your program to fixed point arithmetic. Tho i wouldnt propose that since you do not know what other calculation operation are done in that program and how they will suffer.
2. make yourself a own function module for which you can switch on fixed point arithmetic, and do your calculation in there.
2010 Apr 07 2:50 PM
Thanx for your valuable suggestion.
It was nicely done...................
2010 Apr 07 2:05 PM
well, your destination variable has just two decimals i guess.
So once your value is under 0,0050 which would be rounded to 0,01 you get 0.
Check fixed point arithmetik, you have some decimals problem here giving you values of 0,0006 and such.
2010 Apr 07 2:22 PM
In the attributes of the program, make sure that fixed point arithmetic is checked.
Rob