Highlighted
Absent Member.
Absent Member.
3151 views

Copy Book Prefix

Jump to solution

Hi,

Is there a way I can add prefix to a record and it's correspondent items when I copy the copybook into the working storage section ?

Best Regards

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Copy Book Prefix

Jump to solution

You can use copy with the replacing phrase to specify a prefix to use but your copybook must already be setup with a generic prefix that can be replaced.

There are two ways that you can do this depending on which dialect you are using in your compilation:

Ansi 85 and MF Dialect:

Source-file Code:

    copy Payroll
         replacing ==(TAG)== by ==Payroll==.

Copy-file 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.

Example Using ISO 2002 and Micro Focus Dialects

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==.

Copy-file 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.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Copy Book Prefix

Jump to solution

You can use copy with the replacing phrase to specify a prefix to use but your copybook must already be setup with a generic prefix that can be replaced.

There are two ways that you can do this depending on which dialect you are using in your compilation:

Ansi 85 and MF Dialect:

Source-file Code:

    copy Payroll
         replacing ==(TAG)== by ==Payroll==.

Copy-file 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.

Example Using ISO 2002 and Micro Focus Dialects

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==.

Copy-file 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.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.