on 04-19-2006 3:14 PM
Hello All,
Is there any FM present to check if a value is numeric and does not contain any alphanumeric or character values?
Thanks,
HI,
Use the 'CO' option. Contains only
if v_str co '0123456789'.
write:/ ' Its a pure number'.
else.
write:/ ' Its not a pure number'.
endif.
Regards,.
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are using a character field and do not want to compinsate for the SPACE in the field. You can do something like this as well.
report zrich_0001 .
data: field(10) type c value '1%56539'.
data: length type i.
length = strlen( field ).
if field(length) co '1234567890'.
write:/ 'This is a number'.
else.
write:/ 'This is not a number'.
endif.
Regards,
Rich Heilman
No need for a FM use the CATCH command to generate a CONVT_NO_NUMBER error for non numeric fields:
DATA I TYPE I.
CONVERSION_ERRORS contains CONVT_NO_NUMBER ***
CATCH SYSTEM-EXCEPTIONS CONVERSION_ERRORS = 1.
MOVE 'abc' TO I. " <- Error: CONVT_NO_NUMBER
ENDCATCH.
IF SY-SUBRC = 1.
...
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
NUMERIC_CHECK?
Rob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You don't need a function module. Just check it with an if statement.
If field CO '1234567890'.
* Then its ok.
else.
* Then its not ok.
Endif.
Regards,
Rich Heilman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.