‎2006 Aug 17 12:18 PM
Hello Everyone,
Am faced with a problem when dividing two values.
The numerator is field vbrp-cmpre, Domain: WERTV6, Value: 139.20
The denominator is field vbrp-fkimg, Domain: MENG13, Value: 5.000
Am taking the result into a variable LIKE vbrp-cmpre. The value I am getting is 0.03, which is incorrect.
I understand that this may be a conversion problem. Could someone please explain how to solve this?
Thank you very much.
Regards,
Johnson
‎2006 Aug 17 12:20 PM
See if the attribute for Fixed Point- Arithmetic is checked in your program.
se38.
Give Program name.
Choose Attributes radio-button.
Click Display.
Regards,
Ravi
‎2006 Aug 17 12:20 PM
See if the attribute for Fixed Point- Arithmetic is checked in your program.
se38.
Give Program name.
Choose Attributes radio-button.
Click Display.
Regards,
Ravi
‎2006 Aug 17 12:20 PM
Hello Johnson,
I don't think this is with the Conversion problem.
Declare variable where u r storing the result as <b>PACKED NUMBER
DATA: RESULT TYPE P DECIMALS 2.</b>
Reward if helps.
Vasanth
‎2006 Aug 17 12:27 PM
its because in the program attributes, the Check box FIXED POINT ARITHMETIC field is not selected.
because of this you are getting 0.03
if you select that and do that you will get 27.84.
Regards
Srikanth
‎2006 Aug 17 12:35 PM
HI,
I drafted a sample code as follows and executed:
data: a1 like vbrp-cmpre value '139.20',
a2 like vbrp-fkimg value '5.000'.
data: a3 like vbrp-cmpre.
a3 = a1 / a2.
write:/ a1,
/ a2,
/ a3.
I get the result:
139.20
5.000
27.84
I don't think there's any conversion problem. Pls check ur code.
Regards
Subbu
‎2006 Aug 17 1:00 PM
Hi,
Immaterial of whether the fixed point arithmetic is ON or NOT, you are bound to get a truncated value in the sum because you are target field can hold only 2 decimals. So, the denomenator will be rounded off to 2 decimals value.
First thing is you have to check 'FIXED POINT ARITHMETIC' on the attributes of the program, and then you have to choose your target field after division to refer a domain having 3 decimal places so that any truncation can be avoided.
data : l_tot type vbrp-cmpre value '139.20'.
data : l_den type vbrp-fkimg value '5.010'.
data : l_fin type vbrp-fkimg.
l_fin = l_tot / l_den.
write: l_fin.