‎2008 Aug 29 10:03 AM
how to convert a char field of an internal table into a numeric field?
‎2008 Aug 29 10:05 AM
Hi,
you can directly assign datatype c to n.
data:
w_result type n,
loop at itab into wa.
(wa-field) = w_result.
endloop.
Regards,
Anirban
‎2008 Aug 29 10:05 AM
Hi,
you can directly assign datatype c to n.
data:
w_result type n,
loop at itab into wa.
(wa-field) = w_result.
endloop.
Regards,
Anirban
‎2008 Aug 29 10:07 AM
hii
assign char type value in to variable of type n.
data:
w_txt(5) type c,
w_num(5) type n,
w_txt = 'gh12'.
w_num = w_txt.
regards
twinkal
‎2008 Aug 29 10:08 AM
You can move character field to numeric field. SAP will do implicit conversion to numeric. Please make sure you handle exceptions.
‎2008 Aug 29 10:08 AM
Hi try this,
data : var1(10) type n,
var2(10) type c value '256748'.
move var2 to var1.
write : / var1,
/ var2.
‎2008 Aug 29 10:09 AM
Use below FMs
CHAR_NUMC_CONVERSION
MOVE_CHAR_TO_NUM
C14W_CHAR_NUMBER_CONVERSION
CHAR_NUMC_CONVERSION
See the 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.Also hv a look on below thread..
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
‎2008 Sep 10 8:27 AM
Hi...
I am also facing the same issue. If You have solved this problem. I am able to convert the char into numc. but if user enters SPACE then it shuold not be valid.
How to solve that.
Regards,
Rohit
‎2008 Sep 10 8:35 AM
Rohit,
Its a answered post.
nobody will notice your prob
you post your prob in seperate post.
Regards,
Anirban