Page 1 of 1

Why can't we use occur clause in 01 group level?

Posted: Mon Nov 17, 2014 2:59 pm
by praveenMadhu
Hi,

I know we should not - but the question is, Why can't we use occur clause in 01 group level? Is there any explnation apart from it being a rule?

Re: Why can't we use occur clause in 01 group level?

Posted: Mon Nov 17, 2014 8:13 pm
by Robert Sample
Actually, the fact that it is a rule is enough of a reason.

However, the Programming Guide points out that a table definition with the OCCURS must be subordinate to a group name -- and since that cannot occur with an 01 level, OCCURS cannot be put on an 01 level variable. And if you want to know why the table must be subordinate to a group name -- that is the rule.

You need to learn to accept what the rules are and use them without worrying about why things are how they are. Sometimes the explanation is available, but sometimes it is not -- remember that COBOL came about more than 50 years ago, so the reasons for some of the language constructs are not necessarily easy to determine now.