You are on page 1of 9

-----------------------------------------------------------------------------------

--------------------
-- JCL
-----------------------------------------------------------------------------------
-------------
-----------------------------------------------------------------------------------
--------------------
* JOB Statement
Positional Parameter -
Accounting Parameter - Person or group to which the CPU time is owed
Programmer's Name - Person who is in charge of the JCL
Keyword Parameter -
CLASS=0 to 9/ A to Z - Based on the time duration and the number of
resources required by the job, companies assign different job classes
MSGCLASS=CLASS - Specify the output destination for the system and
Job messages when the job is complete
MSGLEVEL=(ST,MSG) - Type of the message to be written to output
ST -> 0(Job statements only), 1(JCL and symbolic param expanded),
2(input JCL only)
MSG -> 0(Messages upon abnormal job completion), 1(Messages
irrespective of job completion)
PRTY=0 to 15 - To set priority within a class
TIME=(mm, ss) - To ensure job to complete within requested time,
TIME=1440 is unlimited time.
REGION=nK/nM - Address spaces required to run a step within the
job
NOTIFY="userID"/&SYSUID - Sends success or failure messages to specified user
TYPRUN=SCAN/HOLD - SCAN checks the syntax without executing, HOLD puts job
on HOLD
ADDRSPC, USER, PASSWORD, COND, RESTART

* EXEC Statement
Positional Parameter -
PGM
PROC
Keyword Parameter -
PARM - Used to provide parametrized data to the program(Value has to be
given within quotes)
ACCT - (Value in EXEC statement will override JOB statement)
COND - To control job step execution based on return code of previous steps
TIME
REGION - (Value in JOB statement overrides)
ADDRSPC - Default: VIRT - To specify whether the job step require VIRT or
REAL storage - (value in JOB statement overrides)

* DD Statement
Positional Parameter -
DATA (or *) - * is used for instream data, DATA is used to pass JCL
statements stored in a member
DUMMY
DYNAM
Keyword Parameter -
DSN - (Total length can be 44 bytes and each node can be 8 byte) (DSN=&&TEMP
or just &&TEMP for temp dataset)
(If a temporary dataset created by a job step is to be used in the next
job step, then it is referenced as DSN=*.stepname.ddname. This is called Backward
Referencing.)
DISP=(Status, normal-disp, abnormal-disp)
(default - NEW,DELETE,DELETE or OLD,KEEP,KEEP)
Status - NEW, OLD, SHR, MOD
normal-disp - CATLG, UNCATLG, DELETE, KEEP and PASS
abnormal-disp - CATLG, UNCATLG, DELETE and KEEP
DCB=(BLKSIZE=0,DSORG=PS/PO,RECFM=,LRECL=)
SPACE=(Unit, (pri, sec, dir), RLSE)
Unit can be CYL, TRK, BLKSIZE
UNIT=DASD/SYSDA/TEMPDA - Specifies the type of device on which the dataset is
stored
VOL=SER=(v1,v2) - Specifies the vol number on the device
SYSOUT=* - To direct data to output device based on CLASS, here class is * is
same as JOB statement
Ex.
DSN=MYFILE.SAMPLE.DS,
DISP=(NEW,CATLG,DELETE),
DCB=(BLKSIZE=0,DSORG=PS,RECFM=FB,LRECL=80),
SPACE=(CYL,(50,50),RLSE)

---

* BASE lbraries - JCLLIB, JOBLIB, STEPLIB, INCLUDE statement


ex. // JCLLIB ORDER=(DNS1, DSN2)
ex. // INCLUDE MEMBER=member-name - is a member containing set of JCL
statements - JOB and PROC statements can not be coded - nesting can be done 15
levels

* PROCEDURE/PROC - set of JCL statements grouped together to perform a specific


function.
SYS1.PROCLIB - system proclib, IEBUPDATE is an utility used to create and save PROC
into system library

* // SET DSN1=SAMPLE.DSN - is used to initialize any symbolic parameters in


the job; should coded first before initailizing any symbolic elsewhere

* Return codes can be between 0 and 4095

---

* COND in JOB statment - RC checked for previous step if condition matched then the
current step and following steps bypassed
COND in EXEC statement - RC checked for previous step if matched then ONLY
current step is bypassed
COND=(RC, Logical-Operator)
COND=(RC, Logical-Operator, Step-name)
COND=EVEN - Step executed even if any of the previous step ABENDS, COND=((RC,Lo-
Op, St-na),EVEN) - step executed even any previous steps abend but cond should not
be true
COND=ONLY - Step executed ONLY when any previous step ABENDS, COND=((RC,Lo-Op,
St-na),ONLY) - step executed only when any step ABENDS and cond is not met

* RESTART=STEP01.PRC1.PRC1STP1 - Added in job statement and submitted to restart


the job from PRC1STP1 step of proc PRC1 at STEP1 job step

* RD=RC, NRC, NR, NC - Added in EXEC statement for automatic restart

* IF-THEN-ENDIF ex.
//IF1 IF (RC EQ 0) THEN - RC of all previous steps are checked,
if any one is not having RC 00 then ELSE part is executed
// ELSE
// ENDIF

//IF1 IF (STEP1.RC = 0 & STEP2.RC = 0) THEN


// ELSE
// ENDIF

//IF2 IF (STEP1.RUN) THEN


// ENDIF

//IF3 IF (STEP1.!ABEND) THEN


// ENDIF

//IF4 IF (STEP2.PROC1.PROC1STEP1.RC = 0) THEN


// ENDIF

* Setting checkpoint
If CHKPT=EOV is added in DD DSN, and SYSCKEOV DD statement is added after EXEC
Then a check point is written at end of each volume

//CHKSAMP JOB CLASS=6,NOTIFY=&SYSUID


//*
//STP01 EXEC PGM=MYCOBB
//SYSCKEOV DD DSN=SAMPLE.CHK,DISP=MOD
//IN1 DD DSN=SAMPLE.IN,DISP=SHR
//OUT1 DD DSN=SAMPLE.OUT,DISP=(,CATLG,CATLG)
// CHKPT=EOV,LRECL=80,RECFM=FB

---

* TEMP DSN ex. - DSN=&&FILE1, DISP=(, KEEP)

* OVERRIDE DSN ex. - IF there are multiple steps in proc and proc step name not
mentioned then only fist step DSN is overridden.
PROC - PROC1
//PRC001 EXEC PGM=PGM1
//INFIL DD DSN=TEST.IN.F001,DISP=SHR
.
//PRC002 EXEC PGM=PGM2
//INFIL DD DSN=TEST.IN.F002,DISP=SHR
JOB -
//STEP1 EXEC PROC1
//INFIL DD DSN=TST.IN.DB.FILE,DISP=SHR

---

* Job log catalog -


MSGCLASS=Y will store log in Joblog Management and Retrieval, which can be
downloaded to PS file using XDC command
SYSOUT/SYSPRINT DD DSN=JOBLOG.DSN, DISP=SHR will store joblog except JESMSGLOG

---

* Passing Data to COBOL -


DD DSN - using file - data read using READ
DD * - using SYSIN - data read using ACCEPT
PARM=' ' - using parm - data read in LINKAGE SECTION using linkage variable

---
* IEHMOVE - Copy PS
* IEBCOPY - Copy, Merge, compress, back-up or restore PDS
* IEBGENER - Copy from SYSUT1 to SYSUT2
* IEFBR14 - Used to delete PS or gen or model of gdg
* IDCAMS - Create GDG and VSAM
* IEHCOMPR - Compare PS files
* IKJEFT01 - Is simply a IBM program/utility that allow you to execute
command

-----------------------------------------------------------------------------------
--------------------
-- GDG
-----------------------------------------------------------------------------------
-------------
-----------------------------------------------------------------------------------
--------------------

* DEFINE GDG ex.

DEFINE GDG(NAME(MYDATA.SAMPLE.GDG) -
LIMIT(7) -
NOEMPTY -
SCRATCH)
NOEMPTY uncatalogs only oldest gen when lim reached, EMPTY will uncatalogs all
gen
SCRATCH will physically deletes the gen and NOSCRATCH will will only uncatalogs

* ALTER GDD ex.


ALTER MYDATA.SAMPLE.GDG -
LIMIT(15)
* DELETE GDG ex.
DELETE (MYDATA.SAMPLE.GDG) GDG FORCE/PURGE

FORCE will delete GDG base and Gens only when retension period has expired
PURGE will delete GDG base and Gens even if retention period of GDG not expired

-----------------------------------------------------------------------------------
--------------------
-- VSAM
-----------------------------------------------------------------------------------
------------
-----------------------------------------------------------------------------------
--------------------

* KSDS VSAM
DEFINE CLUSTER (NAME(MY.VSAM.KSDSFILE) -
INDEXED -
RECSZ(80 80) -
TRACKS(1,1) -
KEYS(5 0) -
CISZ(4096) -
FREESPACE(3 3) ) -
DATA (NAME(MY.VSAM.KSDSFILE.DATA)) -
INDEX (NAME(MY.VSAM.KSDSFILE.INDEX))

* ESDS VSAM (Records stored in fiexd length slots, when a rec deleted slot will be
empty and can be reused)
DEFINE CLUSTER (NAME(MY.VSAM.ESDSFILE) -
NONINDEXED -
RECSZ(80 80) -
TRACKS(1,1) -
CISZ(4096) -
FREESPACE(3 3) ) -
DATA (NAME(MY.VSAM.ESDSFILE.DATA))

* RRDS VSAM (Relative Byte Address - for 80 byte file - 1st rec is 0, 2nd is 80,
3rd is 160..)
DEFINE CLUSTER (NAME(MY.VSAM.RRDSFILE) -
NUMBERED -
RECSZ(80 80) -
TRACKS(1,1) -
CISZ(4096) -
FREESPACE(3 3) ) -
DATA (NAME(MY.VSAM.RRDSFILE.DATA))

* LDS VSAM (Byte-stream data set, used in DB2 not in application)


DEFINE CLUSTER (NAME(MY.VSAM.LDSFILE) -
LINEAR -
TRACKS(1,1) -
CISZ(4096) -
DATA (NAME(MY.VSAM.LDSFILE.DATA))

---

* LISTCAT ENTRY(MY.VSAM.KSDSFILE) ALL

* REPRO INFILE(in-ddname)
OUTFILE(out-ddname)

* ALTER MY.VSAM.KSDSFILE
[ADDVOLUMES(2)]
[FREESPACE(6 6)]
[KEYS(10 2)]

* DELETE SAMPLE.VSAM.FILE CLUSER

* EXAMINE - to check structural integrity of KSDS,


* VERIFY - to check and fix VSAMs which not closed properly

-----------------------------------------------------------------------------------
--------------------
-- DFSORT
-----------------------------------------------------------------------------------
----------
-----------------------------------------------------------------------------------
--------------------

* Skip records
SORT FIELDS=COPY,STOPAFT=n,SKIPREC=m

* Include and Omit


SORT FIELDS=COPY
INCLUDE COND=(1,6,CH,EQ,C'HEADER')
OMIT COND=(1,6,CH,EQ,C'TRAILR')

* Remove duplicate
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=NONE

* Override data
OPTION COPY
INREC OVERLAY=(1:C'ABC')

* Add sequence number


OPTION COPY
BUILD=(1:1,80,81:SEQNUM,3,ZD,START=100,INCR=2)

* Find Replace
OPTION COPY
OUTREC FINDREP=(IN=C'A',OUT=C'B')

* Parse
INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=5),
%02=(ENDBEFR=C',',FIXLEN=5),
%03=(FIXLEN=5))
SORT FIELDS=COPY
BUILD=(%01,X,%02,X,%03)

* Change case
SORT FIELDS=COPY
OUTREC OVERLAY=(1,20,TRAN=LTOU)

* Change VB to FB
SORT FIELDS=COPY
OUTFIL VTOF,BUILD=(5,80),VLFILL=C' '

* Change FB to VB
SORT FIELDS=COPY
OUTFIL FTOV,BUILD=(1,80),VLTRIM=C' '

* Justify and Squeeze


SORT FIELDS=COPY
OUTREC
FIELDS=(1,20,JFY=(SHIFT=LEFT,PREBLANK=C',./',MID=C'-',LEAD=C'<',TRAIL=C'>'),21,60,S
QZ=(SHIFT=LEFT,PREBLANK=C',./',MID=C'-',LEAD=C'<',TRAIL=C'>'))

* Add condition
OPTION COPY
OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),OVERLAY=(81:C'HEADER')),
IFTHEN=(WHEN=NONE,OVERLAY=(81:C'DETAIL')) - THIS is ELSE
cond

* Header and Trailer


SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=(1:C'HDR',10:X'020110131C'),
TRAILER1=(1:C'TRL',TOT=(10,9,PD,TO=PD,LENGTH=9))

* Sort numeric stored as char


SORT FIELDS=(1,10,UFF,A)

* SORT JOIN
//MAIN DD *
1000
1001
1003
1005
//LOOKUP DD *
1000
1002
1003
.
//SYSIN DD *
JOINKEYS F1=MAIN,FIELDS=(1,4,A)
JOINKEYS F2=LOOKUP,FIELDS=(1,4,A)
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(?,F1:1,4,F2:1,4)
OPTION COPY
OUTFIL FNAMES=MATCH,INCLUDE=(1,1,CH,EQ,C'B'),BUILD=(1:2,4)

OUTFIL FNAMES=NOMATCH1,INCLUDE=(1,1,CH,EQ,C'1'),BUILD=(1:2,4)
OUTFIL FNAMES=NOMATCH2,INCLUDE=(1,1,CH,EQ,C'2'),BUILD=(1:6,4)

-----------------------------------------------------------------------------------
--------------------
-- Q & A
-----------------------------------------------------------------------------------
-----------
-----------------------------------------------------------------------------------
--------------------

* Maximum of 255 EXEC steps can be coded in a job


* JMR - Joblog Management and Retrieval
* MVS - Multiple Virtual Storage
* GDG - Generation Data Group - Collection of historically related non-vsam
datasets that are arranged in chronological order
* DASD - Direct Access Storage Device, SYSDA - System Direct Access
* ISPF - Interactive System Productivity Facility

* How to restore deleted gen in GDG?


Either this
List out thebackups taken by MVS
TSO HLIST BCDS DSN ('Dataset Name')
Recover the required backup
TSO HRECOVER 'Original Dataset Name' GEN(005) 'NEWNAME'
OR this
TSO HRECOVER 'Deleted Dataset Name'

* How can you check if file is empty without opening it. Ans- we can use file as
input in IDCAMS and if job failes with MAXCC 0004 then it is empty
//H010550 JOB 0000,'TEST',CLASS=X,MSGCLASS=T,NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS
//INFIL01 DD DSN=SAMPLE.TEST.EMPTY.F001,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(INFIL01) COUNT(1)
/*
or use below ICETOOL
//H010550 JOB 0000,'TEST',CLASS=X,MSGCLASS=T,NOTIFY=&SYSUID
//STEP1 EXEC PGM=ICETOOL
//INFIL01 DD DSN=SAMPLE.TEST.EMPTY.F001,DISP=SHR
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
COUNT FROM(INFIL01) EMPTY RC8
/*

* IEBEDIT sample
//STEP1 EXEC PGM=IEBEDIT
//SYSUT1 DD DSN=INSET,UNIT=disk,DISP=(OLD,KEEP)
//SYSUT2 DD SYSOUT=(*,INTRDR) --> INTRDR passes
the control to mvs to run the steps selected in
SYSIN, but if just want to copy steps into new
dataset then
that can be done
too
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
EDIT START=JOBA,TYPE=POSITION,STEPNAME=STEP6 --> to
include all the steps in JOBA, after STEP6
EDIT START=JOBB,TYPE=INCLUDE,STEPNAME=(STEP6-STEP8) --> to
include all steps from STEP6 till STEP8
EDIT START=JOBC,TYPE=EXCLUDE,STEPNAME=STEP10 --> to
exclude STEP10 and run remaining
/*

* How to pass JCL statements in SYSIN? (ensure JCL does not end due to /* present
as part of data in SYSIN)
Example -
//SYSIN DD *,DLM=!!
//STEP1 EXEC PGM=&pgmname
//FOUT DD SYSOUT=*
//SYSIN DD *
ABC
123
/*
!!
Here the PROC, EXEC and DD cards are not executed, they are part of the SYSIN
data.
The default value for DLM is /*, and you must use something else if there is (or
if you suspect there might be) a /* within the data.

* What is the difference between SYSIN DD * and SYSIN DD DATA?


Nothing really, except that the input to SYSIN DD * ends at the next JCL
statement, at the end of the job stream, or at the end delimiter /*.
If you code SYSIN DD DATA, then you must include the end delimiter /*.

* JCL submitting another JCL


//STEP010 EXEC PGM=IEBGENER
//*
//SYSUT1 DD DSN=PERM.TLB.JCL(INTRDRJ2),DISP=SHR
//SYSUT2 DD SYSOUT=(,INTRDR)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY

//STEPXXXX EXEC PGM=IKJEFT01


//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
SUBMIT 'MY.JCL(MEMBER)'
/*
And if JCL is in VSAM then use IDCAMS and REPRO to JES Internal Reader(INTRDR)

* Emptying Dataset
//STEP01 EXEC PGM=IEBGENER
//*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//*
//SYSUT2 DD DSN=xxx.xxx.xx,DISP=SHR
//SYSUT1 DD DUMMY
//*
//SYSIN DD DUMMY

* DD DUMMY or DSN=NULLFILE, what is the significance


To test the program without any actual file, when used and program is run
operating system send end of file status to program

* Can we concatinate PS and PDS?


No we can not. But we can concatinate PS with PS upto 255 files and PDS with PDS
upto 16 files

* Hard recall and soft recall of datasets?

You might also like