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

How to convert character into numeric

Former Member
0 Likes
1,632

Pls suggest me how to convert character value into numeric value.

Pls suggest me how to convert character value into numeric value.

5 REPLIES 5
Read only

Former Member
0 Likes
1,171

hi,

do this way ..


data : v_char(10) value '1000',
     v_numc(10) type n.

 v_numc = v_char.

write : v_char, v_numc.

Read only

Former Member
0 Likes
1,171

Hi,

You might also like to put a CATCH... ENDCATCH statement around the conversion statement in case the character field does not contain a numeric value.

Regards, Andy

Read only

Former Member
0 Likes
1,171

If you are looking for some FM then

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

reward if helpful

Read only

Former Member
0 Likes
1,171

Hi,

Use this FM

'CHAR_NUMC_CONVERSION'

Regards

Sid

Read only

0 Likes
1,171

Hi ,

Can u use write to

use somthing like write v1 to v2

George