Multiple Use of Source Code - Copycode

This document describes the advantages and the use of copycode.

The following topics are covered:


Use of Copycode

Copycode is a portion of source code which can be included in another object via an INCLUDE statement.

So, if you have a statement block which is to appear in identical form in several objects, you may use copycode instead of coding the statement block several times. This reduces the coding effort and also ensures that the blocks are really identical.

Processing of Copycode

The copycode is included at compilation; that is, the source-code lines from the copycode are not physically inserted into the object that contains the INCLUDE statement, but they will be included in the compilation process and are thus part of the resulting object module.

Consequently, when you modify the source code of copycode, you also have to catalog all objects which use that copycode using the CATALOG system command.

Attention:

  • Copycode cannot be executed on its own. It cannot be stowed with a STOW system command, but only saved using the SAVE system command.

  • An END statement must not be placed within a copycode.

For further information, refer to the description of the INCLUDE statement (in the Statements documentation).