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: 

How can I check the field char can be translate into num type?

0 Kudos

Hi

when I import Excel file into sap . I create one table to save the column and there are one column who's tpye is num . as we all know ,all the fields from excel are char type, the sap system will

automatic translate char to num . but if the field can not translate char to num. then the program

will be crush down

such as : qty type char : 500 in excel then in tab qty type num :500 ok

qty type char : 50A in excel then crash

Is there any function that can deal with this matter?

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

you simply have to check if the field value contains numbers only:

IF field CO '0123456789'.
==> can be translated
ELSE.
==> cannot be translated
ENDIF.

4 REPLIES 4

JozsefSzikszai
Active Contributor
0 Kudos

you simply have to check if the field value contains numbers only:

IF field CO '0123456789'.
==> can be translated
ELSE.
==> cannot be translated
ENDIF.

Former Member
0 Kudos

Hi Tom,

Once you download the values from Excel file in to an internal table, the internal table can be looped and that particular column can be checked for Numeric value.

Loop at itab into wa.

" Here it can be checked.

endloop.

Also, you can make use of this FM: MOVE_CHAR_TO_NUM. This will take care of the conversion.

Best Regards,

Ram.

Former Member
0 Kudos

use FM MOVE_CHAR_TO_NUM

raymond_giuseppi
Active Contributor
0 Kudos

You may [CATCH|http://help.sap.com/abapdocu/en/ABAPCATCH_SYSTEM-EXCEPT_SHORTREF.htm] the error.

CATCH SYSTEM-EXCEPTIONS convt_no_number = 1
                        conversion_errors = 2.
  MOVE char TO num.
ENDCATCH.
IF sy-subrc EQ 0.
  " converted
ELSEIF sy-subrc EQ 1.
  " not numeric
ELSEIF sy-subrc EQ 2.
  " not converted, other error
ENDIF.

Regards