The COPY statement in an ANSI'85 conforming compiler can be used to modify parts of words in the copy member source. It should be carefully noted that this syntax only works when certain conventions (and special characters) are used. When using this technique, the programmer must set up their copy members with the modifiable sections pre-established. In fact, once this technique is used, the copy members will NOT compile cleanly when not replaced. For example:
Source file Code:
copy Payroll replacing ==(TAG)== by ==Payroll==.
Copybook Code:
01 (TAG). 05 (TAG)-Week pic s99. 05 (TAG)-Gross-Pay pic s9(5)v99. 05 (TAG)-Hours pic s9(3) occurs 1 to 52 times depending on (TAG)-Week of (TAG).
Is treated as if it were coded as:
01 Payroll. 05 Payroll-Week pic s99. 05 Payroll-Gross-Pay pic s9(5)v99. 05 Payroll-Hours pic s9(3) occurs 1 to 52 times depending on Payroll-Week of Payroll.
Both the ISO 2002 and the Micro Focus dialects support partial word replacement as specified in the ISO 2002 COBOL standard. As above, the modifiable sections must be pre-established, however, the use of special characters is not required and the copy members will compile cleanly even when no replacement is done to them.
The above example could equivalently be coded as follows:
copy Payroll replacing leading ==TAG== by ==Payroll==.
Copybook Code:
01 TAG. 05 TAG-Week pic s99. 05 TAG-Gross-Pay pic s9(5)v99. 05 TAG-Hours pic s9(3) occurs 1 to 52 times depending on TAG-Week of TAG.
Is treated exactly as the code is treated in the ANSI'85 example.