SAPHub

How to Check Whether a Variable Contains a Numeric Value or Character in ABAP

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