Difference Between JOBLIB and STEPLIB statements in JCL

What is JOBLIB ?

JOBLIB is a data definition statement (DD) at JOB level which contains the load modules of programs which are executed by JOB at different steps.

Note: JOBLIB statement can't be used/coded in cataloged procedures.


Syntax:
Following are the syntax of a JOBLIB statement

Syntax 1:
//JOBLIB DD DSN=Place your PDS here

Syntax 2:

//JOBLIB DD DSN=Place your first PDS here
DD DSN=Place your second PDS here

Explanation of above syntax with example:

Example: Assume that we have a JCL which has 4 steps and is executing 4 different programs. If the load modules of all four programs are contained in a single PDS then we would use the first syntax where in only one PDS name is supplied at JOBLIB statement.

If the load modules of all four programs are contained in a two different PDS then we would use the second syntax where in two PDS names are supplied at JOBLIB statement. At the time of program execution load module of program is searched in first PDS, if not found then searched in second PDS.

Example 1: Example JCL code which executes 4 programs. Load modules all four programs are contained in a single PDS

//TESTJOB1 JOB (ACCINFO),user_id,CLASS=D,MSGCLASS=0,REGION=OM 
//********************************************************** 
//JOBLIB   DD  DSN=TEST.PGMS.LOAD,DISP=SHR
//********************************************************** 
//STEP01  EXEC PGM=PGM1 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//********************************************************** 
//STEP02  EXEC PGM=PGM2 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//**********************************************************
//STEP03  EXEC PGM=PGM3 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//**********************************************************
//STEP04  EXEC PGM=PGM4 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//**********************************************************
//

Image shows the above code in mainframe screen

Example JCL with JOBLIB statement (Single library)
Example JCL with JOBLIB statement (Single library)

Explanation of the above code

In the above code load modules of all the four programs PGM1, PGM2, PGM3, PGM4 are picked from a JOBLIB library "TEST.PGMS.LOAD".

Example 2: Example JCL code which executes 4 programs. All the load modules are not contained in a single PDS

//TESTJOB1 JOB (ACCINFO),user_id,CLASS=D,MSGCLASS=0,REGION=OM 
//********************************************************** 
//JOBLIB   DD  DSN=TEST.PGMS.LOAD1,DISP=SHR
//         DD  DSN=TEST.PGMS.LOAD2,DISP=SHR 
//         DD  DSN=TEST.PGMS.LOAD3,DISP=SHR 
//         DD  DSN=TEST.PGMS.LOAD4,DISP=SHR 
//********************************************************** 
//STEP01  EXEC PGM=PGM1 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//********************************************************** 
//STEP02  EXEC PGM=PGM2 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//**********************************************************
//STEP03  EXEC PGM=PGM3 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//**********************************************************
//STEP04  EXEC PGM=PGM4 
//SYSOUT    DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//**********************************************************
//
Example JCL with JOBLIB statement (Four different libraries)
Example JCL with JOBLIB statement (Four different libraries)

Explanation of the above code

In the above code at the time of execution of program PGM1 load module of PGM1 is initially searched in first PDS "TEST.PGMS.LOAD2". If the load module is found then program will continue with the execution. If the load module is not found in first PDS then searched in second PDS "TEST.PGMS.LOAD2”... Etc

The above process is done for all the four programs.

What is STEPLIB ?

STEPLIB is data definition statement at step level which contains the load modules of programs. STEPLIB is coded immediately after the JOB Step.

Partition datasets mentioned at STEPLIB are applicable only to that step not for the entire job. In other words load module of the program which is executed at a particular step is searched in the partition datasets coded in STEPLIB of that particular step.

Note: Unlike JOBLIB, STEPLIB can be coded in cataloged procedures.

Syntax:
Following is the syntax of a STEPLIB statement

Syntax 1:
//STEPLIB DD DSN=Place your PDS here

Syntax 2:
//STEPLIB DD DSN=Place your first PDS here
DD DSN=Place your second PDS here

Explanation of above syntax with example:

Example: Assume that we have a program (Program1) which calls Program2 and is executed at step1 of the JCL.

a) If the load modules of both the programs (program1, program2) are placed in a single PDS then we would use the first syntax, wherein only one PDS name is supplied at STEPLIB statement.


b) If the load modules of both the programs are present in two different PDS then we would use second syntax, where in two PDS names are supplied at STEPLIB statement.

Example JCLs using STEPLIB statement

The following are the example JCL codes which shows the use of STEPLIB statement

Example1: JCL code which executes 2 programs at two steps and step lib is coded at all the two steps. No JOBLIB is present

//TESTJOB1 JOB (ACCINFO),user_id,CLASS=D,MSGCLASS=0,REGION=OM 
//********************************************************** 
//STEP01  EXEC PGM=PGM1 
//STEPLIB  DD  DSN=TEST.PGMS.LOAD1,DISP=SHR
//SYSOUT   DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//********************************************************** 
//STEP02  EXEC PGM=PGM2 
//STEPLIB  DD  DSN=TEST.PGMS.LOAD2,DISP=SHR
//SYSOUT   DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//
Example JCL with STEPLIB statement for two different steps
Example JCL with STEPLIB statement for two different steps

Explanation of the above code

In the above example load module of program "PGM1" is searched in STELIB library "TEST.PGMS.LOAD1" of STEP01.

if the load module is not found in steplib library "TEST.PGMS.LOAD1" then program will abend with abed code "S806" (Load module not found).


Load module of program "PGM2" is searched in STELIB library "TEST.PGMS.LOAD2" of STEP02.

If the load module is not found in steplib library "TEST.PGMS.LOAD2" then program will abend with abed code "S806" (Load module not found).

Example 2: JCL code which executes 2 programs at two steps and step lib is coded for only one step

//TESTJOB1 JOB (ACCINFO),user_id,CLASS=D,MSGCLASS=0,REGION=OM 
//********************************************************** 
//JOBLIB  DD  DSN=TEST.PGMS.LOAD2,DISP=SHR
//        DD  DSN=TEST.PGMS.LOAD1,DISP=SHR
//STEP01  EXEC PGM=PGM1 
//STEPLIB  DD  DSN=TEST.PGMS.LOAD1,DISP=SHR
//SYSOUT   DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//********************************************************** 
//STEP02  EXEC PGM=PGM2 
//SYSOUT   DD SYSOUT=* 
//SYSPRINT DD SYSOUT=* 
//
Example JCL with STEPLIB and JOB statements
Example JCL with STEPLIB and JOB statements

Explanation of the above code

In the above example load module of program "PGM1" is searched in STELIB library "TEST.PGMS.LOAD1" of STEP01.

If the load module is not found in STEPLIB library "TEST.PGMS.LOAD1" then program will abend with ABEND code "S806" (Load module not found). JOBLIB statement is ignored when the STEPLIB is coded

Since no STEPLIB is coded for step STEP02, load module of program "PGM2" is searched in JOBLIB libraries "TEST.PGMS.LOAD1", "TEST.PGMS.LOAD2”. If the load module is not found in these two libraries then job will ABEND with S806 "load module not found" error.


Note:
If both STEPLIB and JOBLIB are coded, then STEPLIB specification will override JOBLIB specification.

Difference between JOBLIB and STEPLIB

JOBLIB
STELIB
JOBLIB is JOB level DD statement
STEPLIB is a step level DD statement
JOBLIB is coded immediately after the JOB statement
STEPLIB is coded immediately after the STEP Exec statement
JOBLIB statement can't be used/coded in cataloged procedures
STEPLIB can be coded inside cataloged procedures
JOBLIB statement is ignored if both JOBLIB and STEPLIB are specified
STEPLIB will override the JOBLIB, if both JOBLIB and STEPLIB are specified

More by this Author


No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working