Jcl
Introduction to JCL Jcl coding sheet JOB Statement Exec statement DD Statement Concatenating Datasets Referback in JCL Special DD statements Utility Programs Utility program IEBGENER Utility programs IEBCOPY and IEBCOMPR DFSort DFSort reformat dataset DFSort INCLUDE OMIT COND Procedures generation data group (GDG) JCL quick study JCL Interview questionsDD Statement
It is the Data Definition(DD) statement for the JCL which provides information about the dataset and to specify the input, output resources needed for that JOB. A maximum of 3273 DD statements can be coded per job STEP.
//DDNAME DD ,
The DD statement is used to
- Describe a dataset and to specify the input and output resources needed for the dataset.
- Map a logical file used by the processing program to a physical dataset.
Rules to follow for DD statement:
- Each ddname should be unique within the job step.
- The ddname must begin in column 3.
- The ddname is 1 through 8 alphanumeric or national ($,#,@) characters.
- The ddname must be followed by atleast one blank.
- The ddname is omitted if it defines a dataset that is to be concatenated to the dataset of the preceding DD statement.
DDName:
It is a mandatory field. If omitted, the dataset is concatenated with the one defined in the previous DD statement.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//INPUT DD DSN=PROGPUB.FLATFILE.INPUT,DISP=SHR
//OUTPUT DD DSN=PROGPUB.FLATFILE.OUTPUT,DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=80,SPACE=(TRK,(2,5))
Positional Parameters:
The most widely used positional parameters are explained here
*(asterisk):
Use of the *(asterisk) parameter to begin an instream data set. It is also used to pass data to the program like the PARM parameter in EXEC statement. The '/*' indicated the end of instream data. When the instream data is passed using '*', the preceding lines should not contain any '//' in the column 1 and 2.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD *
INSTREAM DATA
/*
When using an utility program like SORT, the in-stream data is used to pass the SORT CARD parameters.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=DFSORT
//DD1 DD *
SORTFIELDS=(CONDITION)
/*
DATA:
DATA parameter is functionally same as '*' operand except the instream data can contain '//' in column 1 and 2.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD DD DATA
//INSTREAM DATA
/*
Incase if the instream data has the value '/*' which is also an indicator to define the end of instream data, we can define a custom delimiter as shown in the example
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROG1
//DD1 DD DATA,DLM='$$'
/*INSTREAM DATA
$$
DUMMY or NULLFILE:
The DUMMY or NULLFILE keyword is used to assign a dummy status to a dataset so any input-output operation on the dummy dataset is bypassed.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD DUMMY
Keyword Parameters:
There are wide range of keyword parameter. The most common are explained below,
DSN:
This parameter is used to define the permanent or temporary dataset name. Dataset name is maximum 44 characters long with a period after 8 characters or less. Maximum length is inclusive of periods. Temporary datasets are used a work area for the duration of the job.
Syntax is,
DSN=DATASET NAME
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD DSN=PROGPUB.FLATFILE.INPUT
To define a temporary dataset, specify a name starting with && followed by 1 to 6 characters or without specifying DSN.
DSN=&&TEMP
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD DSN=&&TEMPDT
DISP:
This parameter is used to specify the status of the dataset and to specify what to do with the dataset after termination (normal or abnormal) of the step or the job. The disposition status specifies the existence of a dataset at the start of the STEP. Syntax is
DISP=(Status,Normal-End,Abnormal-End)
Status:
NEW | Specifies that the dataset is new and does not exists when the step begins. |
OLD | Specifies that the dataset exists when the step begins. Gains exclusive control of the dataset for the duration of the step and safeguards against concurrent access to the dataset. The data in the dataset is overwritten. |
MOD | Extends the dataset if the dataset already exists or creates a new one if it is not existing. |
SHR | Specifies that the dataset can be shared (read access) with other jobs. |
Normal-End:
This disposition parameter specifies what to do with the dataset after a normal termination. It takes one of the values,
CATLG, UNCATLG, PASS, KEEP, DELETE.
Abnormal-End:
This disposition parameter specifies what to do with the dataset after a normal termination. It takes one of the values,
CATLG, UNCATLG, KEEP, DELETE.
CATLG | Specifies that the OS must record information about the dataset like its Name, its Unit, Volume identifier in the system catalog when it is newly created or, update the entry if existing. You cannot catalog a temporary dataset. |
KEEP | Specifies that newly created datasets need not have a catalog entry but just be retained on the volume. |
UNCATLG | Specifies that the OS removes all entries from the catalog, but retain the dataset on the volume. |
PASS | Specifies to the OS that subsequent steps will access the dataset and that the dataset need not be cataloged (if new) or the catalog entry need not be updated (if existing). Can PASS PS and PDS but not VSAM datasets. Common to code DISP=(NEW,PASS) when you create a temporary dataset. |
DELETE | Specfies to the OS that the dataset must be uncataloged and deleted from the system when the step ends. |
To create a new member in an existing PDS, code DISP=OLD or SHR, not NEW, since DISP refers to the partitioned dataset as a whole not to the individual member. The PDS directory is updated about the new member.
For VSAM datasets, the disposition should be coded as DISP=OLD or DISP=SHR.
UNIT:
This parameter should be specified for new and existing uncatalogued datasets. Syntax is
UNIT=(Hardware Address or Devce model number or symbolic group name or virtual I/O)
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=AMSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD DSN=PROGPUB.FLATFILE.NEW,DISP=(NEW,CATLG,DELETE)
// UNIT=SYSDA
VOL:
This parameter goes along with the UNIT parameter. The VOL parameter specifies the name and number of the volume of the UNIT specified. Volume is the name of a specific UNIT. One unit can have multiple volumes.
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD DSN=PROGPUB.FLATFILE.NEW,DISP=(NEW,CATLG,DELETE)
// UNIT=(3390,2),VOL=SER=(VOL01,VOL02)
SYSOUT:
This parameter is specified to redirect the data to output device based on the SYSOUT class specified. Syntax is
SYSOUT=CLASS
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=A,MSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//DD1 DD DSN=PROGPUB.FLATFILE.NEW,DISP=(NEW,CATLG,DELETE)
// UNIT=SYSDA
//DD2 DD SYSOUT=*
SPACE:
This parameter is used to specify the amount of space required by the new dataset in DASD. A smallest unit of space in mainframe is one track and group of tracks are called Cylinders. One or more contiguous tracks or cylinders allocated to a dataset is called EXTENT Syntax is
SPACE=(UNIT OF SPACE,(PRIMARY,SECONDARY,DIRECTORY)RLSE,CONTIG,ROUND)
UNIT OF SPACE |
Specified in Tracks (TRK), Cylinders (CYL), block length (BLKLGTH), record length (RECLGTH). |
PRIMARY | Specifies the amount of primary space required in terms of the space unit (tracks/cylinders/number of data blocks). One volume must have enough space for the primary quantity. If a particular volume is requester and it does not have enough space available for the request, the job step is terminated. |
SECONDARY | Secondary quantity of units if primary is exceeded but allocated only when the dataset expands. |
DIRECTORY | Number of directory blocks to be allocated. A directory block can hold up to 5 members. |
RLSE | Releases the unused space requested. Release occurs only if dataset is open for output and the last operation was a write. |
CONTIG | To allocate contiguous primary space. |
ROUND | Allocation by block length rounded to integral cylinders. |
//*JCL with SPACE=(TRK,(2,5))
//PROGPUB JOB NOTIFY=&SYSUID,MSGCLASS=AMSGLEVEL=2
//STEP1 EXEC PGM=PROGRAM1
//INPUT DD DSN=PROGPUB.FLATFILE.INPUT,DISP=SHR
//OUTPUT DD DSN=PROGPUB.FLATFILE.OUTPUT,DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=80,SPACE=(TRK,(2,5))
For this example, the space allocation can be calculated as
2 primary tracks + (5*15) secondary tracks = 77 tracks
//* Space allocation requested in blocksize
//OUTPUT DD DSN=PROGPUB.FLATFILE.OUTPUT,DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=80,SPACE=(800,(2,5))
For this example, the space allocation can be calculated as
2 blocks each holding 800 bytes. So, total primary blocks 1600 bytes.
5*15*800 bytes are allocated for secondary storage.
Examples
SPACE=(CYL,10)
SPACE=(1024,75)
SPACE=(TRK,(50,10,5))
SPACE=(TRK,(100),RLSE)
SPACE=(CYL,(10,,10),,CONTIG)
DCB:
This parameter is called Data Control Block and It defines the dataset characteristics. Syntax is
DCB=(RECFM,LRECL,BLKSIZE,DSORG)
RECFM:
The RECFM parameter specifies the record format of the dataset. It takes the value as listed below
F | Fixed length records. |
FB | Fixed length records and records are blocked. |
V | Variable length record. |
VB | Variable length and records are blocked. |
U | Undefined length. |
LRECL:
This parameter defines the length of the logical records. For a fixed length records, the dataset contains all of the same length and hence LRECL specifies the actual length of the data.
For variable length records, the length of the records vary from an average to a maximum. So, the LRECL = longest data-bytes length +4 bytes. The 4 bytes are called Record Descriptor Word (RDW) is pre-penned to each record and indicates the actual length of the record in its first 2 bytes.
For Undefined format, the parameter is coded as LRECL=0.
BLKSIZE:
It defines the size of a block of record. Blocking of records improves processing speed. For fixed length blocked record the value for blocksize is specified in multiples of LRECL. For variable length blocked record, the value for blocksize is specified in multiples of LRECL plus 4 bytes.
//* Space allocation requested in blocksize
//OUTPUT DD DSN=PROGPUB.FLATFILE.OUTPUT,DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,SPACE=(800,(2,5))
DSORG:
This parameter specifies the organization of the data set as physical sequential (PS), partitioned (PO), or direct (DA).