Copybooks and COPY
| The COPY statement | |
| REPLACING | |
| Copybook hygiene |
The COPY statement
COPY inserts the text of another file at compile time, like include in C. Copybooks usually hold shared data layouts so every program sees the same record:
DATA DIVISION.
WORKING-STORAGE SECTION.
COPY EMPLOYEE-REC.
REPLACING
REPLACING renames text as the copybook is included, so one copybook can serve several record prefixes:
COPY EMPLOYEE-REC REPLACING
==EMP== BY ==CUST==.
Copybook hygiene
Keep copybooks small and free of procedure code: data layouts only, with a clear prefix on every field name. A copybook that changes one program should be recompiled into all of its users before the next release.
Next: OO COBOL: classes and objects
Article author: Arthur Isaev