Understanding Libraries in JCL

Understanding Libraries in JCL

In JCL, libraries refer to storage locations where datasets, programs, or procedures are stored. They are critical in mainframe environments, as they allow organized access to frequently used resources like executable programs, reusable procedures, or dataset definitions. Libraries ensure efficiency, reusability, and proper organization of system resources.

To successfully run the program that you specify on a JCL, EXEC statement z/OS has to search for and find that program. Using JOBLIB or STEPLIB statements can reduce search time.

When you code the PGM parameter, z/OS looks for a program, and will automatically search standard system program libraries, such as SYS1.LINKLIB, which contains IBM-supplied programs.

If the program you want to run resides in a private program library, you must specify either a JOBLIB statement or a STEPLIB statement for z/OS to successfully locate the program.

JOBLIB (Program Library for All Steps in a Job)

  • Specifies the library where the system should search for programs used in all steps of the job.

  • JOBLIB applies to every step in the job. This is useful when multiple steps use programs stored in the same library

Example

//MYJOB JOB (123),CLASS=A,MSGCLASS=X

//JOBLIB DD DSN=MY.LOAD.LIB,DISP=SHR

//STEP1 EXEC PGM=PROGRAM1

//STEP2 EXEC PGM=PROGRAM2

  • Explanation:

    • JOBLIB: Directs the system to MY.LOAD.LIB to locate the programs PROGRAM1 and PROGRAM2 for both steps.

STEPLIB (Program Library for a Specific Step)

  • Specifies the library to search for programs for a single step within a job.

  • Overrides JOBLIB and applies only to the step where it is defined.

Example:

//STEP1 EXEC PGM=PROGRAM1

//STEPLIB DD DSN=MY.LOAD.LIB,DISP=SHR

Explanation:

  • STEPLIB: Directs the system to search for PROGRAM1 in MY.LOAD.LIB.

JCLLIB (Procedure Library for Cataloged Procedures)

  • The JCLLIB statement specifies the location of cataloged procedures.

  • If the cataloged procedure resides in a specific dataset library, the JCLLIB statement ensures that the system searches that location to find the procedure.

Example:

//MYJOB JOB (123),'Example Job',CLASS=A,MSGCLASS=X

//JCLLIB ORDER=MY.PROC.LIB

//STEP1 EXEC PROC=MYPROC

Explanation:

  • JCLLIB ORDER=MY.PROC.LIB: Tells the system to look in MY.PROC.LIB for the cataloged procedure MYPROC.

Last updated