Abap how to check char128 field contains only numeric and decimal points

I am reading data from an excel file. Cols of the internal table all char128, there are 2 cols that contain only a digit with a decimal point. Therefore, I need to check that the fields contain only a digital or digital digit with a decimal point. How? Thanks

The function module NUMERIC_CHECK simply can only check digitally if it is useless with a decimal point.

+3
source share
4 answers

You can use CO(contains only):

IF value CO '1234567890.'.
  "OK
ELSE.
  "Error"
ENDIF.

You might need a place in your IF _ CO-statement.

This check does not detect multiple semicolons (for example, 123.45.67.89).

ABAP .

, CO:: IF value CO '1234567890 .'.

+4

REGEX. DEMO_REGEX_TOY .

-, REGEX , , :

-?[0-9]+(\.[0-9]*)?

-? '-' (

[0-9] + (+ 1 )

\.? '.' ( \, "." - )

([0-9] +)?

+4

if you want to check if a string is a valid decimal, you can use the following module function: "HRCM_STRING_TO_AMOUNT_CONVERT", which allows you to convert a string to its numeric copy, given the string, decimal separator and thousand separator.

considers

0
source

Another way to check the number:

data: float_value type f.
try.
  float_value = <your string value here>.
catch cx_sy_conversion_no_number.
  " not a valid number
endtry.
0
source

All Articles