Professional Documents
Culture Documents
JCL
JCL
--------------------
-- 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)
---
---
* 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
-----------------------------------------------------------------------------------
--------------------
-- GDG
-----------------------------------------------------------------------------------
-------------
-----------------------------------------------------------------------------------
--------------------
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
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))
---
* 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' '
* 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
* 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.
* 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