‎2008 Feb 06 7:24 AM
hi experts
i have a number like xx.xx or x.xx or xxx.xx how do i get rid of the dot and the digits that after the dot
thanks
amit
Edited by: amit walden on Feb 6, 2008 8:29 AM
‎2008 Feb 06 7:28 AM
‎2008 Feb 06 7:28 AM
‎2008 Feb 06 7:30 AM
Hi,
DATA:X_NUM(10) TYPE C VALUE '123.23'.
REPLACE ALL OCCURRENCES OF '.' IN X_NUM WITH ''.
WRITE:X_NUM.
‎2008 Feb 06 7:31 AM
Hi,
Use this stmt.
Replace all occurences of '.' with ' '.
i hope it may work,
regards,
ravi shankar reddy
‎2008 Feb 06 9:06 AM
Don't use character operations. There's no need.
As you present the query, it seems you have a decimal number and you want it to become an integer. You don't say how the decimal number is stored - it could be string, character, floating point or packed decimal. In any case, use the inbuilt function "trunc". Here's a sample program to show how it works.
DATA: my_pd TYPE p LENGTH 8 DECIMALS 2,
my_fp TYPE f,
my_char TYPE c LENGTH 8,
my_str TYPE string.
my_pd = '12.34'.
my_fp = '12.34567'.
my_char = '12.34567'.
my_str = `12.34567`.
PERFORM to_int USING: 'PD' my_pd,
'FP' my_fp,
'CHAR' my_char,
'STR' my_str.
FORM to_int USING desc TYPE clike
valu TYPE any.
DATA: my_int TYPE i.
my_int = TRUNC( valu ).
WRITE: / desc, valu, my_int.
ENDFORM. "to_int
Regards
matt
Edited by: Matthew Billingham on Feb 6, 2008 10:09 AM
‎2008 Feb 06 9:44 AM
Hi,
Please refer to the below code:
data : num1 type p decimals 2 value '10.20'.
data : num2 type i.
num2 = num1.
write : num2.
Thanks,
Sriram Ponna.