Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1. INTRODUCTION......................................................................................................2
1.1. Types of Procedure..........................................................................................................................................2
1.1.1. Instream Procedures..................................................................................................................................2
1.1.2. Catalogued Procedures..............................................................................................................................2
2. EXAMPLE 1..............................................................................................................4
3. MODIFYING A PROCEDURE..................................................................................6
3.1. Symbolic Parameters......................................................................................................................................6
4. EXERCISE 1...........................................................................................................14
5. EXERCISE 2...........................................................................................................14
6. FLOW DIAGRAM...................................................................................................15
IT TRAINING 1
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
1. Introduction
A JCL procedure is a series of JCL statements very similar to those that you have already
met. JCL statements are placed in a procedure and the statements are obeyed by
specifying the name of the procedure on the EXEC statement. Projects use procedures as
they may simplify the JCL that is submitted on a regular basis. Procedures can be modified
when executed, so several programmers can use the same procedure thus saving
duplication and testing. Procedures are modified by passing parameters, amending and/or
adding additional DD statements.
Procedures are invoked by the EXEC JCL statement in either of the following forms -
OR
IT TRAINING 2
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
(1) An EXEC statement referring to a procedure, that is, only programs can be executed
within a procedure.
(2) DD statements defining instream data e.g. DD * or DD DATA
(3) A JOB statement
(4) A JOBLIB statement
(5) A delimiter statement i.e. a card containing just /* in COLS 1 & 2
(6) A null statement i.e. a card just containing // in COLS 1 & 2
(7) JES2 statements e.g. /*JOBPARM
To use a catalogued procedure that does not reside in a system library you can use the
JCLLIB statement to identify the relevant procedure library.
The JCLLIB statement is coded after the JOB statement and before the first EXEC
statement. For example:
IT TRAINING 3
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
2. Example 1
IT TRAINING 4
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
//*
//******************************************************************************
//* *
//* STEP: PTRA020 PROGRAM: TRA020 *
//* *
//* PURPOSE: PRINTS MAINFILE *
//* *
//******************************************************************************
//*
//PTRA020 EXEC PGM=TRA020
//STEPLIB DD DSN=NUTRD.NUTRD14.LOAD,
// DISP=SHR
//UT01 DD DSN=NUTRD14.TESTFILE,
// DISP=SHR
//LP11 DD SYSOUT=X
// PEND
//*
//******************************************************************************
//* *
//* STEP: STRCRE PROCEDURE TRCRE *
//* *
//* PURPOSE: RUNS TRA040AND/OR TRA020 *
//* *
//******************************************************************************
//*
//STRCRE EXEC TRCRE
IT TRAINING 5
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
3. Modifying a procedure
would become
//UT11 DD DSN=&DSN1,
// DISP=(NEW,CATLG,DELETE),
would become
//UT01 DD DSN=&DSN1,
// DISP=SHR
and
//LP11 DD SYSOUT=X
would become
//LP11 DD SYSOUT=&SOUT
IT TRAINING 6
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
3.2. Example 2
//NUTRD14B JOB F-ZZZZZ-NUTR-TTT,
// JCL.G-TS,
// CLASS=A,
// MSGCLASS=X,
// NOTIFY=NUTRD14
//*
//******************************************************************************
//* *
//* JOB: PROCEDURE TRCRE FREQUENCY: WEEKLY *
//* *
//* STEP: PTRA040 PURPOSE: RUNS MAINFILE FORMAT *
//* PROG TRA040 *
//* *
//* STEP: PTRA020 PURPOSE: RUNS MAINFILE PRINT *
//* PROG TRA020 *
//* *
//******************************************************************************
//*
//TRCRE PROC DSN1=, SOUT=X
//*
//******************************************************************************
//* *
//* STEP: PTRA040 PROGRAM: TRA040 *
//* *
//* PURPOSE: PRODUCES MAINFILE FORMAT FROM *
//* 80 BYTE RECORDS *
//* *
//******************************************************************************
//*
//PTRA040 EXEC PGM=TRA040
//STEPLIB DD DSN=&DSN1,
// DISP=SHR
//CR01 DD DSN=NUTRD.MASTER.DATA(CTRACCS),
// DISP=SHR
//UT11 DD DSN=NUTRD14.TESTFILE,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DEVPOOL,
// SPACE=(TRK,(2,1),RLSE),
// DCB=(RECFM=VB,LRECL=1328,BLKSIZE=0)
//LP11 DD SYSOUT=&SOUT
IT TRAINING 7
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
//*
//******************************************************************************
//* *
//* STEP: PTRA020 PROGRAM: TRA020 *
//* *
//* PURPOSE: PRINTS MAINFILE *
//* *
//******************************************************************************
//*
//PTRA020 EXEC PGM=TRA020
//STEPLIB DD DSN=NUTRD.NUTRD14.LOAD,
// DISP=SHR
//UT01 DD DSN=NUTRD14.TESTFILE,
// DISP=SHR
//LP11 DD SYSOUT=&SOUT
// PEND
//*
Note - Both parameters are defined on the PROC statement. The DSN1 parameter is not
given a default value, as this procedure is designed to be used by several people, it is
impossible to give a meaningful value. The SOUT parameter has been given a default
value of X.
Example A
//******************************************************************************
//* *
//* STEP: STRCRE PROCEDURE TRCRE *
//* *
//* PURPOSE: RUNS TRA040AND/OR TRA020 *
//* *
//******************************************************************************
//*
//STRCRE EXEC TRCRE,
// DSN1=’NUTRD14.TESTFILE’,
// SOUT=A
The values for DSN1 and SOUT are assigned on the procedure execute statement. The
name for DSN1 must be enclosed in quotes. Quotes are necessary if a value contains any
of the characters . , + or *
Example B
//******************************************************************************
//* *
//* STEP: STRCRE PROCEDURE TRCRE *
IT TRAINING 8
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
//* *
//* PURPOSE: RUNS TRA040AND/OR TRA020 *
//* *
//******************************************************************************
//*
//STRCRE EXEC TRCRE,
// DSN1=’NUTRD14.TESTFILE’
Note - a value for a parameter cannot be continued onto another line. Continuation can
only take place after a complete parameter followed by a comma.
Default values for parameters can be nullified by coding parameter= on the procedure call
e.g. nullify the SOUT parameter of our procedure in Example 1 code
//******************************************************************************
//* *
//* STEP: STRCRE PROCEDURE TRCRE *
//* *
//* PURPOSE: RUNS TRA040AND/OR TRA020 *
//* *
//******************************************************************************
//*
//STRCRE EXEC TRCRE,
// DSN1=’NUTRD14.TESTFILE’,
// SOUT=
Care must be taken when nullifying symbolic parameters that represent positional
parameters. for example the procedure TRDAILY contains the following statement,
IT TRAINING 9
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
// TYPE=
//LP11 DD ,SYSOUT=A
The comma will cause a JCL error. To overcome this problem, the procedure should be
coded
//LP11 DD &TYPE.SYSOUT=&SOUT
//STRDAILY TRDAILY,
// TYPE='DUMMY',
// SOUT=X
or
//STRDAILY TRDAILY
// TYPE=,
// SOUT=X
The symbolic parameter has been followed by a full stop, not a comma, the full stop marks
the end of the symbolic parameter.
Examples
(1) To add a PARM parameter to program TRA040 in our procedure Example 2 code
(2) To nullify the COND parameter in step PTRA090 of procedure TRDAILY code
IT TRAINING 10
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
These statements follow the statement that executes the procedure. They have to be in the
same order as they appear in the procedure.
More than one parameter on a DD statement can be changed and more than one DD
statement changed. Subparameters e.g. BLKSIZE can be amended in the same way as
parameters. It is not necessary to redefine all the DCB parameter, only the
subparameter(s) that require amendment. As before when nullifying a parameter the = sign
should not be followed by a value. If the parameter is not present on the DD statement it
will be added.
(A) To change the volume serial number of UT11 DD statement of step PTRA040 code -
If the VOL parameter had not been coded on that statement, this parameter would be
added.
(C) To amend DD statement UT11 to write to a tape and to change the blocksize
code
//STRCRE TRCRE,DSN1='NUTRD.NUTRD15.TESTFILE'
//PTRA040.UT11 DD UNIT=CART,
// VOL=,
// SPACE=,
// DCB=BLKSIZE=32760
BLKSIZE and UNIT have been amended, VOL and SPACE have been nullified since
these parameters are not needed for cartridge datasets.
//STRCRE TRCRE,DSN1='NUTRD15.TESTFILE'
//PTRA040.LP11 DD OUTLIM=2000
IT TRAINING 11
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
//PTRA020.LP11 DD OUTLIM=2000
IT TRAINING 12
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
In a job that uses JCL procedures, the job log will list the procedure statements after the
procedure execute statement. This listing will distinguish between the original job
statements, procedure statements, amended procedure statements and comments.
Columns 1 and 2 will contain -
Catalogued Instream
Procedure Procedure
Coded in job // //
Procedure not amended XX ++
Amended procedure X/ +/
Comment lines have *** in columns 1-3 for both procedure types.
See following example.
MSGLEVEL can be coded on the JOB statement, if not coded the default value of
MSGLEVEL=(1,1) is used. This causes all JCL statements in the job stream and all JCL
statements in any catalogued procedures executed to be printed, also all allocation
messages are printed. To suppress printing the JCL from the catalogued procedures code
MSGLEVEL=(2,1)
Then only the JCL in the input stream and the allocation messages will be printed.
IT TRAINING 13
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
4. Exercise 1
Write an instream procedure, TRPROC, to run the suite in the following diagram.
(a) IDCAMS delete output serial datasets from all reporting programs
(b) PTRA0040n
(c) PTRA025
NOTE: -
Remember that PTRA040 needs to have a date and vat rate passed as PARM parameters
Steps should only run if all earlier steps are successful. See Attached Flow diagram on the
next page.
5. EXERCISE 2
(a) Extract the PROC from exercise 1 into a separate piece of JCL
(b) Create a new piece of JCL to run the procedure, with a JCLLIB ORDER statement and
the required EXEC statement and parameter values only after the jobcard.
IT TRAINING 14
INTRODUCTION TO JCL PROCEDURES LAST PRINTED: 20/06/02
6. Flow Diagram
PTRA040 UT11
IDCAMS
DELETE PTRA040 LP11
PTRA020 LP11
PTRA040n NUTRD.MAPC.TESTDATA
(PTRA040) UT01
PTRA040 LP11
PTRA040 UT11
C
SYSIN
PTRA025
IT TRAINING 15