11-16-2005 1:14 AM
hi,
I would like to change 1500.000 -> 1500, is there any function for that in the system?
Thanks.
11-16-2005 1:23 AM
11-16-2005 1:28 AM
Ong,
You can aslo do this
WRITE: <Variable> DECIMALS 0
Cheers
Raghava
11-16-2005 1:52 AM
Hi,
If I use no decimals for it, will my result come out like this 150020 if my value is 1500.20?
11-16-2005 1:54 AM
11-16-2005 1:58 AM
Ong,
In case if you want more info on Decimals option
Option ... DECIMALS d
Effect d specifies the number of decimal places for a number field
(type I, P or F) in d. If this value is smaller than the
number of decimal places in the number, the number is rounded.
If the value is greater, the number is padded with zeros.
Since accuracy with floating point arithmetic is up to about
15 decimal places (see ABAP number types), up to 17 digits are
output with floating point numbers (type F). (In some
circumstances, 17 digits are needed to differentiate between
two neighboring floating point numbers.) If the output length
is not sufficient, as many decimal places as possible are
output. Negative DECIMALS specifications are treated as
DECIMALS 0.
Example Effect of different DECIMALS specifications:
DATA: X TYPE P DECIMALS 3 VALUE '1.267',
Y TYPE F VALUE '125.456E2'.
WRITE: /X DECIMALS 0, "output: 1
/X DECIMALS 2, "output: 1.27
/X DECIMALS 5, "output: 1.26700
/Y DECIMALS 1, "output: 1.3E+04
/Y DECIMALS 5, "output: 1.25456E+04
/Y DECIMALS 20. "output: 1.25456000000000E+04
11-16-2005 2:24 AM
I see.
How about if when the figures is 1500.00, I want to keep it as 1500 and figure is 1500.20, I want to keep it as 1500.2?
11-16-2005 2:28 AM
Ong ,
Variable1 = 1500.00
WRITE: <Variable1> DECIMALS 0.
That would give you 1500.
Variable2 = 1500.20
WRITE: <Variable2> DECIMALS 1.
That would give you 1500.2
Message was edited by: Raghava M
Message was edited by: Raghava M
11-16-2005 3:13 AM
Can you tell how many maximum decimal places you can have? Is it one or two or any number?
Srinivas
11-16-2005 3:55 AM
Ong,
I think I got your issue now. I checked for standard SAP function module, but I could not find much help .However, I have one possible solution to your issue, if you are considering only two decimal places. Complexity might increase as you increase the number of decimals.
Let us say
A = 1500. XY
If Y is a non zero .
WRITE: A DECIMALS 2.
Else.
If X is a non zero.
WRITE: A DECIMALS 1.
Else.
WRITE: A DECIMALS 0.
Endif.
Endif.
Hope it helps.
Cheers
Raghava
11-16-2005 4:12 AM
Hi Raghava,
I able to solve my problem now.
I am using code as below:
WRITE <variable1> NO-GROUPING UNIT 'ST' TO <variable2>.
So whatever figure come with 1500.00 will bcome 1500.00 and figure come with 1500.20 will maintain as 1500.20.
Thanks for your help!
11-16-2005 4:14 AM
Hi Raghava,
Sorry for making mistake for previous post.
The result will be 1500.00 will bcome 1500 and 1500.20 will maintain as 1500.20
Thanks.
11-16-2005 5:43 AM
Hi,
Refer following code. It will surely solve ur problem.
data rs type p decimals 2 value '1500.50'.
data in type i.
if u want rounded figure, uncomment the below code (exa. 1500.50 as 1501)
*in = rs.
if u do not want rounded figure (exa. 1500.50 as 1500)
in = trunc( rs ).
write in.
Regards,
Digesh Panchal
11-16-2005 5:52 AM
Hi,
According to your last post u have to Define ur variable in folloing way:
parameters rs type p decimals 2.
write rs.
Regards,
Digesh