Back to Shorts

How to check if a value is numeric in ABAP?

Use the Function Module NUMERIC_CHECK.

DATA: ld_value TYPE char10 VALUE '12345',
      ld_htype TYPE dd01v-datatype.

CALL FUNCTION 'NUMERIC_CHECK'
  EXPORTING
    string_in = ld_value
  IMPORTING
    htype     = ld_htype.

IF ld_htype = 'NUMC'.
  " ld_value is numeric
ELSE.
  " ld_value is NOT numeric
ENDIF.

HTYPE returns 'NUMC' if the value contains only digits, 'CHAR' otherwise. Note: decimals and thousand separators are treated as 'CHAR' — this FM only validates whole integers.

Alternative — use CO (Contains Only) for a lightweight check without calling an FM:

IF ld_value CO '0123456789'.
  " all characters are digits
ENDIF.