MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check for Special character

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Vanitha
Beginner


Joined: 10 Jan 2005
Posts: 2
Topics: 1

PostPosted: Mon Jan 10, 2005 4:44 am    Post subject: Check for Special character Reply with quote

I want a field to accept both numeric,alphabetic or both but it should not accept special characters.How can i check that condition?
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Mon Jan 10, 2005 5:49 am    Post subject: Reply with quote

Vanitha,

Try this,

Idea Assuming your Field is of Lenght 1,

10 ws-variable.
88 ws-alphanum pic x(1) value 0 to 9, 'a' to 'z' , 'A' to 'Z'.
88 ws-special pic x(1).
Check for ws-special, if it's true, then the variable is an special character , otherwise it is your's.

Some one can suggest how it can be used on a field of more than 1 byte.

Hope it will be useful for you.
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
Vanitha
Beginner


Joined: 10 Jan 2005
Posts: 2
Topics: 1

PostPosted: Mon Jan 10, 2005 6:12 am    Post subject: Reply with quote

Thanks.But I get the value of the field as an input from CICS screen.It is of 8 bytes.I want to validate the input.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Mon Jan 10, 2005 8:45 am    Post subject: Reply with quote

Vanitha,

You can use the CLASS definition under SPECIAL-NAMES paragraph to enter the valid characters. I am considering SPACE also as a valid alphanumeric.

ex:

Code:

CONFIGURATION SECTION.                     
SPECIAL-NAMES.                             
   CLASS ALPHA-NUM IS 'A' THRU 'Z' ,       
                      '0' THRU '9' ,       
                      ' '.                 

WORKING-STORAGE SECTION.                   
                                           
01 SCREEN-INPUT             PIC X(08).     
                                           
                                           
PROCEDURE DIVISION.                         
                                           
    MOVE 'BLAHBLAH'   TO SCREEN-INPUT       

    IF SCREEN-INPUT IS ALPHA-NUM           
       DISPLAY 'THE STRING IS ALPHANUMERIC'
    ELSE                                   
       DISPLAY 'THE STRING CONTAINS SPECIAL CHARACTER'     
    END-IF                                 
                                           


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Mon Jan 10, 2005 9:55 am    Post subject: Reply with quote

Quote:

10 ws-variable.
88 ws-alphanum pic x(1) value 0 to 9, 'a' to 'z' , 'A' to 'Z'.
88 ws-special pic x(1).


I could be wrong, but this does not seem like valid syntax to me. I don't remember ever seeing a picture clause associated with an 88-level. In my usage at least, the 88 level followed a field that had a picture clause associated with it, and it would list the values that would be associated with the 88-level name.

So I guess I would expect to see something like:

Code:

10 ws-variable  PIC X.
88 ws-alphanum  value 0 to 9, 'a' to 'z' , 'A' to 'Z'.


You could define this as a table, and loop through one byte at a time, However I like Kolusu's solution better.

One question though......... Are you also wanting to allow spaces, either imbedded or trailing? If so, this will change the solution slightly.

DTF
________
Scientology Advice


Last edited by dtf on Tue Mar 15, 2011 4:59 am; edited 1 time in total
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Tue Jan 11, 2005 12:15 am    Post subject: Reply with quote

DTF,

8) Thanks for the poniting that... I was intrested in putting my logic there, forget to take care of syntax, Thanks DTF.

Arrow Kolusu solution is a good One
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sat Jan 15, 2005 9:19 pm    Post subject: Reply with quote

One point to keep in mind when defining ALPHA-NUM as a CLASS:

The chars A through Z are NOT contiguous. The result is that some printable chars for eg. } or \ as well as some other printables and non-printables will be accepted as ALPHA-NUM.

The solution is to define the chars individually, e.g. A B C ...... X Y Z or in 3 groups: A THRU I J THRU R S THRU Z.
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group