2007 Mar 07 10:32 AM
Hi all,
I want any given number to be formatted to 3 decimal places.
For example:
1.3 => 1.300
2.35 => 2.350
that's simple, but I want whole numbers to be converted like:
12 => 0.012
56324 => 56.324
How can I achieve this?
Greetings Fred.
2007 Mar 07 10:41 AM
data : num type p decimals 3.
data : text(13).
<take the variable value in num>
text = num.
if text cp '*.000'."check whether it is a whole no or decimal if whole no then
"only devide
num = num / 1000.
endif.
regards
shiba dutta
2007 Mar 07 10:35 AM
Use the function <b>Round</b>
<b>write w_value round 3.</b>
U will get the required output.
regards,
sai ramesh
2007 Mar 07 10:36 AM
divide them by 1000
data : v_num type p decimals 3 value '12'.
v_num = v_num / 1000.
2007 Mar 07 10:41 AM
data : num type p decimals 3.
data : text(13).
<take the variable value in num>
text = num.
if text cp '*.000'."check whether it is a whole no or decimal if whole no then
"only devide
num = num / 1000.
endif.
regards
shiba dutta
2007 Mar 07 10:42 AM
HI Fred,
do this way ..
DATA : V_P(10) TYPE P DECIMALS 3.
V_P = 12 / 1000.
*V_P = V_P * '0.001'.
WRITE V_P.
regards,
santosh
Message was edited by:
Santosh Kumar Patha
2007 Mar 07 10:48 AM
dear why u try to do this?
any way try with this
DATA : NUM1 TYPE P DECIMALS 3.
DATA : NUM2 TYPE P DECIMALS 3.
NUM1 = 12.
NUM2=56324.
NUM1 = NUM1/1000.
NUM2=NUM1/1000.
2007 Mar 07 10:58 AM
Hi all,
thanx for the answers. I have not checked all of them, but I think the answer with the check if there is already a decimal can help me.
To all who simply divide the given number do not take into account that I want a number like 1.5 just as 1.500 and not 0.0015.
Greetings Fred.
2007 Mar 07 11:06 AM
then easy
DATA : NUM1 TYPE I
DATA : NUM2 TYPE P DECIMALS 3.
NUM1 = 12.14.
NUM2 = NUM1.
SO NUM SHOULD BE 12.140.
REWARDS IF HELPFUL.
2007 Mar 07 11:12 AM
Hi Try it in this way
DATA : NUM1 TYPE P DECIMALS 3.
NUM1 = NUM1 / 1000.
WRITE:/ NUM1.
You will get the desired value
Reward point if helpfull---------
2007 Mar 07 11:17 AM
i think for some reason you did not check my answer because i have already check the whole no and decimal.
pls check that if it does not work let me know.
regards
shiba dutta
2007 Mar 07 11:28 AM
Hi Shiba Dutta,
It was your post with the check for decimal places I mentioned before .
It works great thank you!
Points are rewarded.