‎2008 Jul 23 9:20 AM
Hi abapers,
I'm confused on what has been doing wrong in my codes.
The situation is i have variables
v1 type p decimals 2.
v2 type p decimals 2.
i passed the value from ekpo-menge to v1 and same with v2.
i have a variable of v3 with type p decimals 2.
for example v1 = 6, v2 = 3.
when i tried to divide v1 / v2. i get a quotient of 0.01. I expected to get answer of 2 but i get 0.01.
Why is that? I'm working in an enhancement of ME22N.
‎2008 Jul 23 9:33 AM
Hi James Evert Lising,
in EKPO table...
Details of MENGE field...
MENGE QUAN 13 3 Purchase Order Quantity
Here MENGE is having 3 decimal places...
Try to declare all related variables as
VAR1 type P decimals 3.
Also check the values of variable V1 and V2 in debugging mode... Modify the lengh of a variable accordingly...
while creating ur report u should check the check box of Fixed point arithmatic in attributes... Just check it out from Program attributes... GoTo --> Attributes...
Also have a look on below code it's giving proper result...
REPORT ZILESH_TEMP2.
DATA : TAB_V1 TYPE EKPO-MENGE VALUE '6.000', " OR TAB_V1 TYPE EKPO-MENGE VALUE 6.
TAB_V2 TYPE EKPO-MENGE VALUE '3.000', " OR TAB_V2 TYPE EKPO-MENGE VALUE 3.
TAB_V3 TYPE EKPO-MENGE.
DATA : V1 TYPE P DECIMALS 2,
V2 TYPE P DECIMALS 2,
V3 TYPE P DECIMALS 2.
V1 = TAB_V1.
V2 = TAB_V2.
V3 = V1 / V2.
TAB_V3 = V3.
WRITE : / V3.
WRITE : / TAB_V3.Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
‎2008 Jul 23 9:35 AM
hi check this...
data:v1 type p decimals 2,
v2 type p decimals 2,
v3 type p decimals 2,
v_test type ekpo-menge value '6',
v_test1 type ekpo-menge value '3'.
v1 = v_test .
v2 = v_test1.
v3 = v1 / v2 .
write:/ v3 .
‎2008 Jul 23 9:38 AM
hiii
open your program..from menu->attributes->there will be a checkbox called fixed point arithmatic..click that one.
you will get your answer.
regards
twinkal
‎2008 Jul 23 9:39 AM
hi James,
Please execute the below code to find the output as you require ...
DATA :v1 TYPE p DECIMALS 2 VALUE '6',
v2 TYPE p DECIMALS 2 VALUE '3',
v3 TYPE p DECIMALS 2.
v3 = ( v1 / v2 ).
WRITE : v3.
‎2008 Jul 23 9:40 AM
Hi James,
Check whether the Fixed Point Arithmetic is cheked in your attributes screen. It will give different value if you do not check this attribute.
And also I think that the decimal places you have taken is less. So probably the value is getting Rounded Up. Just Check it.
Regards,
Swapna.
‎2008 Jul 23 9:41 AM
take the result into a variable of type p decimals 2 ..
data : v1 type p decimals 2 value '6',
v2 type p decimals 2 value '3'.
data : v3 type p decimals 2.
v3 = v1 / v2 .
‎2008 Jul 23 10:29 AM
Hi all,
Thanks for the info. But sad to say i'm still getting the same error.
I'm currently adding an enhancement in a SAP Standard program and unfortunately the Fixed Point Arithmetic is not being ticked.
Can anyone has an idea on how to do it?
Thanks!
‎2008 Jul 23 10:50 AM
Since fixed point arithmetic is not ticked try this it may work
v3 = v1 / v2 * '1.00'.
if v3 is type p decimals 2.
‎2008 Aug 07 9:03 AM
Hi James,
You have to manage your computation by the appropriate power of ten...
In this scenarion try this exampe:
v3 = (v1 * 100) / (v2 * 100).
It should work.
‎2008 Sep 05 11:01 PM
What I did to get around this is to create a dummy program and have Fixed Point Arithmetic checkbox checked. Put a routine in there. Then in your user exit call this routine in this dummy program.
That way even though the main program of your user exit does not have this Fixed Point Arithmetic checked the calculation will be based on your dummy program's attribute.