GNU COBOL compiler and the zOS COBOL complier. GNU wins?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Prakash Jha
Registered Member
Posts: 58
Joined: Sat Jun 29, 2013 1:45 pm
India

GNU COBOL compiler and the zOS COBOL complier. GNU wins?

Post by Prakash Jha »

Hi,

I was running some COBOL progrms using GNU COBOL to see how it all goes. The results are pretty good so far however I have run into one glitch which is confusing me. It is in a data definition. Please consider this example:

Code: Select all

01 AA 
     10 BB 
          15 CC1 
          15 CC2 
      12 DD 
           15 EE1 
           15 EE2 
       10 FF 
The GNU COBOL compiler shows an error on the "12 DD", the error message:

Code: Select all

Warning: No previous data item of level 18 
This message seem correct to me. While the compile listing on z/OS does not does not have any error flagged like this. I think, IBM compiler has inserted a FILLER type entry to make the above look like:

Code: Select all

01 AA 
     10 BB 
      12 FILLER 
          15 CC1 
          15 CC2 
       12 DD 
           15 EE1 
           15 EE2 
       10 FF


Does anybody know, for sure, what the IBM compiler is doing with this?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: GNU COBOL compiler and the zOS COBOL complier. GNU wins?

Post by Robert Sample »

You did not post enough information -- which of the variables have PICTURE clauses? As posted, if 12 DD does not have a PICTURE then it is a group variable and the structure is valid COBOL, and GNU COBOL is erroneously generating a message.

IBM COBOL will modify a structure if needed (see slack bytes in the Enterprise COBOL Language Reference and Language Guide manuals) but I'm not sure it would make the change you think is happening.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: GNU COBOL compiler and the zOS COBOL complier. GNU wins?

Post by William Collins »

Well, if you look at your compiler output listing, you'll know, for sure, what the compiler has done, and it is not what you think.

If you look at Appendix A in any Enterprise COBOL Language Reference you'll find this, under DATA DIVISION:
Specifying level numbers that are lower than other level numbers at the same hierarchical level in a data description entry. [Standard COBOL 85 requires that all elementary or group items at the same level in the hierarchy be assigned identical level numbers.]
Your fist level-10 defines a hierarchy which is ended by your second level-10. You then have level-15, which is subordinate to the level-10, another level-15, then the level-12. The level-12 is subordinate to the level-10, but not subordinate to the level-15. So it must be equivalent to the level-15. The Enterprise COBOL compiler "normalises" level-numbers, so if you look at your compile listing you'll see that those two level-15s and the level-12 all appear as level-3, with the level-15 subordinate to the level-12 normalised as a level-4.

I think you've quoted your GnuCOBOL message from an earlier version of your code or made a typo, the message would refer to level 12, not 18.

So, both the Enterprise COBOL compiler and the GnuCOBOL compiler are correct. They are just applying different rules, due to the IBM Extension to COBOL detailed above.

This assumes that all your level-15s are individual items defining storage.
Prakash Jha
Registered Member
Posts: 58
Joined: Sat Jun 29, 2013 1:45 pm
India

Re: GNU COBOL compiler and the zOS COBOL complier. GNU wins?

Post by Prakash Jha »

Thank you so much William for the explanation. It is much clear now.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”