Copybook
A shared block of COBOL declarations kept in a library and included into programs, so a record layout is defined once.
Also written COPY, copy member, copylib
A copybook is a piece of COBOL source held as a member in a library and pulled into a program at compile time with a COPY statement. It is COBOL's include mechanism.
Its main use is record layouts. When forty programs read the customer file, all forty need the same field-by-field description of a customer record. Copying that into every program would guarantee they drift apart. Instead, the layout lives in one copybook and every program includes it.
That makes changes tractable. Adding a field means changing the copybook and recompiling the programs that use it. Knowing which programs those are is a standard part of impact analysis before any change goes ahead.
Copybooks also hold shared constants, common working-storage areas and standard blocks of logic used across a site.
When you are reading unfamiliar code, copybooks are essential context. A program that seems to reference undeclared fields is almost always using a copybook, and the field definitions are in the library rather than in front of you.
Related terms
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- DATA DIVISIONThe part of a COBOL program that declares every record layout and variable it will use.
- MemberOne named item inside a partitioned dataset, such as a single program, job or copybook within a library.
- Partitioned datasetA dataset that works like a library or folder, holding many separately named members inside one dataset.
- CompileTurning COBOL source code into machine instructions, checking the syntax and producing a listing of any errors.
- Level numberThe two-digit number in front of a COBOL data item that shows how fields nest inside a record.