JCL (2).doc

52
JCL Job Control Language 1

Transcript of JCL (2).doc

Page 1: JCL (2).doc

JCL

Job Control Language

1

Page 2: JCL (2).doc

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 OPERATION OPERANDS COMMENTS | | | |name field operation field operand field 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.

2

Page 3: JCL (2).doc

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 lineThe 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.

3

Page 4: JCL (2).doc

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 parametersPositional parameters are so called because of the position in which they appear. The positional parameters in the JOB statement are:

Accounting Information Programmer’s 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 ‘A123, dept1’//Job1 JOB (, dept1)

Programmer Name parameter follows the job accounting information parameter.

//Job1 JOB ‘A123, dept1’ MANI//Job1 JOB , Kamal

4

Page 5: JCL (2).doc

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 = minutesTIME = (minutes, seconds)TIME = nolimit or 1440TIME = maximum, which is 357,912 mins

MSGCLASS – specifies the job scheduler output classMSGLEVEL – specifies whether to list all the JCL statementsMSGLEVEL = (jcl, allocation)

JCL Meaning0 Print only the job statement1 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

2 Print only the JCL in the input stream and any JES control statements

Allocations Meaning

0 Print only JCL messages but no allocations, JES or operator messages unless the job abnormally terminates.

1 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 job’s priority in the input queue. The priority may range from 0-15 in JES2 and 0-14 in JES3.

5

Page 6: JCL (2).doc

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 NoNC- no checkpoint No YesNR- No automatic restart No NoRNC – Restart and no checkpoint Yes Yes___________________________________________________________________

RESTART – submits a job for a restartRESTART = stepnameRESTART = stepname.procstepRESTART = * ( 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 jobTYPRUN = 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

6

Page 7: JCL (2).doc

The stepname is the name you choose for the job stepThe procedure names the cataloged procedure to useThe program names the program to executeThe referback names a previous DD statement describing the program to executeThe 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 LE Less than or equal to LT Less than EQ EqualNE not 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

SyntaxADDRSPC = VIRTADDRSPC = REAL

//step1 EXEC PGM = PROGRAM1, ADDRSPC = VIRT

7

Page 8: JCL (2).doc

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 DD operand comments <positional/ Keyword Parameters>The following rules must be adhered to when coding the statement

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 Qualified

8

Page 9: JCL (2).doc

DISP Parameter

The DISP is keyword parameter-It 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 = NEWIf 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.

9

Page 10: JCL (2).doc

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

10

Page 11: JCL (2).doc

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 Corresponding JCL sub-parameters Coded on the DCB parameter

Specification of record format RECFMSpecification of record length LRECL

Specification of block size BLKSIZESpecification of buffers 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.

11

Page 12: JCL (2).doc

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.FILE1Temporary 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 = addressUNIT = 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.

12

Page 13: JCL (2).doc

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)

13

Page 14: JCL (2).doc

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 = PGM1SYSUDUMP 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

14

Page 15: JCL (2).doc

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//

15

Page 16: JCL (2).doc

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 Character Operator DescriptionNOT ¬ Logical notEQ = Equal toNE ¬= Not equal toGT > Greater thanLT < Less thanGE >= Greater thanNL ¬< Not greater than. Same as GELE <= Less than or equalNG ¬> Not greater than.Same as LE

AND & Logical andOR | Logical or

16

Page 17: JCL (2).doc

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.

17

Page 18: JCL (2).doc

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 JOB A123, BOND//STEP1 EXEC PGM=IEBGENER//SYSPRINT DD SYSOUT=A//SYSUT1 DD DSN=COBOL.ORIGINAL, DISP=SHR//SYSUT2 DD DSN=COBOL.DUPLICATE,// DISP=(NEW,CATLG,KEEP)// UNIT=SYSDA SPACE= (TRK, (20, 10), RLSE),// DCB=(RECFM=FB,LRECL=80, BLKSIZE=800)//SYSIN DD DUMMY//

Source File : SYSUT1Destination File : 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 : INDDDestination File : OUTDD

18

Page 19: JCL (2).doc

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 : Selected members of the INDDDestination : OUTDD

19

Page 20: JCL (2).doc

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 : Members of the INDD, except the excluded membersDestination : 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)//

20

Page 21: JCL (2).doc

IEBCOMPR compares datasets.

To compare two sequential datasets

//IEBCMPR JOB A123, BOND//STEP1 EXEC PGM=IEBCOMPR//SYSPRINT DD SYSOUT=A//SYSUT1 DD DSN=FILE1.ORIGINAL, DISP=SHR//SYSUT2 DD DSN=FILE2.DUPLICATE,// DISP= SHR//SYSIN DD *

COMPARE TYPORG=PS/*//

To compare two partitioned datasets

//IEBCMPR JOB A123, BOND//STEP1 EXEC PGM=IEBCOMPR//SYSPRINT DD SYSOUT=A//SYSUT1 DD DSN=FILE1.ORIGINAL, DISP=SHR//SYSUT2 DD DSN=FILE2.DUPLICATE,// DISP= SHR//SYSIN DD *

COMPARE TYPORG=PO/*//

Some common utilities and their functions

Function Corresponding Utility NameCopy Sequential files IEBGENERCopy Partitioned Data sets IEBCOPYCatalog Data sets IEHPROGMUncatalog Data sets IEHPROGMRename Data sets IEHPROGMCompress partitioned Data sets IEBCOPYInclude members of partitioned data sets when implementing a copy command

SELECT statement coded in the COPY command of the IEBCOPY utility

Exclude members of partitioned data sets when implementing a copy command

EXCLUDE statement coded in the COPY command of the IEBCOPY utility

Compare sequential data sets IEBCOMPR with TYPORG=PS Compare partitioned data sets IEBCOMPR with TYPORG=POCode function available on the DD statement without executing a program

IEFBR14

Create Generation Data Group IEHPROGM

21

Page 22: JCL (2).doc

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 : SORTINDestination : SORTOUTTemporary Workspace : 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)/*

22

Page 23: JCL (2).doc

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 : SORTIN01Source2 : SORTIN02Destination : OUTFILETemporary Workspace : 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)

23

Page 24: JCL (2).doc

//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,C’BATCH’)/*//

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,C’BATCH’)/*//

24

Page 25: JCL (2).doc

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 FunctionDEBUG Used to debug the execution of the SORT

programEND Must be coded on the SYSIN statement, if

input is to be discontinued before the actual end of a file

INCLUDE Used to specify the inclusion of specific records only.

INREC Used to reformat records before they are processed by the SORT program

OUTREC Used to specify the format of records before they are written

OPTION Used to override installation-defined sorting defaults

SUM Used to sum up equal control fields to produce a single output record after sorting

OMIT Used to exclude records from the sort

25

Page 26: JCL (2).doc

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)

/*//

26

Page 27: JCL (2).doc

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)

/*//

27

Page 28: JCL (2).doc

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)/*//

28

Page 29: JCL (2).doc

Options available on REPRO Command

Option Corresponding Parameter and SyntaxSkip selected records from the input file

SKIP (n)n is the number of records from the start of the file which are to be skipped in the copy transaction

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

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.

Copy records between two key (KSDS only)

FROMKEY(n1) TOKEY (n2)n1 and n2 specify the two keys

Copy records between two addresses (ESDS only)

FROMADDRESS(n1)TOADDRESS(n2)n1 and n2 specify the two addresses

Copy records between two relative record numbers of RRDS files

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)OrPRINT 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/*//

29

Page 30: JCL (2).doc

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 doesn’t 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.]

)/*//

30

Page 31: JCL (2).doc

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 EXEC PGM=GDG1//FILE1 DD DSN=A1000.TAX.STATE (+1), DISP=(NEW,CATLG)// UNIT=SYSDA// SPACE= (CYL, (2,1), RLSE),// DCB= (RECFM=FB, LRECL=80, BLKSIZE=800)//

31