If you’ve ever used COBOL, chances are high you are familiar with the COPY statement. It allows developers to write chunks of reusable code in a separate file, called a copybook. Such a copybook typically contains common data structures (a data copybook) or shared code for e.g. error handling (a code copybook), but in theory it can contain nearly anything you wish to reuse in multiple COBOL programs.
To include such a copybook in your main program, you use the COPY statement. This statement will simply place the prewritten source code in the compilation unit at compile time. The ‘compile time’ phrase is an important detail here as it means the COPY statement is a preprocessing statement altering the original source file by replacing the entire COPY statement with the contents of the copybook, so that the compiled program no longer contains the reference to the copybook, but instead contains the entire contents from that copybook.
In addition, a REPLACING clause can be specified with the COPY statement. This clause can be used to replace all occurrences of a specified text by the new associated text.
Get the full white paper using the form below.
Please fill in this form to request a PDF download for this White Paper.