‎2008 May 28 9:41 AM
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.
‎2008 May 28 9:46 AM
Hi,
Please check the type of the export parameter WA_CDPOS-VALNEW also what is the problrm you are getting.Regards,
Himanshu Verma
‎2008 May 28 9:48 AM
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