‎2010 Nov 09 12:53 PM
Hi Gurus,
I have the variable P_DATA with value 75468.275.
P_DATE is of type OIJ_ACTQTY.
I am doing an arthematic operation P_DATA = P_DATA / 10.
But the value of P_DATA is becoming 7546.828
I don't want rounding to happen.
QUESTION : How can we restrict Rounding ? I want value to be 7546.827.
Avi
‎2010 Nov 09 1:57 PM
I guess there is a more elegant Version on how to do this, but following will work.
Make yourself a local variable wit decimals 4.
Now do your calculation into the new local variable.
Slope this local variable to another new variable of type char. Then you can tranfer it back to another char variable using offset.
Now you can transfer it back to your probably type p field.
‎2010 Nov 09 1:24 PM
Hi
That means you want the result rounded off to default, so I think you need to store the result in a variable with 4 decimals and then move the rounded result in a variable with 3 decimals
Max
‎2010 Nov 09 1:38 PM
then move the rounded result in a variable with 3 decimals
Hi Max,
This will still round it.
A character variable of size 17 will be usefull
‎2010 Nov 09 1:36 PM
Its because OIJ_ACTQTY is of decimals 3 and cannot accomodate 4 decimals, so it rounds off.
data:p_data type OIJ_ACTQTY,
p_p type p decimals 4,
p_char type char17.
p_data = '75468.275'.
p_p = p_data / 10. or p_char = p_data / 10.
‎2010 Nov 09 1:41 PM
Hi...
Pass your value to HR_ROUND_NUMBER.. If you use rounding type "space" you get your number without any rounding.. 10,556=> 10,55 for example leaving '6' alone
hope to help...
‎2010 Nov 09 1:43 PM
...anyway there's also this function module ROUND
passing SIGN = space, you should gain your result..
‎2010 Nov 09 1:57 PM
I guess there is a more elegant Version on how to do this, but following will work.
Make yourself a local variable wit decimals 4.
Now do your calculation into the new local variable.
Slope this local variable to another new variable of type char. Then you can tranfer it back to another char variable using offset.
Now you can transfer it back to your probably type p field.
‎2010 Nov 09 2:27 PM
Question was asked before in forum and i gave sort of the same solution as now:
gv1 = '75468.275'.
write: / gv1.
gv1 = gv1 * 100.
gv1 = trunc( gv1 ).
gv1 = gv1 / 1000.
write: / gv1.
‎2010 Nov 09 2:37 PM
‎2010 Nov 09 3:15 PM
>
> Thanks .... multiplying and truncating did the trick.
Would expect a thanks from Avi.. but hey.. you're welcome!
‎2010 Nov 09 2:27 PM
Take a variable of type f for calculation purpose and also take a variable type p with 3 decimal places.
For example.
I have the variable P_DATA with value 75468.275.
p_var1 type f.
p_var2(15) type p decimals 3.
p_var1 = p_data / 10.
Move value of variable p_var1 to p_var2.