Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Example: using the COPY statement

These examples show how you can use the COPY statement to include library text in a program.

Suppose the library entry CFILEA consists of the following FD entries:

    BLOCK CONTAINS 20 RECORDS
    RECORD CONTAINS 120 CHARACTERS
    LABEL RECORDS ARE STANDARD
    DATA RECORD IS FILE-OUT.
01  FILE-OUT       PIC X(120).

You can retrieve the text-name CFILEA by using the COPY statement in a source program as follows:

FD FILEA
         COPY CFILEA.

The library entry is copied into your program, and the resulting program listing looks like this:

FD FILEA
         COPY CFILEA.
C    BLOCK CONTAINS 20 RECORDS
C    RECORD CONTAINS 120 CHARACTERS
C    LABEL RECORDS ARE STANDARD
C    DATA RECORD IS FILE-OUT.
C    01  FILE-OUT   PIC X(120).

In the compiler source listing, the COPY statement prints on a separate line. C precedes copied lines.

Assume that a copybook with the text-name DOWORK is stored by using the following statements:

COMPUTE QTY-ON-HAND = TOTAL-USED-NUMBER-ON-HAND
MOVE QTY-ON-HAND to PRINT-AREA

To retrieve the copybook identified as DOWORK, code:

paragraph-name.
    COPY DOWORK.

The statements that are in the DOWORK procedure will follow paragraph-name.

If you use the EXIT compiler option to provide a LIBEXIT module, your results might differ from those shown here.

related tasks  
Eliminating repetitive coding

related references   
Compiler-directing statements


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)