‎2008 Jan 10 2:03 PM
HI,
I am facing one problem while conversion.
At run time I am getting one field name is vbdkr-ntgew and the value of this field is 1143.541
I want to convert the above value into rounded value with out decimals in all user settings format.
I mean if it is 1143.541 then it should be 1144
If it is 1143.078 then it should be 1143.
For the above case I am using the logic
gv_a = CEIL( vbdpr-ntgew ).
In above the gv_a variable is of type I ( I have used type n and c also).
But this is not working I mean after the above statement the gv_a is showing 1143541 instead of 1144.
And one more thing this is almost similar to above
I have a variable vbdpr-fkimg and the value of this field is 1.000
Now I need to convert next rounded value with one decimal.
I mean to 1.0
For this I am using following logic.
Gv_b = ceil ( vbdpr-fkimg).
In above gv_b is of type p decimal 1.
Now after execution of above statement the gv_b is populating with 100.0 but I am expecting 1.0
Suppose the value is 1143.789 then I want 1144.0
Please tell me the logic with out using SPLIT command
If helpful I will give the points.
Thanks a lot in advance.
‎2008 Jan 10 2:07 PM
Use this:
data: tt type f value '1143.541'.
data: gv_a(16) type n.
gv_a = tt.
write: / gv_a.
‎2008 Jan 10 2:09 PM
or to match the CURR data type:
data: tt type vbdkr-netwr value '1143.541'.
data: gv_a(16) type n.
gv_a = tt.
write: / gv_a.
‎2008 Jan 10 2:14 PM
Hi,
I tried this but it is not working. I mean if the value is 1143.790 it is coming 1143790.
Thanks.
‎2008 Jan 10 2:16 PM
Hey use ABS instead of ceil.... I am not sure but try out. hope it will work.
‎2008 Jan 10 2:18 PM
Not possible...
Please provide the code that returned 1143.xxx instead of 1144 into the type N field.
‎2008 Jan 10 2:21 PM
Hi,
DATA: gv_ntgew(16) TYPE n .
gv_ntgew = vbdpr-ntgew .
the vbdpr-ntgew contains value 1143.501
after execution of above line gv_ntgew contains 1143501
but i want 1144
Thanks for your help.
‎2008 Jan 10 2:25 PM
Hmmm...
This code:
DATA: gv_ntgew(16) TYPE n .
data: ll type vbdpr-ntgew value '1143.88'.
gv_ntgew = ll .
write: / gv_ntgew.
prints out 1144 in my ECC 6.0 system.
What version / system are you running in?
And what if you just paste my code into a new program with JUST THESE lines and a REPORT header statement - and execute?
‎2008 Jan 10 2:27 PM
DATA: gv_ntgew TYPE i .
gv_ntgew = ABS( vbdpr-ntgew ) .
t_ans = ABS( t_exam ).
write : t_ans.
Check with this..... Hope this is what you want....If possible get the value with type Int.
‎2008 Jan 10 2:07 PM
Hi
If you need to have an integer value, use an integer variable:
DATA: NETGEW_I TYPE I.
MOVE VBDPR-NETGEW TO NETGEW_I.
You can use a p variable with 1 decimal if you need to convert a number with 3 decimal to one with only one decimal:
DATA: FKIMG_1 TYPE P DECIMALS 1.
MOVE VBDRP-FKIMG TO FKIMG_1.
The values'll be rounded automatically.
Edited by: max bianchi on Jan 10, 2008 3:08 PM
‎2008 Jan 10 2:07 PM
try:
PARAMETERS: p3 TYPE p DECIMALS 3 DEFAULT '1143.541'.
DATA p0 TYPE p DECIMALS 0.
MOVE p3 TO p0.
WRITE: / p3, p0.
A.
‎2008 Jan 10 2:07 PM
Hi
If you need to have an integer value, use an integer variable:
DATA: NETGEW_I TYPE I.
MOVE VBDPR-NETGEW TO NETGEW_I
The value'll be rounded automatically.
‎2008 Jan 10 2:23 PM
Hi Ramesh,
You can use the function module MURC_ROUND_FLOAT_TO_PACKED to round off the values.
Or else you can try the following code:
DATA: num1 TYPE f value '19.468323', num2 TYPE p decimals 2.
num1 = '19.468323 '.
num2 = num1.
WRITE num2.
Reward if usefull.
Thanks,
Kashyap Ivaturi