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

Validating only digits

Former Member
0 Likes
1,016

Hi All

I want to validate a field with digits only ( 0 to 9) . If it contains other than 0 to 9 digits like special characters then it should fail.

for e.g. : 384746 should be true

384-746 should be false.

If I use CA operand then it throws true even for 384-746 value

Can anybody let us know how to achieve it ? is there any FM available .

I got it with some extra logic to find it out whether it is a numeric or not BUT I need a direct method , one step validation

Responses are highly appreciated .

Satya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
976

Try:


IF f1 CO '0123456789'.
* Good
ELSE.
* No good.
ENDIF.

7 REPLIES 7
Read only

Former Member
0 Likes
977

Try:


IF f1 CO '0123456789'.
* Good
ELSE.
* No good.
ENDIF.

Read only

0 Likes
976

Hi

Thanks for ur response

If f1 = 65883 then it is fine

if f1 = 659-675 then it should fail

The above condition should execute .there are some cases where special characters are possible.

Read only

0 Likes
976

Hi,

The code provided by Rob will work in the cases you provided. What is the issue then.

Regards,

Atish

Read only

0 Likes
976

Would you mind letting us know what the "special cases" are?

Rob

Read only

naimesh_patel
Active Contributor
0 Likes
976

Try like this:

[code]REPORT ZTEST_NP.

parameters: l_text(10) type c.

data: l_num(12) type c value '-+=@#$%^&*()'.

if l_text ca l_num.

write: 'false'.

else.

write: 'true'.

endif.[/code]

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
976

Hi Satya,

try like this

if field CO '0123456789'.

then process...

else.

exit.

endif.

Reward points if it helps,

Satish

Read only

Former Member
0 Likes
976

Thanks