‎2008 Feb 06 8:31 AM
Hi All,
Is there any FM exists to convert the any thing that contains commas like into numbers.
Regards
krishna
‎2008 Feb 06 8:48 AM
Hi,
Check these function modules.
CHAR_HEX_CONVERSION
CHAR_INT_CONVERSION
CHAR_NUMC_CONVERSION
CHAR_PACK_CONVERSION
-
This Report without FM.
report zrich_0001.
data: c(5) type c value 25.
data: n(5) type n.
data: p(8) type p decimals 2.
data: i type i.
n = c.
p = c.
i = c.
write:/ n.
write:/ p.
Write:/ i.
[/code]
-
Unless you have special characters in the value, like thousand seperator, if so you can get rid of it using the TRANSLATE keyword. Example.
codeTranslate c using ', '.
condense c no-gaps.[/code]
Regards.
‎2008 Feb 06 8:36 AM
Hi Murali,
Hope the below link helps you:
/community [original link is broken]
Reward if found helpfull,
Cheers,
Chaitanya.
‎2008 Feb 06 8:37 AM
Try this:
DATA: c_data type string value '! # $ % ^ & * ( ) + = - < > ? . / '.
v_name = 'ABC+CDF'.
translate v_name using c_data.
Now the result is 'ABC CDF'. I have used space between each speacial character. Try using numbers in your case.
‎2008 Feb 06 8:38 AM
Hi,
Declare one variable type character and pass this value to taht variable n then display it.
data : lv_var(20) type c.
lv_var = '1,23,500'
OR:
try this code..
DATA : l_amt TYPE char16.
l_amt = amount. "amount is number field
REPLACE ALL OCCURRENCES OF ',' IN l_amt WITH space.
CONDENSE l_amt.
WRITE 😕 l_amt.
OR:
replace all occurrences of ',' with space in <variable>.
condense <variable>
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.
‎2008 Feb 06 8:40 AM
Hi,
Try the function module
DATA: input(20) type c value '10000',
output type i.
CALL FUNCTION 'CONVERT_STRING_TO_INTEGER'
EXPORTING
P_STRING = input
IMPORTING
P_INT = output
EXCEPTIONS
OVERFLOW = 1
INVALID_CHARS = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write: output. output->10,000.
Edited by: prosenjit chaudhuri on Feb 6, 2008 9:43 AM
‎2008 Feb 06 8:48 AM
Hi,
Check these function modules.
CHAR_HEX_CONVERSION
CHAR_INT_CONVERSION
CHAR_NUMC_CONVERSION
CHAR_PACK_CONVERSION
-
This Report without FM.
report zrich_0001.
data: c(5) type c value 25.
data: n(5) type n.
data: p(8) type p decimals 2.
data: i type i.
n = c.
p = c.
i = c.
write:/ n.
write:/ p.
Write:/ i.
[/code]
-
Unless you have special characters in the value, like thousand seperator, if so you can get rid of it using the TRANSLATE keyword. Example.
codeTranslate c using ', '.
condense c no-gaps.[/code]
Regards.
‎2008 Feb 06 8:56 AM
Hi,
I think the following function module would suit your purpose the most.
DATA: output type i.
CALL FUNCTION 'HRCM_STRING_TO_AMOUNT_CONVERT'
EXPORTING
STRING = '10,000'
DECIMAL_SEPARATOR = '.'
THOUSANDS_SEPARATOR = ','
WAERS = ' '
IMPORTING
BETRG = output.