‎2015 Jun 30 10:59 AM
Hi All,
I am a newbie of ABAP programming. I have create a new routine for condition value by VOFM.
FORM FRM_KONDI_WERT_908.
*{ INSERT
DATA: p_value(7) TYPE p DECIMALS 4.
p_value = komp-brtwr * konp-kbetr / 10000.
xkomv-kbetr = konp-kbetr / 10.
xkwert = p_value.
*} INSERT
ENDFORM.
It is very strange that if p_value = 1.2340, xkwert will equal to 123.40 but not 1.23. It seems like the number format is right-justified.
Please kindly help on this issue....I have hold on this for a few days...Thanks~~!!
‎2015 Jun 30 2:41 PM
This is because "Fixed point arithmetic" checkbox is not checked for the main program SAPLV61A.
For this reason, it is always better to declare your own function group, and function module inside it, with the required calculation and just call the function module from the routine. Don't do calculations directly inside the routine.
Thanks,
Juwin
‎2015 Jun 30 11:06 AM
hello Chan,
what kind of data type you have declared for variable xkwert ?
‎2015 Jun 30 11:13 AM
Hello Sujatha,
xkwert is type kwert (P(7) DECIMALS 2), thanks~~
‎2015 Jun 30 11:48 AM
Hi Chan,
what value you are getting at the run time in xkwert ?
as per the data declaration by you , the result of xkwert shouldbe 1.23 itself.
Regards,
Sujatha Arsid.
‎2015 Jun 30 2:27 PM
Hi,
Change declaration p_value and check
DATA: p_value(7) TYPE p DECIMALS 2.
Thanks and Regards,
Chandra
‎2015 Jun 30 2:41 PM
This is because "Fixed point arithmetic" checkbox is not checked for the main program SAPLV61A.
For this reason, it is always better to declare your own function group, and function module inside it, with the required calculation and just call the function module from the routine. Don't do calculations directly inside the routine.
Thanks,
Juwin
‎2015 Jun 30 4:02 PM
Hi Ka Wai Chan,
I second Juwin.. He is right. SAPLV61A does not hv Fixed Point Arithmetic checked. Create a FM with Fixed Point Arithmetic checked (Attribute menu)
Take a look of a example of FM with Fixed Point Arithmetic checked and unchecked.
1. Both Program and FM with Fixed Point Arithmetic UNCHECKED.
Expect output is 1.235, but 12.35 is wrongly displayed.
2. Program with Fixed Point Arithmetic UNCHECKED and FM with Fixed Point Arithmetic CHECKED (exact your scenario). Output is 1.24
More explanation at: Do all ABAPers know Fixed Point Arithmetic? | SAP Yard
Regards,
Raju
‎2015 Jul 03 6:52 AM
Dear All,
Problem fixed, it is caused by Fixed Point Arithmetic~~~~
I created a function then it works normally.
thank you very much~~~!!
God Bless,
Dan