‎2007 Feb 13 9:57 AM
i have requirement which is like:-
data: var(30) type c.
The variable var is holding the value '44.567'.
The decimal point is set default to <b>,</b> as per my id settings.
in the production it is set to<b> .</b>.
I want to remove the decimals and store 44. How can i do this independant of the user default settings.
best regards,
Subhakar.
‎2007 Feb 13 10:01 AM
Hi Subhakar,
You can use..
Write: var to var decimals 0.
Reward helpful answers.
Regards,
Siddhesh Sanghvi.
‎2007 Feb 13 10:01 AM
DATA: I TYPE I,
P TYPE P DECIMALS 2,
M TYPE F VALUE '-3.5',
D TYPE P DECIMALS 1.
P = ABS( M ). " 3,5
I = P. " 4 - business rounding
I = M. " -4
I = CEIL( P ). " 4 - next largest whole number
I = CEIL( M ). " -3
I = FLOOR( P ). " 3 - next smallest whole number
I = FLOOR( M ). " -4
TRY CEIL AND FLOOR
REGARDS
SHIBA DUTTA
‎2007 Feb 13 10:02 AM
Hi,
As the value is store in char variable then you can use split at <b>.</b>.
then it will be easy to remove the decimals.
I think this will be helpful for you.
Regards,
‎2007 Feb 13 10:02 AM
report ychatest.
data : v_dec type p decimals 2,
v_abs type i.
v_dec = '44.57'.
v_abs = trunc( v_dec ).
write : v_abs.
‎2007 Feb 13 10:05 AM
Thankyou all for your prompt reply.
Here the var is of type char. I wanna truncate the decimals of this char. Based on the user default settings the decimal may represent with , or .
‎2007 Feb 13 10:13 AM
Try this its working fine for CHAR too
DATA n(4) TYPE c.
DATA ni(4) type c.
DATA m(5) TYPE c VALUE '-5.55'.
n = ceil( m ).
ni = trunc( n ).
WRITE: / 'VALUE: ', ni.
‎2007 Feb 13 10:03 AM
Use this
numeric datatypes
DATA n TYPE p DECIMALS 2.
DATA ni type p.
DATA m TYPE p DECIMALS 2 VALUE '-5.55'.
n = ceil( m ).
ni = trunc( n ).
WRITE: / 'VALUE: ', ni.<b>Output:
VALUE: 5- </b>
Then use <b>trunc( n )</b>
Message was edited by:
Judith Jessie Selvi
‎2007 Feb 13 10:04 AM
report ychatest.
data : v_dec type p decimals 2,
v_abs type i.
v_dec = '44.57'.
v_abs = trunc( v_dec ).
write : v_abs.
‎2007 Feb 13 10:04 AM
Hi,
If you can transfer the value to a type P variable. you can use the FLOOR command.
if you want to have only in Char, then You can write a select single query on USR01 to fetch the value of DCPFM which will tell you whether the decimal separator is '.' or ',' and use SPLIT statement to get the desired value.
regards,
Mahesh
‎2007 Feb 13 10:16 AM
‎2007 Feb 13 10:16 AM
Subhakar,
The quick solution for the same is to move the var field to a floting variable first. and then compute using arithmatic expression depending on the requirement.
See the below sample code:
DATA: char_c(30), int_i type i, p_p type p decimals 3, i type i.
char_c = '44.567'.
MOVE char_c to p_p.
int_i = ceil( p_p ). "To get the Upper value i.e 45 in this case
i = FLOOR( p_p ). "To get the Lower value i.e. 44 in this case
WRITE: / int_i, i.
Hope this helps.
Thanks
‎2007 Feb 13 10:21 AM
Hi rahul,
Tried but stilll its raising runtime error while assigning char variable to variable of type p. Pls help
‎2007 Feb 13 10:27 AM
Hi,
As the var is character type you need to use split.
the code is as follows:
data: var(30) type c value '44.567'.
data: var1(30),var2(30) type c.
split var at '.' into var1 var2 .
write 😕 var1.
i think this will helpful for you.
‎2007 Feb 13 10:28 AM
Hi Subha,
The same code is working for me.... I hope you are using the same code as posted above....
Thanks