Use SAP Function module NUMERIC_CHECK to check whether a variable contains numeric value or character.
DATA: g_type TYPE dd01v-datatype. DATA: g_string(10) TYPE c. g_string = 'Hello'. *Check whether first character of material description is NUMERIC or CHAR CALL FUNCTION 'NUMERIC_CHECK' EXPORTING string_in = g_string IMPORTING htype = g_type. WRITE:/ 'The Value ', g_string, ' is a ',g_type. g_string = '25'. *Check whether first character of material description is NUMERIC or CHAR CALL FUNCTION 'NUMERIC_CHECK' EXPORTING string_in = g_string IMPORTING htype = g_type. WRITE:/ 'The Value ', g_string, ' is a ',g_type.
Output
IF value_entered CO ‘0123456789. ‘. (There is space after 9 and .dot and then ‘ Apostrophe and .dot)
WRITE ‘var is numeric’.
ELSE.
WRITE ‘var is alphabets’.
ENDIF.
Really? And what if value_entered = ‘.1.2 ..2 .7. 8.’ ?
What is that number?