Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if character field contains only digits

Tags:

abap

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.

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

like image 882
YuTian Avatar asked Apr 24 '12 02:04

YuTian


People also ask

How do I check if a string contains only digits?

isDigit(char ch) The idea is to iterate over each character of the string and check whether the specified character is a digit or not using Character. isDigit(char ch). If the character is a digit then return true, else return false.

How do you check for only digits in Python?

Python String isnumeric() Method The isnumeric() method returns True if all the characters are numeric (0-9), otherwise False. Exponents, like ² and ¾ are also considered to be numeric values.

How do you check if a string contains only digits in C++?

Approach: Create a frequency array to mark the frequency of each of the digits from 0 to 9. Finally, traverse the frequency array and if there is any digit that is not present in the given string then the answer will be “No” else the answer will be “Yes”.

How do you check if input contains only numbers JS?

To check if a string contains only numbers in JavaScript, call the test() method on this regular expression: ^\d+$ . The test() method will return true if the string contains only numbers. Otherwise, it will return false .


1 Answers

You may use CO (contains only):

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

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

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

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 .'.

like image 171
knut Avatar answered Nov 15 '22 11:11

knut