‎2007 Feb 15 4:07 PM
Hi,
I have a field value like this
f1 = 12.987
I must show only f1 = 12.9
How dod i do this?
‎2007 Feb 15 4:32 PM
Hi,
You can try using in the function module ROUND
Example..
DATA: v_p3 TYPE p DECIMALS 3 VALUE '12.567'.
DATA: v_p1 TYPE p DECIMALS 1.
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 1
input = v_p3
IMPORTING
output = v_p1
EXCEPTIONS
input_invalid = 1
overflow = 2
type_invalid = 3
OTHERS = 4.
WRITE: / v_p1.
THanks,
Naren
‎2007 Feb 15 4:08 PM
‎2007 Feb 15 4:08 PM
declare f1 as type p decimals 1. or else declare f2 and type p decimals 1 and move f1 to f2 and display f2.
Award points if it helps you.
Message was edited by:
Vinni
‎2007 Feb 15 4:09 PM
I can't change the definition..I have to write some other code
‎2007 Feb 15 4:12 PM
In that case you can create a local variable as below and pass its value to the original variable afterwards:
data f2 type p decimal 1.
f2 = f1.
f1 = f2.
Here F1 will have value as 12.900
Is that okay?
‎2007 Feb 15 4:19 PM
You don't have to change the definition of f1. you can declare another variable f2 and can use that.
‎2007 Feb 15 4:20 PM
hi,
u can also try this..
data f1 type string.
data: one type string.
data: two type string.
data: three type string.
f1 = '12.953'.
split f1 at '.' into one two.
three = two+0(1).
concatenate one '.' three into one.
write: one.
Regards
SAB
‎2007 Feb 15 4:25 PM
‎2007 Feb 15 4:30 PM
You don't have to when you declare your other variable v2 as type p decimals 1. you will achieve what you wanted.
‎2007 Feb 15 4:29 PM
Hi,
If you want to round use the CEIL function..
<b>Example</b>
DATA: v_p3 TYPE p DECIMALS 3 VALUE '12.987'.
DATA: v_p1 TYPE p DECIMALS 1.
v_p1 = ceil( v_p3 ).
WRITE: / v_p1.
Thanks,
Naren
‎2007 Feb 15 4:32 PM
Hi,
You can try using in the function module ROUND
Example..
DATA: v_p3 TYPE p DECIMALS 3 VALUE '12.567'.
DATA: v_p1 TYPE p DECIMALS 1.
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 1
input = v_p3
IMPORTING
output = v_p1
EXCEPTIONS
input_invalid = 1
overflow = 2
type_invalid = 3
OTHERS = 4.
WRITE: / v_p1.
THanks,
Naren