COPYLIB


COPYLIB is a DD statement used to code the copybook PDS in the compilation step (IGYCRCTL step) of the JCL at the compilation time. COPYLIB is a private library (PDS), and each member contains the copybook layout that is used by many application programs.

The system searches the copybooks in the COPYLIB PDS while compiling the program if they coded. Otherwise, it searches in the system COPY library.

Syntax -

//COPYLIB DD DSN=library-name,DISP=SHR

Where -

  • library-name is the PDS where the copybook resides.

A COPY statement is used to copy the copybook from the library to the program.

Examples -


Scenario1 - Coding a single COPY library.

//COB    EXEC PGM=IGYCRCTL,REGION=4M,COND=((4,LT,PC),(4,LT,TRN)), 
//            PARM='NODYNAM,LIB,OBJECT,RES,APOST,MAP,XREF,NOSEQUENCE' 
//STEPLIB  DD DSN=IGY420.SIGYCOMP,DISP=SHR 
//SYSLIB   DD DSN=MTH.TEST.COPYLIB,DISP=SHR
...

The system searches the libraries for copy libraries in the following order -

  1. MTH.TEST.COPYLIB
  2. MTH.AIT.COPYLIB
  3. MTH.PROD.COPYLIB

Scenario2 - Coding multiple libraries.

//COB    EXEC PGM=IGYCRCTL,REGION=4M,COND=((4,LT,PC),(4,LT,TRN)), 
//            PARM='NODYNAM,LIB,OBJECT,RES,APOST,MAP,XREF,NOSEQUENCE'
//STEPLIB  DD DSN=IGY420.SIGYCOMP,DISP=SHR
//SYSLIB   DD DSN=MTH.TEST.COPYLIB,DISP=SHR
//         DD DSN=MTH.AIT.COPYLIB,DISP=SHR
//         DD DSN=MTH.PROD.COPYLIB,DISP=SHR
//         DD DSN=DFH420.CICS.SDFHCOB,DISP=SHR
...

The system considers MTH.TEST.COPYLIB is the first priority for searching copybooks. If the desired copybook is found in it, the system won't look in other libraries. If the copybook is not found in the first library, then the system considers searching in libraries in the below order -

  1. MTH.TEST.COPYLIB
  2. MTH.AIT.COPYLIB
  3. MTH.PROD.COPYLIB