Job Control Notes

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 7

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

--------------------
-- JCL
-----------------------------------------------------------------------------------
-------------
-----------------------------------------------------------------------------------
--------------------

* 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

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

You might also like