COPY
With the COPY statement, you can include an exact copy of the ILF statements in a subroutine process within the one containing the COPY statement. The copied statements are added to the current event point during compilation. There are two primary advantages to using COPY rather than simply re-entering the desired statements in the current ILF routine:
· You can standardize certain routines, such as a calculation that is performed at several points in your application, and
· If a change is required to a copied routine, you make the changes in only one place and they are automatically reflected where the routine has been copied.
COPY
(1)
(2) (3)
(2) Application ID |
(3) Subroutine name |
You can use a related statement, SUBR, to execute a subroutine without actually copying it into the current process. This statement is particularly useful if a subroutine must be used in more than one event point in a process, or if the subroutine is very large and therefore extends the compilation time of a process.
An error is not generated if a statement references a non-existing application. A Missing Subroutine error is generated if a non-existing subroutine process name is encountered within a valid application.
Recursive use of a COPY statement, by which a COPY statement attempts to copy itself, is not allowed. A Copy Used Recursively error is generated in this case.
The following example copies a subroutine process that performs a common routine to verify general ledger account numbers:
COPY TGL VERIFY ACCOUNT