JOBLIB and STEPLIB
JOBLIB and STEPLIB in JCL both are used to specify the load libraries so that that the programs that are being used in that JCL/JOB are searched in these libraries. Generally z/OS searches for the programs load module in the default system libraries where actually the IBM supplied programs are stored. Specifying JOBLIB/steplib makes the Z/OS to search in these libraries first and then in system libraries.Both JOBLIB & STEPLIB are used for the same purpose except that JOBLIB is applicable for all the steps of a JOB where as the STEPLIB is limited to that step only.
What happens if both JOBLIB and STEPLIB are specified in a job? Which one has first preference. In this case, if steplib is specified for a STEP, Z/OS first looks for the program load MODULE in the steplib library. If it does not find it in there, then it searches in the SYSTEM LOAD LIBRARIES. So STEPLIB overrides the JOBLIB. Note that in this case, it does not go back to JOBLIB to search.
Multiple libraries can be specified under one DD statement, in this case z/OS searches for the load modules in the libraries one after another in the order they are given.
What is a LOAD Module: Load module is nothing but the executable code of a program which gets created in the compilation process (Link Edit part) and stored in a PDS specified in the compile JCL. These Load libraries are used in JOBs to execute the programs. To give more insight, we need to know about Source and Object Modules as well.
- Source Module is the code that we write in a PDS, this is not an executable one.
- Source code when under goes compilation process, Object module gets created.
- Object module when under goes Link Edit process, Load module gets created. This includes all the references that are present in the source code like date routines, Sub programs etc.
Example-1:
In the below code single loca library is specified at JOB level, so it is applicable for both the steps.
//JBNAME1 JOB (82C-9,'28/06/12'),MAHY,CLASS=A,MSGCLASS=A, // REGION=0M,TYPRUN=SCAN,NOTIFY=MG00T2 //********************************************************************** //* JOB LIBRARY //*************************************************************** //JOBLIB DD DSN=CUST.TEST.REG01.LOADLIB,DISP=SHR //********************************************************************** //* THIS STEP EXECUTES THE PROGRAM CUSTUPD //*************************************************************** //CUST1 EXEC PGM=CUSTUPD //INFILE1 DD DSN=CUST.CUSTUPD.IN01,DISP=SHR //OUTFILE1 DD DSN=CUST.CUSTUPD.OT01,UNIT=SYSDA, // DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=133,BLKSIZE=0) //SYSOUT DD SYSOUT=X //* //CUST2 EXEC PGM=CUSTEXT //EXTIN1 DD DSN=CUST.CUSTUPD.OT01,DISP=SHR //OUTFILE1 DD DSN=CUST.CUSTUPD.EXT01,UNIT=SYSDA, // DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=100,BLKSIZE=0) //SYSOUT DD SYSOUT=X //
Example-2:
If there are multiple Load libraries availabe and all of them needs to be specified it can be specified as below
//JOBLIB DD DSN=CUST.TEST.REG01.LOADLIB,DISP=SHR // DD DSN=CUST.TEMP.REG02.LOADLIB,DISP=SHR // DD DSN=CUST.PROD.REG03.LOADLIB,DISP=SHR
Example-3:
Specifying both JOB lib and STEPLIBs
//JOB001 JOB (82C9,'28/06/12'),MAHY,CLASS=A,MSGCLASS=A, // REGION=0M,TYPRUN=SCAN,NOTIFY=&SYSUID //********************************************************************* //* JOB LIBRARIES //*************************************************************** //JOBLIB DD DSN=CRD.REG01.LOADLIB,DISP=SHR // DD DSN=CRD.REG02.LOADLIB,DISP=SHR // DD DSN=CRD.REG03.LOADLIB,DISP=SHR // DD DSN=CRD.REG04.LOADLIB,DISP=SHR //********************************************************************* //* THIS STEP EXECUTES THE PROGRAM CUSTUPD //*************************************************************** //STP01 EXEC PGM=PROG01 //STEPLIB DD DSN=CRD.REG05.LOADLIB,DISP=SHR // DD DSN=CRD.REG06.LOADLIB,DISP=SHR //IN01 DD DSN=CRD.CUSTUPD.IN01,DISP=SHR //OUT01 DD DSN=CUST.CUSTUPD.OT01,UNIT=SYSDA, // DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=133,BLKSIZE=0) //SYSOUT DD SYSOUT=* //* //STP02 EXEC PGM=CUSTEXT //STEPLIB DD DSN=CRD.REG06.LOADLIB,DISP=SHR // DD DSN=CRD.REG07.LOADLIB,DISP=SHR //IN02 DD DSN=CUST.CRD.OT01,DISP=SHR //OUT02 DD DSN=CUST.CCRD.EXT01,UNIT=SYSDA, // DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=100,BLKSIZE=0) //SYSOUT DD SYSOUT=* //* //STP03 EXEC PGM=CUSUPD1 //IN02 DD DSN=CUST.CRD.EXT01,DISP=SHR //OUT02 DD DSN=CUST.CCRD.EXT02,UNIT=SYSDA, // DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(1,1),RLSE), // DCB=(RECFM=FB,LRECL=100,BLKSIZE=0) //SYSOUT DD SYSOUT=* //
I’m a little confused by example 3. In the article you mention “STEPLIB overrides the JOBLIB. Note that in this case, it does not go back to JOBLIB to search.”
In example 3, both programs have a STEPLIB defined, so if the program is not found at the STEPLIB, then it defaults back to the system libraries, not the JOBLIB. So, what is the purpose of the JOBLIB in this example?
You are right, there is no point in having the JOBLIB in Example 3. But it will be useful if there are other steps without STEPLIB. Updated the example-3.