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

Doubt On String Validation.

Former Member
0 Likes
448

want to do some validation for telephone number for the pattern XXX-XXX-XXXX

i want to check all the values in the field telephone are numbers.

please help me how to check is there any easy way?

i have done like this

If telnum3(1) eq '-' and telnum6(1) eq '-' .

IF TELNUM CO '0123456789'

phone number is valid

else.

phone number is wrong.

endif.

else.

phone number pattern is wrong

endif.

but when i validate with database value 123-456-7890 giving phone number is wrong.but the pattern is correct .

In one more condition for another field i need to check for only 10 numbers are present

I gave like

l_fax co '0123456789' .

even l_fax contains numbers i am not getting output exactly..

please hellp with how to use Contains Only with the solution to the above problem.

2 REPLIES 2
Read only

former_member194669
Active Contributor
0 Likes
385

Hi,

Check this


parameters : val(30)  type c.
data : final(30) type c,
       cnt type i,
       v type c,
       n type i.
 
 
cnt = strlen( val ).
do cnt times.
move val+n(1) to v.
if v ca '0123456789'.
move v to final+n(1).
endif.
n = n + 1.
enddo.
 
condense final no-gaps.
 
write:/ final

aRs

Read only

Former Member
0 Likes
385

hi gokul

try giving

IF TELNUM CO '0123456789-'

instead of

IF TELNUM CO '0123456789'

hope it solves the problem

Regards

Gaurav

<b>

Reward points for useful answers</b>