JCL Training
JCL Training
Statement Description
JOB Provides the job name to the system for the batch workload.
It can optionally include accounting information and a few
job-wide parameters.
EXEC Provides the name of the program to execute. There can be
multiple EXEC statements in a job. Each EXEC statement
within the same job is called a job step.
DD DD stands for Data Definition. It provides inputs and outputs
to the execution program on the EXEC statement. This
statement links a data set or I/O device to a ddname coded in
the program. DD statements are associated with a particular
job step.
JCL - Example
//SRTEMP JOB (00967),’THOMAS’
//STEP10 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=SN32967.EMP.DETAILS
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,15,CH,A)
/*
Statement Description
SRTEMP Job name
STEP10 Step name
SORTIN The ddname of the input file in the SORT program
SORTOUT The ddname of the output file in the SORT program
SYSOUT Output messages sent to the JES print output area
SYSIN Another input statement that tells SORT program on which fields to sort the data
JCL – Parameter Types
JOB statement identifies the job and the user who submits it
The syntax of a JOB statement looks like
//Jobname JOB positional-parms,Keyword-parms
Jobname identifies the job while submitting it to z/OS. It can be of length 1 to 8 with alphanumeric
characters and starts just after //.
JOB is the keyword that identifies the JOB statement
CLASS • Based on the number of resources required by the job, companies assign different job classes
• The job classes can be classified with respect to the environment (test, pre-prod, prod)
• Valid values for CLASS parameter are A to Z and 0 to 9
• CLASS=0 to 9|A to Z
• Ex: CLASS=A
MSGCLASS • Specifies the output destination for the system and the job messages when the job is complete
• MSGCLASS=CLASS
• Valid values of class can be A to Z or 0 to 9
• Ex: MSGCLASS=X indicates the job output is directed to the SPOOL
MSGLEVEL • Specifies the type of messages to be written to the output destination specified in the MSGCLASS
• MSGLEVEL=(Statements,Messages)
• Statements=Type of statements written to the output log
• 0 means job statements only
• 1 means JCL statements along with symbolic parameters expanded
• 2 means input JCL only
• Messages=Type of messages written to the output log
• 0 means allocation and termination messages written upon abnormal job completion
• 1 means allocation and termination messages written irrespective of the nature of job completion
• Ex: MSGLEVEL=(1,1)
JOB Statement
Keyword Parameters Description
TIME • Specifies the time span to be used by the processor to execute the job
• TIME=(mm,ss) or TIME=ss (mm is minutes and ss is seconds)
• Ex: TIME=30
• TIME=1440 or TIME=NOLIMIT means there is no time limit for this particular job
• TIME=MAXIMUM allows a job to use the maximum amount of CPU time
REGION • Specifies the address space required to run a job step within the job
• REGION=nK|nM (K is kilobyte and M is Megabyte)
• When REGION=0K or 0M, largest address space is provided for execution
TYPRUN • Specifies a special processing for the job
• TYPRUN=SCAN|HOLD
• SCAN checks for the syntax errors of the JCL without executing the job
• HOLD puts the job on hold in the job queue. To release the job, type “A” against the job in the SPOOL
that brings the job to execution.
NOTIFY • Sends the success or failure message to the user specified in this parameter
• NOTIFY=userID|&SYSUID
• userID is a specific user ID
• &SYSUID is the user ID submitting the JCL
PRTY • Specifies the priority of the job within a class
• If omitted, the job is added to the end of the queue in the specified class
• PRTY=N
• N varies from 0 to 15. The higher the value, the higher is the priority
JOB Statement – Examples
EXEC statement provides the program or the procedure to be executed in the job step
The syntax of a EXEC statement looks like
//Stepname EXEC positional-parms,Keyword-parms
Stepname identifies the job step within the JCL. It can be of length 1 to 8 with alphanumeric characters and
starts just after //.
EXEC is the keyword that identifies the EXEC statement
The job is allowed 4 minutes of execution time and each step is allowed 2 minutes. If either step tries to execute beyond 2 minutes, the
job will terminate beginning with that step.
The job is allowed 3 minutes of execution time. Each step is allowed 2 minutes of execution time. Should either step try to execute
beyond 2 minutes, the job will terminate beginning with that step. If step S10 executes in 1.6 minutes, then step S20 tries to execute
beyond 1.4 minutes, then the job will be terminated because of the 3 minutes time limit specified on the JOB statement.
//JOBC JOB ,’TEST10’,TIME=2
//S10 EXEC PGM=PROGRAMP,TIME=3
The job is allowed 2 minutes of execution time. Since the time specified on the JOB statement is less than the time on the EXEC
statement, the step S10 is only allowed 2 minutes of execution time. If step S10 attempts to execute beyond 2 minutes, the job will
terminate in that step.
Since TIME=1440 is specified on the JOB statement, any TIME values on an EXEC statement will be nullified.
EXEC Statement
Keyword Parameters Description
COND • Used to control the job step execution based on the Return Code (RC) of the previous step
• The COND parameter can be coded on JOB statement or EXEC statement.
• If the COND parameter is coded on the JOB statement and on one or more of the job’s EXEC statements and
if a RC test on the JOB statement is satisfied, then the job terminates. In this case the system ignores any
EXEC statement COND parameter. If the RC tests on the JOB statement are not satisfied, the system then
performs the RC tests on the EXEC statement. If an EXEC RC test is satisfied, the step is bypassed.
• COND=(code,logical-operator) or COND=(code,logical-operator,stepname) or COND=EVEN or COND=ONLY
• code specifies a number that the system compares to the return code from each job step
• logical-operator specifies the type of comparison (GT, GE, EQ, LT, LE, NE) to be made with the RC
• EVEN specifies that the job step is to be executed even if a preceding job step abnormally terminated
• ONLY specifies that the job step is to be executed only if a preceding job step abnormally terminated
The table on the right shows some common return codes 16 Fatal Error (very serious errors)
EXEC Statement – Examples
The COND parameter specifies that if 7 is less than the return code, the system terminates the job. Any return code less than or equal to 7
allows the job to continue.
The COND parameter specifies that if 20 is greater than or equal to the return code or if 30 is less than the return code, the system
terminates the job. Any code of 21 through 30 allows the job to continue.
If the return code from STEP3 is 0 through 3, the system bypasses STEP6. If the return code is 4 or greater, the system executes STEP6.
EXEC Statement – Examples
//TEST2 EXEC PGM=DUMPINT,COND=((16,GE),(90,LE,STEP1),ONLY))
The system executes this step ONLY if two conditions are met:
• A preceding job step abnormally terminated
• No return code tests are satisfied
Therefore, the system executes this step only when all three of the following are true:
• A preceding job step abnormally terminated
• The return codes from all preceding steps are 17 or greater
• The return code from STEP1 is 89 or less
The system bypasses this step if any one of the following is true:
• All preceding job steps terminated normally
• The return code from any preceding step is 0 through 16
• The return code from STEP1 is 90 or greater
DD Statement
Parameters Description
DSN/DSNAME • The name of the data set
• It can include creation of a temporary data set or new data sets
or a reference back to the data set name
• DSN=dsname or DSN=&&tempds or DSN=*.stepname.ddname
• Ex: DSN=SN45321.ORDER.DETAILS
• Ex: DSN=&&TEMP
• Ex: DSN=*.S10.ORDFILE
DD Statement – DDNAME and DSNAME
//DD1 DD *,DLM=AA
.
.
data
.
AA
The DLM parameter assigns the characters AA as the delimiter for the data defined in the input stream by DD statement DD1.
DD Statement – Examples
//DD1 DD DSNAME=ALP,DISP=(,KEEP),VOLUME=SER=44321,
// UNIT=3400-6,DCB=(RECFM=FB,LRECL=240,BLKSIZE=960)
//DD1A DD DSNAME=EVER,DISP=(NEW,KEEP),UNIT=3380,
// DCB=(RECFM=FB,LRECL=326,BLKSIZE=23472),
// SPACE=(23472,(200,40))
//DD1B DD DSNAME=EVER,DISP=(NEW,KEEP),UNIT=3380,
// DCB=(RECFM=FB,LRECL=326),
// SPACE=(23472,(200,40))
DD statement DD1B is the same as the DD1A statement except that it shows the alternate syntax for the DCB keyword subparameters. Also,
because BLKSIZE is omitted, the system will select an optimum block size for the data.
//DD2 DD DSNAME=BAL,DISP=OLD,DCB=(RECFM=F,LRECL=80,
// BLKSIZE=80)
//DD3 DD DSNAME=CNANN,DISP=(,CATLG,DELETE),UNIT=3400-6,
// VOLUME=SER=663488,DCB=*.DD2
DD statement DD3 defines a new data set named CNANN and requests that the system copy the DCB subparameters from DD statement
DD2, which is in the same job step.
Reserved DD names
A programmer can select almost any name for a DD name, but using a meaningful name (within the eight character
limit) is recommended
There are few reserved DD names that a programmer cannot use (all of these are optional DD statements)
A single ddname can have multiple DD statements. This is called data set concatenation.
Concatenation applies only to input data sets.
The data sets are automatically processed in sequence.
//DATAIN DD DISP=OLD,DSN=SN244521.INPUT1
// DD DISP=OLD,DSN=SN244521.INPUT2
// DD DISP=SHR,DSN=SN456987.DATA
In the above example, when the application program reads to the end of MY.INPUT1, the system automatically
opens MY.INPUT2 and starts reading it. The application program is not aware that it is now reading a second
data set. This continues until the last data in the concatenation is read; at that point, the application receives an
end-of-file indication.
JCL Procedures
JCL procedure is a set of JCL statements grouped together to perform a particular function
Fixed part of the JCL is coded in the procedure and the varying part is coded within the JCL
Syntax:
//procname PROC
//…
//…
// PEND
PROC and PEND statements are unique to procedures and they identify the beginning and the end of a JCL procedure
PROC is preceded by the procedure name
Based on how the procedure is held with respect to the JCL, the procedures are classified into
Instream Procedures
Cataloged Procedures
JCL Procedures – Instream Procedures
When the procedure is coded within the same JCL member, it is called as an Instream Procedure
It should start with a PROC statement and end with a PEND statement
//SAMPINST JOB ,,CLASS=A,MSGCLASS=X,NOTIFY=&SYSUID
//*
//INSTPROC PROC //*START OF PROCEDURE
//PROCST EXEC PGM=SORT
//SORTIN DD DSN=&DSNM,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DSN=&DATAC,DISP=SHR
// PEND //*END OF PROCEDURE
//*
//STEP10 EXEC INSTPROC,DSNM=SN52241.SAMPLE.INPUT1,
// DATAC=SN452241.DATA.LIB(DSETA)
//*
//STEP20 EXEC INSTPROC,DSNM=SN52241.SAMPLE.INPUT2
// DATAC=SN452241.DATA.LIB(DSETB)
//*
Procedure INSTPROC is called in STEP10 and STEP20 using different input files. The parameters DSNM and DATAC can be
coded with different values while calling the procedure.
A symbolic parameter is a variable within a procedure to which a value may be assigned by coding on the EXEC statement
the name of the symbolic parameter and its desired value
JCL Procedures – Cataloged Procedures
When the procedure is separated out from the JCL and coded in a different member, it is called a Cataloged Procedure
PROG, SYSINDAT and DSNM are passed as symbolic parameters to the procedure CATLPROC.
Within the procedure, the symbolic parameters PROG and CORELIB are coded. Please note that the PROG parameter within the
procedure is overridden by the value in the JCL and hence PGM takes the value CATPRCA during execution.
JCL Procedures – Nested Procedures
Calling a procedure from within a procedure is called a nested procedure. Procedures can be nested up to 15 levels.
The nesting can be completely in-stream or cataloged. Cannot code an instream procedure within a cataloged procedure.
Procedure A:
//A PROC
//AS1 EXEC PROC=B
.
//AS2 EXEC PGM=ABC
.
// PEND
.
System Libraries
Library Description
SYS1.PROCLIB • Contains JCL procedures distributed with z/OS
• In practice, there may be many other JCL procedure libraries concatenated with it
SYS1.PARMLIB • Contains control parameters for z/OS and for some program products
• In practice, there may be other libraries concatenated with it
SYS1.LINKLIB • Contains many of the basic execution modules of the system
• In practice it is one of a large number of execution libraries that are concatenated
SYS1.NUCLEUS • Contains the basic supervisor (“kernel”) modules of z/OS
SYS1.SVCLIB • Contains operating system routines known as supervisor calls (SVCs)
Utilities
z/OS includes a number of small programs called utilities, which are useful in batch processing.
These programs provide many small useful functions.
Utility Description
IEFBR14 • The only function of this program is to provide a zero (0) return code by doing nothing
• Usually used to create an empty data set or delete an existing data set
IEBGENER • Copies one sequential data set to another
• A member of a partitioned data set can also be used as a sequential data set
IEBCOPY • Copy, merge, compress, back-up or restore PDS
IDCAMS • Primarily used to create and manipulate VSAM data sets
DFSORT
References
https://www.mainframestechhelp.com/utilities/sort/
http://www.mainframegurukul.com/srcsinc/drona/programming/languages/jcl/jcl.sort.html
Hands On