Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

conversion into numbers

Former Member
0 Likes
906

Hi All,

Is there any FM exists to convert the any thing that contains commas like into numbers.

Regards

krishna

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
859

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.

6 REPLIES 6
Read only

Former Member
0 Likes
859

Hi Murali,

Hope the below link helps you:

/community [original link is broken]

Reward if found helpfull,

Cheers,

Chaitanya.

Read only

Former Member
0 Likes
859

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.

Read only

Former Member
0 Likes
859

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.

Read only

Former Member
0 Likes
859

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

Read only

Former Member
0 Likes
860

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.

Read only

Former Member
0 Likes
859

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.