Application Development 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: 

Urgent plz:Function module to convert char to numeric

Former Member
0 Kudos

Hi do any one know what is the FM to convert Char to numeric type

5 REPLIES 5

Former Member
0 Kudos

Check the function module.

use this for checking ..

1.

CALL FUNCTION 'NUMERIC_CHECK'

EXPORTING

STRING_IN = X

IMPORTING

STRING_OUT = X

HTYPE = H_TYPE.

if h_type = 'CHAR'.

WRITE:/ 'Not Numeric'.

else.

write:/ 'Numeric'.

ENDIF.

2.

use this fm for the conversion

CHAR_NUMC_CONVERSION

Reward if useful.

Former Member
0 Kudos

Hi,

Use FM

MOVE_CHAR_TO_NUM

Former Member
0 Kudos

Hi,

FM for converting char to numc : CHAR_NUMC_CONVERSION

Also try:

CALL FUNCTION 'CHAR_NUMC_CONVERSION'

EXPORTING

INPUT = 0

IMPORTING

NUMCSTR =

.

or use

Sample code below:

codeDATA: lv_chr(4) type c,

lv_num type p.

CALL FUNCTION 'MOVE_CHAR_TO_NUM'

EXPORTING

CHR = lv_chr

IMPORTING

NUM = lv_num

EXCEPTIONS

CONVT_NO_NUMBER = 1

CONVT_OVERFLOW = 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.[/code]

or USE

CONVERT_STRING_TO_INTEGER

or USE THESE FMs

MOVE_CHAR_TO_NUM

C14W_CHAR_NUMBER_CONVERSION

CHAR_NUMC_CONVERSION

Reward Points if found helpfull..

Cheers,

Chandra Sekhar.

dhruv_shah3
Active Contributor
0 Kudos

Hi..

USE

CALL FUNCTION 'CHAR_NUMC_CONVERSION'

EXPORTING

INPUT = 0

IMPORTING

NUMCSTR =

.

or use

Sample code below:

codeDATA: lv_chr(4) type c,

lv_num type p.

CALL FUNCTION 'MOVE_CHAR_TO_NUM'

EXPORTING

CHR = lv_chr

IMPORTING

NUM = lv_num

EXCEPTIONS

CONVT_NO_NUMBER = 1

CONVT_OVERFLOW = 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.[/code]

or USE

CONVERT_STRING_TO_INTEGER

or USE THESE FMs

MOVE_CHAR_TO_NUM

C14W_CHAR_NUMBER_CONVERSION

CHAR_NUMC_CONVERSION

HTH,

Regards,

Dhruv Shah

Former Member
0 Kudos

use these two function moduless

HRCM_AMOUNT_TO_STRING_CONVERT – Converts an amount to a character string

Do reward if helpful