To include external code into your Cobol source you use a copybook. A copybook is linked into your source using the following command:
COPY name OF|IN library SUPPRESS REPLACING op1 BY op2.
The most basic form of the command is to just specify COPY followed by the name of the member to be copied into this spot in the code. The other parameters specified are optional.
You specify the name of the library containing the copybook where the word library appears in the above code. If the copybook is to be found in a common library that is accessible to the preprocessor then the "OF|IN library" reference can be omitted. If you include this clause then using IN has exactly the same effect as using OF, they are alternative ways of coding the same thing.
Specifying SUPPRESS will omit listing the copybook contents in the compile listing. If SUPPRESS is omitted then the content of the copybook will be included in the listing.
The most interesting option on the COPY statement is the REPLACING clause. This allows you to replace all occurrences of a given string within the copybook with a different value allowing the same copybook to be used multiple times within the same program and yet referencing different field names in each instance. You can even replace multiple values within the same copybook just by specifying the replacement values separated by commas. For example:
COPY MY_REC REPLACING LS- BY WS-, -X BY -Y.
This article written by Stephen Chapman, Felgall Pty Ltd.