Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VALIDATE STATE DATA FIELD BEFORE A WRITE

Status
Not open for further replies.

JENISON187

Programmer
Apr 4, 2005
17
US
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

 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top