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

Function Module move_char_to_num

Former Member
0 Likes
1,162

This is part of a program to trace changes done to Credit Limit. Value_new and Value_old fields are characters. I want to convert this to numeric. The following code is not working. Without the function module it is working fine. Kindly help.

  • Select Change document items

SELECT OBJECTCLAS

OBJECTID

CHANGENR

TABNAME

TABKEY

FNAME

CHNGIND

TEXT_CASE

UNIT_OLD

UNIT_NEW

CUKY_OLD

CUKY_NEW

VALUE_NEW

VALUE_OLD

FROM CDPOS INTO CORRESPONDING FIELDS OF TABLE T_CDPOS

FOR ALL ENTRIES IN T_CDHDR

WHERE OBJECTCLAS = T_CDHDR-OBJECTCLAS

AND OBJECTID = T_CDHDR-OBJECTID

AND CHANGENR = T_CDHDR-CHANGENR

AND FNAME IN S_FNAME AND

FNAME = 'KLIMG' OR

FNAME = 'KLIME' OR

FNAME = 'KLIMK' OR

FNAME = 'DBEKR'.

IF NOT T_CDPOS IS INITIAL.

LOOP AT T_CDPOS INTO WA_CDPOS.

CALL FUNCTION 'MOVE_CHAR_TO_NUM'

EXPORTING

CHR = WA_CDPOS-VALUE_NEW

IMPORTING

NUM = WA_CDPOS-VALNEW

EXCEPTIONS

CONVT_NO_NUMBER = 1

CONVT_OVERFLOW = 2

OTHERS = 3.

IF SY-SUBRC = 0.

MODIFY T_CDPOS FROM WA_CDPOS.

CLEAR WA_CDPOS.

ENDIF.

ENDLOOP.

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
662

Hi,

Please check the type of the export parameter WA_CDPOS-VALNEW also what is the problrm you are getting.

Regards,

Himanshu Verma

Read only

JozsefSzikszai
Active Contributor
0 Likes
662

hi,

Are you sure that WA_CDPOS-VALUE_NEW contains only numbers? pls. add the following line before the FM call:

CHECK WA_CDPOS-VALUE_NEW CO '0123456789'.

On the other hand the type of WA_CDPOS-VALNEW has to be P.

hope this helps

ec