‎2009 Jul 24 1:32 PM
hi all,
please look at the below eg:
data : text1 type p decimals 2.
data : text2 type p decimals 2.
data : text3 type p decimals 2.
text1 = '328.70'.
text2 = '0.02'
text3 = text1 * text2.
after multiplication the value is 657.40. but the actual value should be 6.57 what the reason for this errored value 657.40 have is missed some thing over here??? please help
Regards,
Jayakumar.R
‎2009 Jul 24 1:36 PM
Hi,
Ensure that in programs Atributes you have checked Fixed point arithmetic .
Regards
Marcin
‎2009 Jul 24 1:38 PM
hi,
check program attributes:
<fixed point arithmetic> should be marked...
regards,darek
‎2009 Jul 24 1:39 PM
Its correct, I just copied ur code and pasted as below:
data : text1 type p decimals 2.
data : text2 type p decimals 2.
data : text3 type p decimals 2.
text1 = '328.70'.
text2 = '0.02'.
text3 = text1 * text2.
write : text1,text2,text3.
Its giving me 328.70 0.02 6.57
Fixed point aithmetic should be selected in atribute.
‎2009 Jul 24 1:42 PM
Hi Jay,
The problem is that your decimal point is being recognized as a thousand separator. Replace '.' with a comma ',', and your calculation should work fine.
Try this:
data : text1 type p decimals 2.
data : text2 type p decimals 2.
data : text3 type p decimals 2.
text1 = '328,70'.
text2 = '0,02'.
text3 = text1 * text2.
You should get it right now. If you want to change your settings, goto SAP Easy Access -> Settings -> Own Data
Hope this helps! Do let me know if you need anything else!!
Cheers,
Shailesh.
Always provide feedback for helpful answers!
‎2009 Jul 24 1:45 PM
Hi,
Try this.
data : text1 type p decimals 2 VALUE '328.70'.
data : text2 type p decimals 2 VALUE '0.02'.
data : text3 type p decimals 2.
text3 = text1 * text2.
WRITE text3.Thanks,
Sri.
‎2009 Jul 24 1:45 PM
jaya,
your code is correct and fetching correct value.
check if you have written some thing else in the code.
‎2009 Jul 24 1:49 PM
hi,
actually the value are picked from database field kwert,
for example i just entered the values in quotes.
regards,
R.Jayakumar
‎2009 Jul 24 2:10 PM
>
> hi,
>
> actually the value are picked from database field kwert,
> for example i just entered the values in quotes.
>
> regards,
> R.Jayakumar
This is not important as KWERT is of type DEC so the one which you used in your example.
Did you check the setting together with Darek we suggested you?
When it is set, SAP does calculation same way as you would do multiplication on sheet of paper, so decimal point is taken under considertation (4 places shifted to left after applied to result).
On the other hand, when you have that option off, it will leave that point at 2nd place shifted to left, hence you get 657.40 instead of 6.57.
Regards
Marcin
‎2009 Jul 24 2:17 PM
hi,
i have checked the same expression in report it works fine. But, in pricing routine it returns wrong value. plz help
Regards,
R.Jayakumar
‎2009 Jul 24 2:23 PM
hi
try to do your calculation in external program with fixed point arithemtic checked...
darek
‎2009 Jul 24 2:23 PM
Look at SAP documentation [Numeric Data Types |http://help.sap.com/abapdocu_70/en/ABENNUMBER_TYPES.htm]
If you are using packed numbers, you should always set the program attribute fixed point arithmetic as only this ensures that the decimal point is correctly calculated. Otherwise, all numbers are specified as integers and all intermediate results for the next integer are rounded. If fixed point arithmetic is not set, the decimal places defined for the number only appear in screen output or when formatting with WRITE [TO].
Regards,
Raymond
‎2009 Jul 24 2:28 PM
Hi,
Please Check that in your programs atributes you have checked Fixed point arithmetic .
Thanks & Regards,
Shreemohan