Z/OS Cobol 6.3 copy: how to include only a chunk?

65 views Asked by At

I need this information: I have a Cobol 6.3 program “PROGRAM1” that includes a copy statement COPY1. COPY1 contains only data definition, it can be included in WORKING STORAGE or LINKAGE SECTION. I need to tailor the copy in the inclusion process. I need to include only the statement between two eye-catchers. It doesn’t matter the content of the eye-catcher, but it must be a comment, because COPY1 is included In a lot of other COBOL programs, that must include the copy as is without significant modification.

Below an example:

PROGRAM1:

IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM1.

ENVIRONMENT DIVISION.
DATA DIVISION.

WORKING-STORAGE SECTION.
    COPY COPY1 from eye-catcher 1 to eye-catcher 2**.

    ... Rest of program data definition ...

PROCEDURE DIVISION.
    

    ... Rest of program logic ...

    STOP RUN.

** This isn’t a valid COBOL statement. It’s only for clarity.

COPY1:

01  AREA1 PIC X (10).

...eye-catcher 1...

01  AREA2 PIC X (10).

...eye-catcher 2...

01  AREA3 PIC X (10).

I need to include only :

01  AREA2 PIC X (10).

I've searched but found nothing. any idea?

2

There are 2 answers

1
cschneid On

If you are not allowed to modify COPY1 as @BruceMartin suggests, try...

COPY COPY1 REPLACING 
  ==01  AREA1 PIC X (10).== BY ====
  ==01  AREA3 PIC X (10).== BY ====
.
1
Bruce Martin On

Expanding on my comment basically if the Copybook

     01  First-part-of-copybook.
         ...
     01 Bit-i-want.
        ...
     01 The-Rest.
        ...

You create a new copybook called say myCopy

     01 Bit-i-want.
        ...

and the original copybook becomes

     01  First-part-of-copybook.
         ...
     copy bycopy.
     01 The-Rest.
        ...

and you would use bycopy in your program