JOBLIB


The JOBLIB is used to specify one or more user-defined libraries at the job level where the load module resides. When the job is submitted for execution, the system will search these libraries to find the load module running at each step.

When a program runs at the job step, the system searches for the required load module first in the STEPLIB libraries if coded, and if it is not found, then it searches in the JOBLIB libraries. If JOBLIB is not coded, the system searches in system libraries.

A job can have only one JOBLIB statement. A JOBLIB is optional.

Syntax -

//JOBLIB DD DSN=library-name,DISP=SHR  [comments]

Where:

  • library-name is the PDS where the program load modules resides.

Notes -

  • The job has only one JOBLIB statement and should code between the JOB and the first EXEC statements.
  • More than one library can code with the JOBLIB statement.
  • If a STEPLIB DD is coded in the job that also has a JOBLIB, the STEPLIB takes precedence when searching for a program.
  • If more than one load library is coded in JOBLIB, the order of searching for the load modules by the system is the same as how they are coded in JOBLIB.

Examples -


Scenario1 - JOBLIB with one library.

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//JOBLIB  DD   DSN=MTH.JLOADLIB,DISP=SHR
//STEP1   EXEC PGM=PROG1
//STEP2   EXEC PGM=PROG2

The system searches for the programs PROG1 and PROG2 in MTH.JLOADLIB.

Scenario2 - JOBLIB with multiple libraries.

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//JOBLIB  DD   DSN=MTH.LOADLIB1,DISP=SHR
//        DD   DSN=MTH.LOADLIB2,DISP=SHR
//STEP1   EXEC PGM=PROG1
//STEP2   EXEC PGM=PROG2

The system searches MTH.LOADLIB1 and MTH.LOADLIB2 for the program PROG1.

Scenario3 -

//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//JOBLIB  DD   DSN=MTH.JLOADLIB,DISP=SHR
//STEP01  EXEC PGM=PROG1
//STEPLIB DD   DSN=MTH.LOADLIB,DISP=SHR
//STEP2   EXEC PGM=PROG2

The system searches MTH.LOADLIB and MTH.JLOADLIB for the program PROG1. The system searches MTH.JLOADLIB for PROG2 as no STEPLIB is coded in STEP2.