View previous topic :: View next topic |
Author |
Message |
Vanitha Beginner
Joined: 10 Jan 2005 Posts: 2 Topics: 1
|
Posted: Mon Jan 10, 2005 4:44 am Post subject: Check for Special character |
|
|
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 |
|
|
s_shivaraj Beginner
Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Mon Jan 10, 2005 5:49 am Post subject: |
|
|
Vanitha,
Try this,
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 |
|
|
Vanitha Beginner
Joined: 10 Jan 2005 Posts: 2 Topics: 1
|
Posted: Mon Jan 10, 2005 6:12 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Mon Jan 10, 2005 8:45 am Post subject: |
|
|
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 |
|
|
dtf Beginner
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
|
Posted: Mon Jan 10, 2005 9:55 am Post subject: |
|
|
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 |
|
|
s_shivaraj Beginner
Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Tue Jan 11, 2005 12:15 am Post subject: |
|
|
DTF,
8) Thanks for the poniting that... I was intrested in putting my logic there, forget to take care of syntax, Thanks DTF.
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 |
|
|
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Sat Jan 15, 2005 9:19 pm Post subject: |
|
|
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 |
|
|
|
|