Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need some help on Special names...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
smita V

New User


Joined: 05 Nov 2007
Posts: 11
Location: hyderabad

PostPosted: Thu Apr 07, 2011 2:55 pm    Post subject: Need some help on Special names...
Reply with quote

I need to check an alphanumeric string whether it consists of any Special characters. If so will post an error as special characters are not allowed.

I coded following:

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. CLASS HAS-INVALID-CHARS '*' '(' ')' '!' '@' '^'
'$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\' '?' '>'
'<' '%' '`' '_' '|'.

PROCEDURE DIVISION.

IF CA-MAP-TI(1) EQUAL '2'
IF CA-MAP-REIN-ACCT-NO HAS-INVALID-CHARS
Post error.

I am testing the code by giving values to CA-MAP-REIN-ACCT-NO as 1234%678, !@#$%^&*. But the code is not posting the error.

When I am using the variable with relative byte for e.g CA-MAP-REIN-ACCT-NO(1:1) and giving values @1234567, it is posting the error with above code.

I want to know why the code is not working when I am using the variable without relative positioning. How can I make this work?
The special character can be in any of the 8 bytes.

Thanks in advance.
[/img][/url][/code][/quote]
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Thu Apr 07, 2011 3:14 pm    Post subject:
Reply with quote

Because without using reference modification, you are comparing '@1234567" to a single character. This comparison will always be false. You can make it work by using reference modificaition on each character of CA-MAP-REIN-ACCT-NO to do the comparison.
Back to top
View user's profile Send private message
smita V

New User


Joined: 05 Nov 2007
Posts: 11
Location: hyderabad

PostPosted: Thu Apr 07, 2011 3:32 pm    Post subject:
Reply with quote

If I have to check each character using reference modification then I can do it with the help of 88 level clause also. what is the benefit of Special names over 88 level clause?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Thu Apr 07, 2011 4:50 pm    Post subject:
Reply with quote

I can't answer that question because I've never had a need to use SPECIAL-NAMES data in the way you did. Of course, I've only been writing COBOL for 36 years, so there may yet come a day when I need to use it ....
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Apr 07, 2011 5:09 pm    Post subject:
Reply with quote

Code:
77 CA-MAP-REIN-ACCT-NO  pic x(8).

move "!@#$%^&*" to CA-MAP-REIN-ACCT-NO
IF CA-MAP-REIN-ACCT-NO HAS-INVALID-CHARS
   Post error.

should work.
If it doesn't work maybe CA-MAP-REIN-ACCT-NO is not defined as X(8) containing spaces at the end.

class is used not as "has invalid chars", but as "consist solely out of invalid chars"

you can use INSPECT for what you're trying to do.
Code:
move invar to testvar
INSPECT Testvar CONVERTING "%*&!..."               
                     TO    "       "
if testvar <> invar
  display "error"
end-if
Back to top
View user's profile Send private message
smita V

New User


Joined: 05 Nov 2007
Posts: 11
Location: hyderabad

PostPosted: Thu Apr 07, 2011 7:16 pm    Post subject:
Reply with quote

I coded as given below and it is working now:

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. CLASS WS-VALID-CHARS IS '0' THRU '9'
'A' THRU 'Z'.

PROCEDURE DIVISION.
IF CA-MAP-TI(1) EQUAL '2'
IF CA-MAP-REIN-ACCT-NO WS-VALID-CHARS
NEXT SENTENCE
ELSE
Post error.

Thanks for your help.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Apr 08, 2011 3:12 am    Post subject:
Reply with quote

Close, but not quite correct.
'A' thru 'Z' (hex 'C1' thru hex 'E9') includes the non-alphabetic, non-numeric values x'CA', x'CB', x'CC', x'CD', x'CE', x'CF', x'D0', x'DA', x'DB', x'DC', x'DD', x'DE', x'DF', x'E0', and x'E1'.

What you probably SHOULD have coded, is

Code:
    SPECIAL-NAMES. CLASS WS-VALID-CHARS IS
                         'A' THRU 'I'
                         'J' THRU 'R'
                         'S' THRU 'Z'
                         '0' THRU '9'.


And, if a SPACE is also valid, you should include that, as well.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts Using Field names in FILEAID Batch CO... Atul Banke Compuware & Other Tools 2 Wed Jun 29, 2016 9:54 pm
No new posts Check special resource availability w... pinimo JCL & VSAM 8 Fri Apr 15, 2016 8:18 pm
No new posts special characters db2 unload Ashish.Srivastava.123 DB2 10 Thu Jun 25, 2015 12:21 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us