×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VALIDATE STATE DATA FIELD BEFORE A WRITE

VALIDATE STATE DATA FIELD BEFORE A WRITE

VALIDATE STATE DATA FIELD BEFORE A WRITE

(OP)
I NEED TO VALIDATE A DATA FIELD THAT CONTAINS A U.S. STATE.  I NEED TO MAKE SURE THEY ENTER A VALID STATE BEFORE IT WRITES THE RECORD TO FILE.  HOW CAN I DO THAT?  CAN I USE
 
       10 STATE-FIELD       PIC X(002).
          88 VALID-STATES   VALUES 'MI','FL', ETC.

       
       IF VALID-STATES
          NEXT SENTENCE
       ELSE
          MOVE 'YOU MUST ENTER A VALID U.S. STATE'
             TO MAP-MSG-DATA

I WOULD APPRECIATE SOME INSIGHT.

ERIC

RE: VALIDATE STATE DATA FIELD BEFORE A WRITE

No need to shout, Eric. The shift key is down on the left.

More of a COBOL forum issue really, but you are probably safe using an 88 level conditional on this occasion. It is unlikely that the US will acquire new states in the foreseeable future, so no maintenance headache as the data aren't volatile. If it was something that was more likely to change (shop locations for a retail chain, for example) then I'd probably use reference data, preferably from a relational table. This also gives you the opportunity to translate the state code to the state name by having two columns on the table, which might be a nice-to-have on the display. I'm not from the US, and it took me some time and an atlas to figure out that ME was Maine...

For really high usage systems, use a CICS data table with a key of the state abbreviation.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close