
i dont want to allow special character and digits
What do you want to do if you find them?
Tom

if i found my screen field then validate it if there any other option for it please tel me

For a simple validation test, translate any forbidden characters (to anything else, doesn’t matter as long as each translated character is different than the forbidden one it replaces) and if the translated string is not equal to the compare string, then there are forbidden characters in the compare string
d goodChar s 3a inz(’___’)
d forbidden s 3a inz(’1 $’)
d compareStr s 50a inz(’ABCDEFG1HIJK LMN$OP’)
/free
if compareStr <> %xlate(forbidden:goodChar:compareStr);
// forbidden characters in field
endif;
*inlr = *on;
/end-free

If all you want to do is check to see if you only have letters, no special characters or digits), then simply check for letters:
D string1 s 50a varying
D inz( ‘ABCDEFG1:’ )
D string2 s 50a varying
D inz( ‘ABCDEFGHI’ )
D chars C ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’
/free
if 0 <> %check( chars : string1 ) ;
dsply ’string1 has junk’ ;
endif ;
if 0 <> %check( chars : string2 ) ;
dsply ’string2 has junk’ ;
endif ;
*inlr = *on ;
return ;
/end-free
That has two string variables — string1 and string2. And it has a constant that contains only letters — chars.
It first checks string1 to see if there’s anything that doesn’t match between chars and string1. If it finds any position in string1 that doesn’t match, the %check() function will return the position of the mismatched character. So if it returns anything but zero, it will display the message ’string1 has junk’.
Then it checks string2. If it finds anything but letters, it will display the message ’string2 has junk’.
Because string1 has “1:” at the end, you should get the ’string1 has junk’. And because string2 only has letters, you won’t get a message for string2.
Tom

Hi TomLiotta
Thanks for your valuable example


















