Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Validate Numbers

Former Member
0 Likes
628

Hello,

How can I validate that a string a I got is only numeric?.

I have this for example:

DATA: str type string.

str = 'a1a1'.

I need to find out if str is ONLY numeric, not alphanumeric, any ideas?,

Thanks!!!

Gabriel

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
610

Hi Gabriel,

Please declare a string 'str2'with 'A to Z'.

in the statement,

if str CA str1.

then

...

else

...

endif.

It will work.

shylesh

4 REPLIES 4
Read only

Former Member
0 Likes
611

Hi Gabriel,

Please declare a string 'str2'with 'A to Z'.

in the statement,

if str CA str1.

then

...

else

...

endif.

It will work.

shylesh

Read only

Former Member
0 Likes
610

Hi Gabriel,

By using a check for value in SY-ABCDE you can check that..

DATA: str type string.

str = 'a1a1'.

IF STR CA SY-ABCDE."Checks if the string contains any alphabets from A to Z.

...

ELSE.

.....

ENDIF.

Read only

Former Member
0 Likes
610

Try:


REPORT ztest MESSAGE-ID 00.

PARAMETERS: p_input(10).

DATA numbers(10) VALUE '1234567890'.

IF p_input CO numbers.
  WRITE: /001 p_input,  'is numeric.'.
ELSE.
  WRITE: /001 p_input,  'contains non-numeric characters.'.
ENDIF.

Rob

Read only

Former Member
0 Likes
610

Hi,

Thank you all for your help, I already tryed as you all said, but it worked for me like this:

IF str CN '1234567890' AND sy-fdpos EQ '1'.

...

endif.

Thanks,

Gabriel