Vous êtes sur la page 1sur 32

JCL

Job Control Language

INTRODUCTION
A computer job is the basic independent unit of work. It begins as a group of
computer language statements (called source language statements) that you enter from a
terminal and store on a direct-access volume to be submitted to the computer. Sets of
source language statements that are executed together within a job constitute a program.
You usually divide program into functional parts called modules, subroutines, functions
or procedures so that the various parts can be tested and changed without affecting other
parts.
JCL statement direct the operating system on the processing to be done on a job and
describe all the I/O units required. Since these JCL statement are numerous and complex,
the statement are numerous and complex, the statement for frequently used procedures
are kept on a direct-access volume (disk). The user invokes these cataloged procedures by
giving the system the name of the cataloged procedures rather than submitting all the JCL
statements.
JCL consists of control statements that:

Introduce a computer job to the operating system


Request hardware device
Direct the operating system on what is to be done in terms of running application
and scheduling resources.

Components of JCL Statements


//NAME
|
name field

OPERATION
|
operation field

OPERANDS
|
operand field

COMMENTS
|
comment field

// The two forward slashes are required at the beginning of each JCL statement in
column 1 and 2

The name field. This is optional field immediately follow the //, starting in column
3

The Operation Field, Which indicates the operation that is to be performed

The operand Field must appear one or more spaces after the operation. Multiple
operands are separated by commas.

Comments. Comments begin one space after the last operand.

Continuation of JCL statements


//NAME OPERATION OPERAND,OPERAND,
// OPERAND, OPERAND
When the total length of the fields on a control statement exceeds 71 columns, continue
the fields onto one or more following statements.

Interrupt the field after a complete operand(including the comma that follows it)
at or before column 71
Code // in columns 1 and 2 of the following line
Continue the interrupted statement beginning anywhere in columns 4 to 16

Commenting JCL
//* This is a comment line
The comments statement contains //* in columns 1 to 3 with the remaining columns
contains any desired comments. Comment can also be coded on JCL statements by
leaving a blank field after the operand field.
The complete set of JCL statements is as follows

JOB statement identifies the beginning of a job


EXEC indicates what programs or procedure to be executed
DD (data definition) identifies what resources are needed and where to find them
Delimiters (/*) is the end-of-file statement for marking the end of the data that is
included with JCL statements
PROC identifies the beginning of the procedure, cataloged or instream and
assigns default values to symbolic parameters
PEND statement marks the end of an in-stream procedure.
IF/THEN/ELSE/ENDIF statement construct selectively executes job steps within
a job
INCLUDE statement copies JCL from a file into the Job stream
JCLLIB statement names private library that contains cataloged procedures and
jcl statements copied in to the input stream by INCLUDE statement
SET statement assigns values to symbolic parameters in a procedure.
Null (//) statement marks the end of a job.

JOB STATEMENT
The job statement informs the start of a Job to the Operating system, gives the necessary
accounting information and supplies run parameters. Each job must begin with a single
job statement.
Syntax:
//Jobname

JOB

operand
comments
<positional/
Keyword
Parameters>

Jobname is a descriptive name assigned to the job by the user, any name from 1 to 8
alphanumeric (A-Z,0-9) or national ($,@,#) characters, first character must be alphabet or
national characters.
Job statement Parameters
Operand field contains both positional and keyword parameters
Positional parameters are so called because of the position in which they appear. The
positional parameters in the JOB statement are:

Accounting Information
Programmers Name

Accounting Information
This is used to bill or charge back any job that is run on the mainframe.
Syntax
(account number, additional-accounting-information)
Account number, additional-accounting-information
account number
, additional-accounting-information
//Job1 JOB
//Job1 JOB

A123, dept1
(, dept1)

Programmer Name parameter follows the job accounting information parameter.


//Job1 JOB
//Job1 JOB

A123, dept1 MANI


, Kamal

Keyword Parameters
Keyword parameters must follow positional parameters. Unlike positional parameters
they can be coded in any order. The keyword parameters in a job statement are
CLASS specifies the job class, an input queue for holding jobs awaiting execution. It
ranges from A-Z, 0-9.
COND - specifies the condition for executing the subsequent job steps, if previous steps
fail.
REGION specifies region size to allocate to the job
TIME imposes the CPU time limit on the job. The forms are
TIME = minutes
TIME = (minutes, seconds)
TIME = nolimit or 1440
TIME = maximum, which is 357,912 mins
MSGCLASS specifies the job scheduler output class
MSGLEVEL specifies whether to list all the JCL statements
MSGLEVEL = (jcl, allocation)
JCL
0
1

2
Allocations
0
1

Meaning
Print only the job statement
Print all JCL in the input stream and all the JCL in any
cataloged procedures invoked, including the internal
representation of statements after symbolic parameter
substitutions. Also print all JES control statements
Print only the JCL in the input stream and any JES control
statements
Meaning
Print only JCL messages but no allocations, JES or operator
messages unless the job abnormally terminates.
Print all allocations, JES, SMS and operator messages.

NOTIFY - notifies user at the terminal when the batch job is completed
NOTIFY = userid
PRTY specifies the jobs priority in the input queue. The priority may range from 0-15
in JES2 and 0-14 in JES3.

RD requests restart of a job statement and may also suppress the CHKPT macro.
RD = restart conditions
____________________________________________________________________
Restart conditions
Automatic restart
Suppress CHKPT
R Restart
Yes
No
NC- no checkpoint
No
Yes
NR- No automatic restart
No
No
RNC Restart and no checkpoint
Yes
Yes
___________________________________________________________________
RESTART submits a job for a restart
RESTART = stepname
RESTART = stepname.procstep
RESTART = * ( restarts at the first step)
RESTART = (stepname, checkid)
TYPRUN checks JCL or holds the job in the input queue.
TYPRUN = SCAN, checks the JCL for the syntax errors and suppresses the execution of
the job
TYPRUN = HOLD, holds the job in the input queue until the operator releases it.
USER specifies a RACF userid.
Eg.
//job1 JOB (182187, 167166), GATES, CLASS = A, REGION = 1920K,
//
TIME = 1350, MSGCLASS = A, MSGLEVEL = (1,1) , NOTIFY = &SYSUID,
//
RESTART = *, TYPRUN = HOLD
EXEC Statement
A job may consist of one or more job steps. A job step is a unit of work that is submitted
to the Operating system in the form of JCL statements.
EXEC statement is the first statement in each job step. Maximum of 255 of EXEC
statements can be specified within a single job step.
Syntax
//stepname EXEC PGM = program-name, keyword-parameters
//stepname EXEC PGM = *.refer back, keyword-parameters
//stepname EXEC
procedure, keyword-parameters

The stepname is the name you choose for the job step
The procedure names the cataloged procedure to use
The program names the program to execute
The referback names a previous DD statement describing the program to execute
The keyword parameter are the following
COND specifies condition for executing job steps if previous steps fail.
Each job step may pass a return code to the system when it reaches completion. The
COND parameter lets the execution of steps depend on return code from previous steps.
If any test satisfy, the system bypasses the step making the test.
// STEP1 EXEC PGM = ONE
//STEP 2 EXEC PGM = TWO
//STEP 3 EXEC PGM = THREE,COND = (4,GT,STEP1)
In the above example the system bypasses the step3 if 4 is greater than the return code
from the step1
The possible return code comparisons are
GT Greater than
LT Less than
NE not equal

LE Less than or equal to


EQ Equal
GE Greater than or equal to

PARM is used to supply information to the program as it executes


Syntax
PARM = values (a string from 1 to 100 character long)
Eg
//step1 EXEC PGM = PROGRAM!, PARM = PRINT
The string PRINT is supplied to the PROGRAM1 during execution.
ADDRSPC Parameter
This is to indicate the system that the job step is to use either virtual or real storage,
default is virtual
Syntax
ADDRSPC = VIRT
ADDRSPC = REAL
//step1 EXEC PGM = PROGRAM1, ADDRSPC = VIRT

DD statement
DD statements describe data sets. It is used to identify the source of input and placement
of output information. As a job executes the system performs device and space
allocations for each DD name specified. Each DD name should be unique within the job
step.
//ddname

operand
comments
<positional/
Keyword
Parameters>
The following rules must be adhered to when coding the statement

DD

DD statement must immediately follow the EXEC statement


A valid name must be assigned to each dataset used
A DD statement must exist for each dataset used.
Positional parameters may be coded in the operands field.

The following positional parameters may be coded

*
DATA
DUMMY

Keyword Parameters may also be coded in the operand field. The following are the
keyword parameters used:

DSN
DISP
UNIT
SPACE
DCB
VOLUME

DSN Parameters
The DSN Parameter is a keyword parameter on the DD statement. It can also be coded as
DSNAME. It is used to specify name of the dataset to the operating system
Syntax:
DSN=data-set-name

Non-Qualified
8

Qualified

DISP Parameter
The DISP is keyword parameterIt is used to instruct the system as to the current status of a dataset, and the steps
to be taken with dataset upon successful or unsuccessful execution of the job.
Syntax:
DISP= (status, normal-dispostion, abnormal-dispostion)
Rules for coding:
One or more of the sub parameters may be skipped. However, atleast one sub-parameter
must exist. The parenthesis can be omitted if only the status field is coded like this,
DISP = NEW
If normal disposition and/or abnormal disposition fields are coded and status is omitted
then a comma must be coded in its position, like this
DISP = (, CATLG, DELETE)
If the first and third sub-parameters are coded ,then a comma must be coded in the
location of the second parameter like this
DISP = (OLD, DELETE)
STATUS FIELD
MOD sub-parameter

It is used to modify sequential data sets


If the data set already exists, use of the MOD sub-parameter in the status field
results in the reader/writer of the device positioning itself just after the last record,
so that records can be added to it easily.
If the sequential data set does not exists, then the system replaces MOD with
NEW and create it.

SHR sub-parameter

Setting DISP to SHR is identical to setting it to OLD except when OLD gives
exclusive control of the data set to the user, whereas SHR allows multiple jobs to
read the same data set.

10

NORMAL DISPOSITION Field


The normal-disposition field in the DISP parameter is used to indicate what to do with the
data set upon normal termination of the job
DISP = (status, normal-disposition, abnormal-disposition) and the sub parameters can be
coded here are

DELETE
KEEP
CATLG
UNCATLG
PASS

ABNORMAL-DISPOSITION Field
The Abnormal-disposition field tells the system what to do with the data upon abnormal
termination of the job. This sub-parameter is required only if the abnormal disposition is
different from the normal disposition

DELETE
KEEP
UNCATLG
CATLG

CONCATENATING DATASETS
A dataset can be concatenated and perceived as one file by the operating systems
provided the RECFM, DEVICE, TYPE (pds, seqn) is same. Up to 255 sequential and 16
PDS can be concatenated together.
//STEP1 EXEC PGM = PGM1
//FILE1 DD DSN = FILE1A
//
DD DSN = FILE1B

11

DCB PARAMETER
It specifies data control block parameters. DCB parameters are used to supply
information to the system that allows it to manage the datasets that are created as jobs are
submitted. When a new dataset is created the following has to be specified,
Function
Specification of record format
Specification of record length
Specification of block size
Specification of buffers

Corresponding JCL sub-parameters Coded on the DCB


parameter
RECFM
LRECL
BLKSIZE
BUFNO

RECFM
Syntax
RECFM = F (fixed)
RECFM = FB (fixed block)
RECFM = V (Variable)
RECFM = VB (Variable Block)
RECFM = U (Undefined length)
SPACE PARAMETER
Space is an optional keyword parameter on the DD statement that is used to specify
storage requirements of datasets on direct access devices such as disks. Tapes do not
require in space parameter.
Syntax
CYL
TRK
Blksize
reclength
SPACE = ( ______________, (primary, secondary, directory))
The reclength, Blksize, TRK or CYL requests that space be allocated in units of number
of bytes per record, bytes per block, tracks or cylinders.
The primary is the number of units (records, blocks, tracks or cylinders) to allocate for
the primary allocation. The secondary is the number of units to allocate as the secondary
allocation if it exceeds the primary allocation.

12

Temporary Datasets
They are created during the execution of the job and then deleted subsequently after the
job completes. Temporary dataset can be created by
Omitting DSN parameter
//STEP1 EXEC PGM=ONE
//FILE 1 DD
//STEP2 EXEC PGM=TWO
//FILE2 DD *.STEP1.FILE1
Temporary dataset is created in step1 since DSN parameters are omitted. The system
assigns a unit name to dataset and any subsequent steps using the datasets must referback
to DD statement.
Using && sign
//STEP1 EXEC PGM=ONE
//FILE 1 DD DSN=&&TEMP, DISP = (NEW, PASS, DELETE)
//STEP2 EXEC PGM=TWO
//FILE2 DD DSN=&&TEMP, DISP = SHR
UNIT PARAMETER
Unit parameter specifies the I/O device. Unit request an I/O unit by hardware address,
device type or group name.
UNIT = address
UNIT = type (3390)
UNIT = group (SYSDA)
VOLUME PARAMETER
VOL parameter specifies the volume and provides volume information. The VOL
parameter is primarily used for tape datasets although it can be used with disks. To
request a specific volumes VOL = SER = volume is used
//A DD DSN = SAVE, DISP= (NEW, CATLG), UNIT = TAPE, VOL=SER=XT4321
If the tape XT4321 is not mounted, the system will request the operator to mount it.

13

INPUT STREAM DATASETS


An input data stream is the data that is entered at the time that the job is submitted. The
conventional DD name assigned to input data streams is SYSIN
Syntax
//SYSIN DD *
[Lines of data]
/*
//SYSIN DD * DATA
[Lines of data]
/*
DATA indicates data may contain special characters.
DELIMITER PARAMETER
If the data itself contains the /* in columns 1 and 2 which could occur if the data
consisted of JCL statements, code the DLM = cc parameter on the DD statement to
specify any two character as the delimiter. If the delimiter contains an ampersand or
apostrophe, code it as two consecutive characters.
DLM = && specifies the delimiter characters as &
//SYSIN DD *, DLM=ZZ
[Lines of data]
ZZ
OUTPUT STREAM DATASETS
The DD statement SYSOUT parameter routes output that is generated during the
execution of the job to an output device.
Syntax
//DDNAME DD SYSOUT = CLASS
//SYSPRINT DD SYSOUT = (A-Z, 0-9)
//SYSPRINT DD SYSOUT = * (same as MSGCLASS)

14

SYSUDUMP DD STATEMENT
It is used to obtain the dumps of various registers and variables in case of abnormal
termination of a job. Information of subroutines called within the job and the dataset
accessed is also provided.
STEP1 EXEC PGM = PGM1
SYSUDUMP DD SYSOUT = *
CATALOGED AND INSTREAM PROCEDURES
JCL statements that have potential use by several users are usually grouped together and
given a name are called Procedures. Procedures are executed by coding their names in
the EXEC statement.
//PROC1 PROC
//STEP1 EXEC PGM=ONE
//FILE 1 DD DSN= FILE1, DISP=SHR
//STEP2 EXEC PGM=TWO
//FILE 2 DD DSN= FILE2, DISP=SHR
//PEND
//JOB1 AE04, CHE GUEVARA
//BATCH EXEC PROC1
The two types of Procedures are 1.Cataloged Procedure and 2.Instream Procedure.
Cataloged Procedures are stored as members in partitioned datasets established by the
installation. For Cataloged Procedures, no PEND is required.
Instream Procedures are similar to Cataloged Procedures except that they are not the
member of partitioned datasets. They must end with PEND statement. They must be
coded immediately after the job statement and before the first EXEC statement, not more
than 15 instream procedures can be coded in a job.
//JOB1 AE04, FIDEL CASTRO
//INSTREAM PROC
//STEP1 EXEC PGM=ONE
//FILE 1 DD DSN= FILE1, DISP=SHR
//STEP2 EXEC PGM=TWO
//FILE 2 DD DSN= FILE2, DISP=SHR
// PEND
//STEP3 EXEC INSTREAM

15

Rules for Coding the Procedures


A procedure name can be 1-8 alphanumeric or national characters. The first character
must be an alphabet or national
No more that 255 job steps can be coded in a procedure.
The following JCL statements cannot be included within the procedures.

JOB
EXEC, under special circumstances, which are described below
DD * or DD DATA
JOBLIB DD
JES2 or JES3 control statements.

OVERRIDING PARAMETERS
Existing Parameters inside the PROC can be overridden as follows
//procstep.ddname DD modified_parameters
The modified parameters of the PROC will be active only for the duration of the job.
//PROC1 PROC
//STEP1 EXEC PGM=ONE
//FILE 1 DD DSN= FILE1, DISP=SHR
//STEP2 EXEC PGM=TWO
//FILE 2 DD DSN= FILE2, DISP=SHR
//PEND
To override file1 and file2, the following changes are made in the job.
//JOB1 AE04, ADOLF
//BATCH EXEC PROC1
//STEP1.FILE1 DD DSN=FILE1, DISP = OLD
//STEP2.FILE1 DD DSN = NEWFILE, DISP = SHR
//

16

SYMBOLIC PARAMETERS
Symbolic Parameters are used to override parameters on EXEC, DD and OUTPUT
statement. Symbolic parameters on DD statement is coded by preceding with a & that
will be assigned a value during the job execution.
//RUN PROC PROGRAM=ONE, UNIT=SYSDA
//GO EXEC PGM=&PROGRAM
//A DD UNIT=&UNIT, SPACE= (TRK, 20)
//JOB1 AE04, ADOLF
//BATCH EXEC RUN, UNIT=TEMP, PROGRAM=TWO
//
IF/THEN/ELSE/ENDIF STATEMENT CONSTRUCT
The IF/THEN/ELSE/ENDIF statement construct provides a simple means of selectively
executing job steps.
// IF (relational-expression) THEN
[Jcl statements to execute if the relational expression is true]
// ELSE
[Jcl statements to execute if the relational expression is false]
// ENDIF
Instead of Relational Expressions, the return codes of the previousp steps can also be
used as below
//IF (STEP1.RC GE 4 AND STEP1.RC LE 6) THEN
[Jcl statements to execute if the relational expression is true]
//ENDIF
Mnemonic Parameter
NOT
EQ
NE
GT
LT
GE
NL
LE
NG
AND
OR

Character Operator

=
=
>
<
>=
<
<=
>
&
|

Description
Logical not
Equal to
Not equal to
Greater than
Less than
Greater than
Not greater than. Same as GE
Less than or equal
Not greater than.Same as LE
Logical and
Logical or
17

Special DD Statements
JOBLIB
JOBLIB is the special DD statement placed next to the JOB statement which defines
a program library to search first when attempting to locate programs executed during
the job's life. More than one program library can be concatenated after the first one on
a joblib .If the system doesnot find the program in the named Library, it searches in
the SYS1.LINKLIB
//JOB1 AE04, ADOLF
//JOBLIB DD DSN=A1000.COMPLIB.LOAD,DISP=SHR
//
DD DSN=A1000.PRINTLIB.LOAD,DISP=SHR
STEPLIB
The STEPLIB statement is similar in form and function to the JOBLIB statement, is
placed after an EXEC statement and is effective only for that jobstep. STEPLIB provides
an alternative means of specifying a private library.
//JOB1 AE04, FIDEL
//STEP1 EXEC PGM=ONE
//STEPLIB DD DSN= A1000.COMPLIB.LOAD,DISP=SHR
//STEP2 EXEC PGM=TWO
// STEPLIB DD DSN= A1000.PRINTLIB.LOAD,DISP=SHR
//
If JOBLIB and STEPLIB statements are both included in a job, the STEPLIB statement
overrides the JOBLIB for the step.

18

IBM Utility Programs


IBM Utility Programs are the pre-written JCL utility programs used very often. Some of
these are:
IEBGENER copies sequential datasets.
//IEBGENR1
//STEP1
//SYSPRINT
//SYSUT1
//SYSUT2
//
//
//
//SYSIN
//
Source File
Destination File

JOB
EXEC
DD
DD
DD

DD

A123, BOND
PGM=IEBGENER
SYSOUT=A
DSN=COBOL.ORIGINAL, DISP=SHR
DSN=COBOL.DUPLICATE,
DISP=(NEW,CATLG,KEEP)
UNIT=SYSDA SPACE= (TRK, (20, 10), RLSE),
DCB=(RECFM=FB,LRECL=80, BLKSIZE=800)
DUMMY

: SYSUT1
: SYSUT2

IEBCOPY

Copies partitioned datasets


Compresses a PDS
Include members of PDS within Copy Transaction
Exclude members of PDS within Copy Transaction
//IEBCOPY1 JOB A123, BOND
//STEP1
EXEC PGM=IEBCOPY
//SYSPRINT DD
SYSOUT=A
//SYSUT1
DD
DSN=FILE1.ORIGINAL,DISP=SHR
//SYSUT2
DD
DSN=FILE2.DUPLICATE,
//
DISP=(NEW,CATLG,KEEP)
//
UNIT=SYSDA
//
SPACE=(TRK,(20,10),RLSE),
//
DCB=(RECFM=FB,LRECL=80,
//
BLKSIZE=800)
//SYSIN
DD
*
COPY INDD=SYSUT1,
OUTDD=SYSUT2
/*
//
Source File
Destination File

: INDD
: OUTDD
19

To compress a dataset, both the Source File and Destination File should be the same.
//IEBCOPY1 JOB A123, BOND
//STEP1
EXEC PGM=IEBCOPY
//SYSPRINT DD
SYSOUT=A
//SYSUT1
DD
DSN=FILE1.ORIGINAL, DISP=SHR
//SYSIN
DD
*
COPY INDD=SYSUT1,
OUTDD=SYSUT1
/*
//
Including members of PDS in a copy command
//IEBCOPY1 JOB A123, BOND
//STEP1
EXEC PGM=IEBCOPY
//SYSPRINT DD
SYSOUT=A
//SYSUT1
DD
DSN=FILE1.ORIGINAL, DISP=SHR
//SYSUT2
DD
DSN=FILE2.DUPLICATE,
//
DISP= (NEW, CATLG, KEEP)
//
UNIT=SYSDA
//
SPACE= (TRK,(20,10),RLSE),
//
DCB=(RECFM=FB,LRECL=80,
//
BLKSIZE=800)
//SYSIN
DD
*
COPY INDD=SYSUT1,
OUTDD=SYSUT2
SELECT MEMBER= (FILE1, FILE2, FILE3)
/*
//
Where FILE1, FILE2 and FILE3 are selected members of the PDS defined in SYSUT1.
Source
Destination

: Selected members of the INDD


: OUTDD

20

Excluding Members of PDS in COPY command


//IEBCOPY1 JOB A123, BOND
//STEP1
EXEC PGM=IEBCOPY
//SYSPRINT DD
SYSOUT=A
//SYSUT1
DD
DSN=FILE1.ORIGINAL, DISP=SHR
//SYSUT2
DD
DSN=FILE2.DUPLICATE,
//
DISP= (NEW, CATLG, KEEP)
//
UNIT=SYSDA
//
SPACE= (TRK,(20,10),RLSE),
//
DCB= (RECFM=FB, LRECL=80,
//
BLKSIZE=800)
//SYSIN
DD
*
COPY INDD=SYSUT1,
OUTDD=SYSUT2
EXCLUDE MEMBER=(FILE1,FILE2,FILE3)
/*
//
Where FILE1, FILE2 and FILE3 are excluded members of the PDS defined in SYSUT1.
Source
Destination

: Members of the INDD, except the excluded members


: OUTDD

IEFBR14

It is a null program that executes single statement which specifies the end of
program.
This program is used to code functions that are commonly available on the DD
statement such as the creation, deletion, and updating of datasets.
It can be used to check the syntax of JCL without affecting any datasets.

Eg1.
//UNCATLG JOB A123, BOND
//STEP1
EXEC PGM=IEFBR14
//DD1
DD
DSN=FILE1.ORIGINAL, DISP= (OLD, UNCATLG)
//

21

IEBCOMPR compares datasets.


To compare two sequential datasets
//IEBCMPR
//STEP1
//SYSPRINT
//SYSUT1
//SYSUT2
//
//SYSIN

JOB
EXEC
DD
DD
DD

A123, BOND
PGM=IEBCOMPR
SYSOUT=A
DSN=FILE1.ORIGINAL, DISP=SHR
DSN=FILE2.DUPLICATE,
DISP= SHR
DD
*
COMPARE TYPORG=PS

/*
//
To compare two partitioned datasets
//IEBCMPR
//STEP1
//SYSPRINT
//SYSUT1
//SYSUT2
//
//SYSIN

JOB
EXEC
DD
DD
DD

A123, BOND
PGM=IEBCOMPR
SYSOUT=A
DSN=FILE1.ORIGINAL, DISP=SHR
DSN=FILE2.DUPLICATE,
DISP= SHR
DD
*
COMPARE TYPORG=PO

/*
//
Some common utilities and their functions
Function
Copy Sequential files
Copy Partitioned Data sets
Catalog Data sets
Uncatalog Data sets
Rename Data sets
Compress partitioned Data sets
Include members of partitioned data sets
when implementing a copy command
Exclude members of partitioned data sets
when implementing a copy command
Compare sequential data sets
Compare partitioned data sets
Code function available on the DD
statement without executing a program
Create Generation Data Group

Corresponding Utility Name


IEBGENER
IEBCOPY
IEHPROGM
IEHPROGM
IEHPROGM
IEBCOPY
SELECT statement coded in the COPY
command of the IEBCOPY utility
EXCLUDE statement coded in the COPY
command of the IEBCOPY utility
IEBCOMPR with TYPORG=PS
IEBCOMPR with TYPORG=PO
IEFBR14
IEHPROGM
22

SORT/MERGE UTILITY
The sort function in the SORT utility takes records from an input file, sorts the records
and places them in an output file. The merge function of the SORT utility takes its input
from the sorted records of multiple files and combines them in to one sequential file.
JCL to SORT
//SORT1
JOB A123, LARA
//STEP1
EXEC PGM=SORT
//SYSOUT
DD SYSOUT=A
//SYSPRINT DD SYSOUT=A
//SORTIN
DD DSN=ADDRESS.BOOK1,
//
DISP=SHR
//SORTOUT DD DSN=ADDRESS.BOOK1,
//
DISP= (NEW, CATLG, DELETE),
//
UNIT=UNIT1
//
SPACE= (CYL, (2,1), RLSE),
//
DCB= (RECFM=FB, LRECL=80, BLKSIZE=800)
//SORTWK01 DD UNIT=SYSDA,
//
SPACE= (CYL, (20, 10), RLSE)
//SYIN DD *
SORT FIELDS = (2, 5, A, CH)
/*
//
Source
Destination
Temporary Workspace

: SORTIN
: SORTOUT
: SORTWK01

In the above JCL, Sort utility is instructed to sort address.book1 starting at byte 2 of each
record. Only five bytes are to be sorted, starting at byte 2. The file is to be sorted in
ascending order.
Syntax
//SYIN
DD *
SORT FIELDS = (Starting position, length, sort sequence, format)
/*

23

JCL to MERGE
//MERGE1
JOB A123, LARA
//STEP1
EXEC PGM=SORT
//SYSOUT
DD SYSOUT=A
//SYSPRINT DD SYSOUT=A
//SORTIN01 DD DSN=ADDRESS.BOOK1,
//
DISP=SHR
// SORTIN02 DD DSN=ADDRESS.BOOK2,
//
DISP=SHR
//OUTFILE DD DSN=ADDRESS.BOOK,
//
DISP= (NEW, CATLG, DELETE),
//
UNIT=UNIT1
//
SPACE= (CYL, (2,1), RLSE),
//
DCB= (RECFM=FB, LRECL=80, BLKSIZE=800)
//SYIN
DD *
MERGE FIELDS = (1, 5, A, CH)
/*
//
Source1
Source2
Destination
Temporary Workspace

: SORTIN01
: SORTIN02
: OUTFILE
: SORTWK01

Syntax
//SYIN
DD *
MERGE FIELDS = (Starting position, length, merge sequence, format)
/*
Both the Source1 and Source2 should have been sorted before merging them.
INCLUDE statement
The INCLUDE statement is coded in the SORT program to select only specific records
which meet specified criteria in the sort.
Syntax:
INCLUDE COND= (expression)

24

//SORT1
JOB A123, LARA
//STEP1
EXEC PGM=SORT
//SYSOUT
DD SYSOUT=A
//SYSPRINT DD SYSOUT=A
//SORTIN
DD DSN=ADDRESS.BOOK1,
//
DISP=SHR
//SORTOUT DD DSN=ADDRESS.BOOK1,
//
DISP= (NEW, CATLG, DELETE),
//
UNIT=UNIT1
//
SPACE= (CYL, (2,1), RLSE),
//
DCB= (RECFM=FB, LRECL=80, BLKSIZE=800)
//SORTWK01 DD UNIT=SYSDA,
//
SPACE= (CYL, (20, 10), RLSE)
//SYIN
DD *
INCLUDE COND = (2, 5, A, CH,EQ,CBATCH)
/*
//
The specific criteria are the following for the above example, starting at byte number 2
pick up the next five bytes and compare them to the character constant BATCH. If
there is a match, include the record in the sort.
OMIT statement
The OMIT statement is coded in the SORT program to exclude specific records which
meet specified criteria in the sort.
//SORT1
JOB A123, LARA
//STEP1
EXEC PGM=SORT
//SYSOUT
DD SYSOUT=A
//SYSPRINT DD SYSOUT=A
//SORTIN
DD DSN=ADDRESS.BOOK1,
//
DISP=SHR
//SORTOUT DD DSN=ADDRESS.BOOK1,
//
DISP= (NEW, CATLG, DELETE),
//
UNIT=UNIT1
//
SPACE= (CYL, (2,1), RLSE),
//
DCB= (RECFM=FB, LRECL=80, BLKSIZE=800)
//SORTWK01 DD UNIT=SYSDA,
//
SPACE= (CYL, (20, 10), RLSE)
//SYIN
DD *
OMIT COND = (2, 5, A, CH,EQ,CBATCH)
/*
//

25

The specific criteria are the following for the above example, starting at byte number 2
pick up the next five bytes and compare them to the character constant BATCH. If
there is a match, omit the record in the sort.
Additional control statements on the SORT program
Control Statement
DEBUG
END
INCLUDE
INREC
OUTREC
OPTION
SUM
OMIT

Function
Used to debug the execution of the SORT
program
Must be coded on the SYSIN statement, if
input is to be discontinued before the actual
end of a file
Used to specify the inclusion of specific
records only.
Used to reformat records before they are
processed by the SORT program
Used to specify the format of records before
they are written
Used to override installation-defined sorting
defaults
Used to sum up equal control fields to
produce a single output record after sorting
Used to exclude records from the sort

26

IDCAMS Utility
The IDCAMS utility is the primary utility used by the Access Method Services (AMS)
programs to process VSAM and non-VSAM data sets. The IDCAMS utility can be
executed for the following functions on VSAM data sets.

Define them
Load records in to them
Print them

DEFINING A KSDS DATA SET


//KSDS
JOB (A123), A. KALAM
//STEP1
EXEC PGM = IDCAMS
//SYSPRINT DD SYSOUT = A
//SYSIN
DD *
DEFINE CLUSTER
(
NAME (VSAM1.KSDS.CLUSTER)
VOLUMES (CICT00)
CYLINDERS (3, 1)
CONTROLINTERVALSIZE (4096)
FREESPACE (10, 20)
KEYS (5, 1)
RECORDSIZE (80, 80)
)
DATA
(
NAME (VSAM.KSDS.DATA)
)
INDEX
(
NAME (VSAM1.KSDS.INDEX)
CONTROLINTERVALSIZE (2048)
)
CATALOG (VSAM.USER.PRIVATE)
/*
//

27

DEFINING A ENTRY SEQUENCED DATA SET (ESDS)


//ESDS
JOB (A123), A. KALAM
//STEP1
EXEC PGM = IDCAMS
//SYSPRINT DD SYSOUT = A
//SYSIN
DD *
DEFINE CLUSTER
(
NAME (VSAM1.ESDS.CLUSTER)
VOLUMES (CICT00)
CYLINDERS (3, 1)
CONTROLINTERVALSIZE (4096)
RECORDSIZE (80, 80)
NONINDEXED
)
DATA
(
NAME (VSAM2.ESDS.DATA)
)
CATALOG (VSAM.USER.PRIVATE)
/*
//

DEFINE A RELATIVE RECORD DATA SET (RRDS)


//RRDS
JOB (A123), A. KALAM
//STEP1
EXEC PGM = IDCAMS
//SYSPRINT DD SYSOUT = A
//SYSIN
DD *
DEFINE CLUSTER
(
NAME (VSAM1.RRDS.CLUSTER)
VOLUMES (CICT00)
CYLINDERS (3, 1)
CONTROLINTERVALSIZE (4096)
RECORDSIZE (80, 80)
NUMBERED
)
DATA
(
NAME (VSAM2.RRDS.DATA)
)
CATALOG (VSAM.USER.PRIVATE)
/*
//

28

REPRO Command
The REPRO command reads records from an input data set and copies them to an output
data set. It may be used to load records in the VSAM, Physical sequential are member of
Partitioned Data set.
In order for the REPRO command to work properly, the following must hold true
The input file and output file must be a KSDS, ESDS, RRDS, physical sequential are
member of Partitioned Data set.
The input file must be sorted on the prime key using the SORT utility.
Syntax
REPRO INFILE (ddname of input file)
OUTFILE (ddname of output file)
Or
REPRO INDATASET (input data set name)
OUTDATASET (output data set name)

LOADING A VSAM DATA SET


//KSDS
JOB (A123), A. KALAM
//STEP1
EXEC PGM = IDCAMS
//SYSPRINT DD SYSOUT = A
//DDIN
DD DSN = FILE1.TEST, DISP = SHR
//DDOUT
DD DSN = VSAM1.KSDS.CLUSTER, DISP = OLD
//SYSIN
DD *
REPRO
INFILE (DDIN)
OUTFILE (DDOUT)
/*
//

29

Options available on REPRO Command


Option
Skip selected records from the input
file
Copy select number of records from the
input file to the output file.

Copy records between two key (KSDS


only)
Copy records between two addresses
(ESDS only)
Copy records between two relative
record numbers of RRDS files

Corresponding Parameter and Syntax


SKIP (n)
n is the number of records from the start of the
file which are to be skipped in the copy
transaction
COUNT (n)
n is the number of records that are to be copied
COUNT starts the copy from the current, if
SKIP is coded before COUNT, the number of
records copied will start right after the number
of records skipped.
FROMKEY(n1) TOKEY (n2)
n1 and n2 specify the two keys
FROMADDRESS(n1)
TOADDRESS(n2)
n1 and n2 specify the two addresses
FROMNUMBER(n1)
TONUMBER(n2)
N1 and n2 specify the two relative record
numbers

PRINTING VSAM DATASET


The Print command can be coded on the SYSIN statement of the IDCAMS Utility to
print both VSAM and non-VSAM data sets
Syntax
PRINT INFILE (ddname of dataset)
Or
PRINT INDATASET (data set name)
//KSDSPRNT JOB (A123), A. KALAM
//STEP1
EXEC PGM = IDCAMS
//SYSPRINT DD SYSOUT = A
//SYSIN
DD *
PRINT
INDATASET (VSAM1.KSDS.CLUSTER)
CHAR
/*
//

30

GENERATION DATA GROUPS


A generation data groups (GDG) is a group of chronologically or functionally related data
sets. They are processed periodically, often by adding a new generation, retaining
previous generation and perhaps discarding the oldest generation. The advantage of GDG
is that all the data sets have same name, the system keeps track of adding and deleting the
successful generation which doesnt require to change the JCL between runs.
CREATING THE GDG BASE ENTRY
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN
DD *
DEFINE GDG
(NAME (A100.TAX.STATE)
[Names the generation data groups]
LIMIT (5) [Maximum number of generations to keep (1 to 255)]
EMPTY [Optional. Tells the system to uncatalog all the generation datasets when the limit is
reached. Omit EMPTY or code NOEMPTY to uncatalog only the oldest dataset.]
OWNER (userid) [Optional. Gives the userid of the owner of the data set]
SCRATCH [Optional. Scratches a data set when it is uncataloged. Omit SCRATCH or code
NOSCRATCH to keep the data set when it is uncataloged.]
FOR (days) [Optional. Tell how many days to retain the data set. Alternatively, you can code TO
(yyyymmdd) to specify the last date of retention.]
)
/*
//

31

CREATING THE MODEL DATA SET LABEL


//STEP1 EXEC PGM = IEFBR14
//BUILDIT DD DSN = A1000. TAX. STATE, DISP = (NEW, KEEP),
//
VOL = SER = PACK12, RECFM = FB, LRECL = 80,
//
SPACE = (TRK, 0)
//

CREATING A GENERATION DATA SET


//STEP1
//FILE1
//
//
//
//

EXEC
DD

PGM=GDG1
DSN=A1000.TAX.STATE (+1), DISP=(NEW,CATLG)
UNIT=SYSDA
SPACE= (CYL, (2,1), RLSE),
DCB= (RECFM=FB, LRECL=80, BLKSIZE=800)

32

Vous aimerez peut-être aussi