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

field validations-

Former Member
0 Likes
683

I am working on a dialogue programme in which there are various fields like firstname, lastname, phoneno,age etc etc.., I need to validate the phoneno and age fields such that it should not accept anything but numericals, how can i do that!!!

sample code i am using is this -

*PHONE NUMBER VALIDATIONS

IF PHONENO CN 'ABCDEFGHIHJK'.

MESSAGE I017(YMESS).

RETURN.

ENDIF

sushanth.

5 REPLIES 5
Read only

Former Member
0 Likes
577

Hi,

use a numeric field as type reference to the age and phone no fields. ..

that will validate automatically

regards,

lavanya

Read only

Former Member
0 Likes
577

hi

validate ur fields in

PBO event of driver program with in

CHAIN

ENDCHAIN.

u can refer CHAIN ENDCHAIN. example .

reward if helpful.

Read only

Former Member
0 Likes
577

hi sushant,

Use CHAIN ..... ENDCHAIN for validation of fields in Dialog prog. for detailed help abt the code, use help on Chain ... Endchain.

Thanx.

Khan

Read only

Former Member
0 Likes
577

data : num type i.

data : n type i value 0.

data cpos type c.

parameters : input(30) type c.

field-symbols : <fs> type any.

num = strlen( input ).

do num times.

assign input+n(1) to <fs>.

if <fs> = '1'

or <fs> = '2'

or <fs> = '3'

or <fs> = '4'

or <fs> = '5'

or <fs> = '6'

or <fs> = '7'

or <fs> = '8'

or <fs> = '9'

or <fs> = '0'.

add 1 to n.

  • continue

else.

add 1 to n.

write 'error in input'.

endif.

enddo.

Read only

Former Member
0 Likes
577

Hi Sushanth,

Using the numeric fiends is the best solutions, as it will handle by default so that it will not allow the alphabets or any special characters, instead if you want to validate the existing Character fields on the screen you can validate by using the FIELD, CHAIN-ENDCHAIN.

To check this take the Length(say len1) of the screen field that you want to validate and move that field value to NUMC variable(var1) (declare that variable in you program), and after you move the original value to var1, again check the length for var1 (say len2). Now you compare both var1 and var2. if they are not equal to each other, then there will some character field exist in field that you want to validate.

Now you can throw the error message that 'please enter numeric value only'.

Please reward the points if helpful.