Copybooks

When more than one program uses a procedure, you can put the procedure in a copybook. A copybook is a source file that can be copied into another source file using an RPG /COPY statement.

The following rules apply to a copybook.

  • Each copybook should perform a defined function or related group of functions. Each function should be a separate procedure.

  • You must define all new variables in the related D-Specs or C-Specs.

Note: As of release 8.0.3, some copybooks are compiled as *MODULEs and then included in programs by being referenced through a binding directory rather than being included via a /COPY statement. If you change such a copybook, you must recompile it before you compile the program that refers to it.