Job Control Notes
Job Control Notes
Job Control Notes
--------------------
-- JCL
-----------------------------------------------------------------------------------
-------------
-----------------------------------------------------------------------------------
--------------------
---
* 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
* 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
* 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
---
* 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
---
---
---
* 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))
---
* REPRO INFILE(in-ddname)
OUTFILE(out-ddname)
* ALTER MY.VSAM.KSDSFILE
[ADDVOLUMES(2)]
[FREESPACE(6 6)]
[KEYS(10 2)]
-----------------------------------------------------------------------------------
--------------------
-- DFSORT
-----------------------------------------------------------------------------------
----------
-----------------------------------------------------------------------------------
--------------------
* Skip records
SORT FIELDS=COPY,STOPAFT=n,SKIPREC=m
* Remove duplicate
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=NONE
* Override data
OPTION COPY
INREC OVERLAY=(1:C'ABC')
* 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' '
* 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
-----------------------------------------------------------------------------------
-----------
-----------------------------------------------------------------------------------
--------------------
* 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 /*.
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