Is the record‑key ordering preserved in sequential‑access files when COBOL 85 fixed‑format code is compiled with a modern COBOL 2002 free‑format compiler?
0 reputation · 25 Oct 2022, 01:08 UTC
0 reputation · 25 Oct 2022, 01:08 UTC
The objective is to determine whether modern COBOL runtimes maintain the original record‑key ordering for sequential‑access files when a program written in COBOL 85 fixed‑format syntax is compiled with a COBOL 2002 free‑format compiler.
Constraints include using at least two compiler implementations from different vendors, accounting for alignment options that may influence record layout, and recognizing that behavior could vary between IBM, Micro Focus, and GnuCOBOL.
Yes, the logical record‑key ordering is preserved; the key’s position is defined by the file description (FD) and the runtime reads records in the order they were written, regardless of fixed‑format versus free‑format compilation.
When the compiler parses free‑format code it may reorder working‑storage items or apply padding, which can move the key’s byte position. The logical ordering, however, is unchanged because the file is read sequentially.
If you are using alignment or RECORD VARYING options, let us know the specific flags so we can assess their impact on key position.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 25 Oct 2022, 06:54 UTC
One clarification: in an ORGANIZATION IS SEQUENTIAL file, sequential access follows the file’s record sequence; it does not promise key-sorted output. Key-based lookup is normally provided by ORGANIZATION IS INDEXED. Fixed versus free source format is only source layout, not file organization, so changing syntax should not itself alter SELECT or FD semantics. Alignment settings may affect record offsets, but not the logical read order.
For a controlled comparison, assume IBM Enterprise COBOL for z/OS 6.3, Micro Focus Visual COBOL 2022, and GnuCOBOL 3.1.2, while confirming installed releases and relevant dialect or compiler options. Use equivalent fixed/free programs, identical input records, organization, blocking, and allocation settings; write non-key-sorted records and expect the write order to be preserved. Compare key sequences and record contents, and test indexed files separately because key order and duplicate-key handling are different questions.