Take the 2-minute tour ×

I read data from a excel file. The cols of internal table all are char128, there are 2 cols contain only digital with decimal point. So I need to check the fields only contain digital or digital with decimal point. How to ? Thanks

The function module NUMERIC_CHECK, just can check only digital, if the digital with decimal point it will be useless.

share|improve this question
Can the number be negative ? –  tomdemuyt Apr 24 '12 at 11:48
yes,actually it could be any thing, I just wanna check it, if it could be convert to digital, I have to show a error message to user –  YuTian May 8 '12 at 5:53

4 Answers 4

You may use CO (contains only):

IF value CO '1234567890.'.

Maybe you need also a space in your IF _ CO-statement.

This check does not detect multiple decimals points (e.g.

Newer versions of ABAP support regular expressions.

If you have also spaces in your string, you may add them into the CO-value:: IF value CO '1234567890 .'.

share|improve this answer
it's not a best one, I have tried it, if the value has space in it, it will be useless –  YuTian May 8 '12 at 3:32
@YuTian You may add spaces in your comparison. I modified my answer, –  knut May 8 '12 at 8:49
This technique is virtually useless since it will also let complete nonsense like "... . .. .. ." pass. –  vwegert Sep 7 '12 at 15:22

You might try to use REGEX. The report DEMO_REGEX_TOY lets you input strings and test regular expressions against them.

Someone more experienced with REGEX in general might be able to make this a little more versatile but here's what I came up with:


-? Optionally match the '-' character (allows for negatives or non-negatives

[0-9]+ matches digits (the + makes it match 1 or more)

\.? optionally matches the '.' character (the \ is needed as '.' is an operator)

([0-9]+)? optionally matches any digits after the decimal

share|improve this answer
it's a good demo, thank you so much. I'll read it –  YuTian May 8 '12 at 3:38

if you want to check if the string is a valid decimal, you could use the following module function : 'HRCM_STRING_TO_AMOUNT_CONVERT', which allow you to convert a string to its numeric counterpart, given the string, the decimal separator and the thousand separator.


share|improve this answer
thank you so much,good function –  YuTian May 8 '12 at 3:37

Another way to check for number:

data: float_value type f.
  float_value = <your string value here>.
catch cx_sy_conversion_no_number.
  " not a valid number
share|improve this answer
yeah, I use it in my code now. –  YuTian May 8 '12 at 3:37

Your Answer


