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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does the validation work and the 88?

Status
Not open for further replies.

gelthie

Programmer
Oct 17, 2001
10
US
I have a question about validation. How does it work. I can't seem to understand it even though i read about it. and why you have to use and 88 in the lines. thanks
 
Gelthie,

could you possibly supply a bit more information, i.e. an example of something you read, or some more explicit questions about validation (a broad subject indeed !) ?
And what do you mean precisely by "an 88 in the lines" ? Are you referring to condition names, like

01 a-field pic x(01).
88 a-field-is-0 value '0'.
88 a-field-is-1 value '1'.

?

Please enlighten us !
 
In the example above you can use constructions like
IF A-FIELD-IS-0 THEN....

OR SET A-FIELD-IS-0 TO TRUE

It is nice to use because it looks ok. But I have also seen people looking for days to the code

IF MARRIED .....

and the value on the 88 level was wrong, but nobody thought about that, they were looking for all other things so it is a beauty in a dictionary definition in which you are 100% sure that the values are ok but dangerous also.
 
There is an additional advantage to the 88's, if you use them consistently and code them correctly.
Say you have values that change, but the logic to handle them remains constant. At my company we have several companies we to business with that have various reporting requirements to the different state governments. I code:

01 WHATEVER-RECORD.
05 COMPANY-CODE PIC 9(4).
88 CALIFORNIA-COMP VALUES 12
60 THRU 61
89 THRU 91
97.
88 FLORIDA-COMP VALUE 39.
88 NEVADA-COMP VALUES 20
26.

Then in my PROCEDURE DIVISION, I can code meaningful names, like this:

EVALUATE TRUE
WHEN CALIFORNIA-COMP
PERFORM CALIFORNIA-PROCESSING
WHEN FLORIDA-COMP
PERFORM FLORIDA-PROCESSING
WHEN NEVADA-COMP
PERFORM NEVADA-PROCESSING
END-EVALUATE.

Now the beauty of this is that even if you have fifty different such evaluates that do fifty different sets of things depending on the company's state, all you have to do to implement a new company is add its value to the appropriate 88. The PROCEDURE DIVISION is already coded correctly. My company is adding and deleting different companies to these lists all the time. Put the 88's in a copy book and all you have to do is update the copy book and re-compile the state specific programs. This is handy when you have fixed logic, but the conditions under which you want to execute that logic is subject to frequent change. Another good application is income tax brackets, which change due to circumstances beyond the programmer's control.

Gelthie, regarding your original question on data validation, generic validation is usually done with class tests like

IF NUM-ITEM IS NUMERIC

or

IF ALPH-ITEM IS ALPHABETIC

Specific tests for values in ranges or on a list are done with 88's. For my company example above you might code:

IF NOT CALIFORNIA-COMP AND NOT FLORIDA-COMP AND NOT NEVADA-COMP
PERFORM STATE-ERROR-HANDLING
END-IF.

Hope this helps Betty Scherber
Brainbench MVP for COBOL II
 
Could someone please answer me the following quetions:

1. What do a line-control(such as Zeros & Spaces) and a
page-Ctr do?

2. What are the purposes of using figurative constrants
and INITIALIZE?

Thanks
Gelthie
 
I think by line control, you mean carriage control. This controls how many lines the printer will advance for each line you write for a printer file. The specific codes you mention, space and zero, are traditionally the codes used for single and double spacing respectively.

A page counter is used to keep track of what page you are on for the purpose of printing a page number on the top of each page. It is usually initialized to zero when it is defined in WORKING-STORAGE and incremented by 1 in your heading routine before you actually print the line.

Figurative constants refers to a small group of constants that have been set up in the language which are commonly used in COBOL programs. They consist of SPACE - as many spaces as it takes to fill the item, ZERO - as many zeros as it takes to fill the item, LOW-VALUE - the lowest value in your computer's collating sequence (usually hex value '00'), HIGH-VALUE - the highest value in your computer's collating sequence (usually hex value 'FF'), QUOTE - a quotation mark, and the ALL literal - as many occurences of whatever string as it takes to fill the item.

INITIALIZE is used to set the value of an item to whatever is appropriate to that item's picture. Numeric elementary items are initialized to zeros. Non-numeric elementary items are initialized to spaces. For group items, the subordinate elementary items are initialized according to their pictures.

Hope this helps. Betty Scherber
Brainbench MVP for COBOL II
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top