Page 1 of 1

Occurs are not allowed at 01/77, why?

Posted: Thu Jul 11, 2013 2:58 pm
by cobollearn
Hi,

Occurs are not allowed at 01/77, why? I've read couple of reference in google but they are very clear. Can someone please help here.

Thanks.

Re: Occurs are not allowed at 01/77, why?

Posted: Thu Jul 11, 2013 3:13 pm
by Robert Sample
In COBOL, a variable must be able to be uniquely identified; this is done via qualification such as

Code: Select all

MOVE 1 TO VAR-X OF VAR-01
If the 01-level variable VAR-01 could have OCCURS, which VAR-01 is the qualification referring to?
Other potential reasons include:
- an 01 level represents a logical record; OCCURS would be defining multiple logical records which doesn't make sense.
- COBOL states a table occurs within a group. There is no level number that can be used to group 01 / 77 items

And the ultimate, complete, total answer to your question is:
The COBOL rule is that OCCURS is not allowed for 01 / 77 levels.
The rules are the rules, and it is not always possible to know why something is the rule -- remember COBOL dates back more than 50 years at this point, and the actual reason(s) may be lost in the history somewhere.

Re: Occurs are not allowed at 01/77, why?

Posted: Thu Jul 11, 2013 5:24 pm
by Priya
Can we say that -- "01 Level" represents a "record occurrence" so every next 01-level is a next record. If tables are allowed at 01 level - we'll never know if it's "record-occurrence" or "a repetition of similar fields" in a single record!?

Re: Occurs are not allowed at 01/77, why?

Posted: Thu Jul 11, 2013 5:40 pm
by Robert Sample
The 01 level in an FD of the FILE SECTION defines a record -- period. Multiple 01 levels in an FD define the same data in multiple ways. In WORKING-STORAGE or LINKAGE, however, the record concept does not really apply since neither is associated with a file. But both handle all data in an 01 level as a unit, which means the processing at the 01 level occurs as if it were a record.

Re: Occurs are not allowed at 01/77, why?

Posted: Tue Aug 06, 2013 11:45 pm
by Priya
Thanks Robert - this is helpful.