DD Statement


Before proceding with DD statement, refer JCL Coding sheet topic.

  • DD (Data Definition) statement is used to specify input and output files for a job step. It defines a dataset or file name, attributes, and location and assigns it a DDname to be referenced within the job step.
  • The DDname used in the program should be the same as the DDname in the DD statement.
  • DD statement in the job contains the full name of the dataset. DDnames should be unique in a single step and may not be unique in the entire JCL.
  • The maximum number of DD statements in a single step is 3273.

Syntax -

//DDname DD parameters [comments]

DDname -


DDname is the name assigned to the dataset or file being defined. DDname is optional.

Rules -

  • The DDname should start from the 3rd column.
  • DDname can be 1-8 characters.
  • DDname is a combination of alphanumeric and special characters (@,#, and $).

DD Keyword -


  • DD is the keyword used to code the DD statement in JCL.
  • A step can have a maximum of 3273 files.

Frequently used parameters -


DSNAME

DSN (DataSet Name) parameter is used to specify the name of a dataset. The dataset can be any type, such as a flat file, a partitioned dataset, a VSAM dataset, or a tape dataset.

Syntax -

//DDname DD DSN=datasetname
  • datasetname - specifies the dataset name.
Example - For PS file.
//DD01   DD  DSN=MTH.DATA.PSFILE,DISP=SHR

DISP

DISP parameter specifies how a dataset is to be handled in the job or job step. DISP parameter also tells the system what to do with the dataset after the job step execution.

Syntax -

DISP=(status[,normal-termination-action][,abnormal-termination-action])
  • STATUS - It is used to specify the state of the dataset and the valid values are -
    • NEW - Specifies that a new dataset is to be created.
    • SHR - Specifies the dataset already exists before the step and used only for reading.
    • OLD - Specifies that the dataset already exists and used with exclusive control on the dataset.
    • MOD - Specifies dataset exists before this step and used to append the data to the dataset.
  • Normal-termination-action - It specifies the system what action needs to be taken on the dataset when the job step executed successfully.
    Applicable actions are - KEEP, CATLG, UNCATLG, PASS, DELETE.
  • Abnormal-termination-action - It tells the system what action needs to be performed on the dataset when the step execution is unsuccessful (terminates abnormally).
    Applicable actions are - KEEP, CATLG, UNCATLG, DELETE.

Actions -

  • KEEP - Specifies that the dataset is to be retained on the volume.
  • CATLG - Specifies that the dataset is to be cataloged if it is not already cataloged.
  • UNCATLG - Specifies that the dataset is to be uncataloged.
  • PASS - Specifies that the dataset should pass and used in the next steps.
  • DELETE - Specifies that the dataset is to be deleted.
Example - Create new PS file.
//STEP10 EXEC PGM=IEFBR14
//DD1  DD DSN=MATEPK.IEFBR14.PSFILE, 
//        DISP=(NEW,CATLG,DELETE),
//        SPACE=(TRK,(3,2),RLSE), 
//        UNIT=SYSDA,VOLUME=SER=DEVHD4,
//        DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

SYSOUT

It is used to specify the destination of system output, such as job log, operator messages, and program output.

Syntax -

SYSOUT={msg-class|*|output-class|output-device|(,)}
  • output-class - specifies the output class that is defined during JES initialization.
  • * - specifies to use the output class in the MSGCLASS parameter on the JOB statement.
  • (,) - specifies a null class. Coding SYSOUT=(,) nullifies the SYSOUT class.
  • output-device - specifies output device name.
Example - Writing output on default printer (SPOOL).
//DD01    DD SYSOUT=*

SPACE

It is used to specify the amount of disk space required for creating a new dataset and the allocation should request on direct access volume (DSAD).

Syntax -

SPACE=({Allocation-parameter,} (primary-qty[,second-qty][,directory]) [,RLSE][,CONTIG or MXIG or ALX][,ROUND])
  • Allocation-parameter - specifies the measurement unit for memory allocation. The valid values are - TRK, CYL, BLKLGTH, RECLGTH.
  • primary-qty - specifies the amount of primary space needed for the dataset.
  • secondary-qty - specifies the amount of additional space required for the dataset.
  • Directory - specifies amount of space in bytes that is reserved for directory blocks.
  • RLSE - releases the memory allocated to the dataset when the dataset is closed.
  • CONTIG - specifies that the memory allocated should be contiguous and applies to primary memory allocation.
  • MXIG - specifies that the memory allocation should be done on the largest contiguous memory location.
  • ALX - specifies to the system that the memory to the dataset allocation is to up to 5 largest available locations on the same volume.
Example - Allocate PS with 3 TRKs primary and 2 TRKs seconday memory.
//MATEPKI  JOB (123),'MTH',NOTIFY=&SYSUID
//*
//STEP10 EXEC PGM=IEFBR14
//DD1  DD DSN=MATEPK.IEFBR14.PSFILE,
//        DISP=(NEW,CATLG,DELETE),
//        SPACE=(TRK,(3,2),RLSE),
//        UNIT=SYSDA,VOLUME=SER=DEVHD4,
//        DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

UNIT

UNIT parameter is used to specify the system to place the dataset on a specific device or a group of devices.

Syntax -

UNIT=([ddd] [,unit-count] [,DEFER])
[device-type]
[group-name ]
  • device-number - Specifies device by a 3-digit or 4-digit hexadecimal number.
  • device-type - Specifies a device by its generic name, which is an IBM-supplied name.
  • group-name - Specifies a group of devices by a symbolic name.
  • unit-count - Specifies the number of devices from 1 through 59.
  • DEFER - Specifies the system to assign the dataset to device(s).
Example - Defines a dataset on DASD(Direct Access Storage Device - SYSDA).
//MATEPKI  JOB (123),'MTH',NOTIFY=&SYSUID
//*
//STEP10 EXEC PGM=IEFBR14
//NEWPS  DD DSN=MTH.DATA.PSFILE,
//          DISP=(NEW,CATLG,DELETE),
//          UNIT=SYSDA,
//          SPACE=(TRK,(3,2),RLSE),
//          DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

DSORG

DSORG parameter specifies the organization of the dataset. The value of this parameter determines how the data in the dataset is arranged and accessed.

Syntax -

DSORG=PS|PO|DA
  • PS - specifies the dataset organization is sequential.
  • PO - specifies the dataset organization is partitioned (PDS).
  • DA - specifies the dataset organization is direct access.
Example - Define PDS.
//NEWPDS DD DSN=MTH.DATA.PSFILE,
//          DISP=(NEW,CATLG,DELETE),
//          UNIT=SYSDA,
//          SPACE=(TRK,(3,2,2),RLSE),
//          DCB=(DSORG=PO,RECFM=FB,LRECL=80,BLKSIZE=800)

RECFM

RECFM parameter is used to define the record format for the new dataset. It specifies the structure of the records in the dataset, such as their length (fixed or variable) and storage structure (blocked or unblocked).

Syntax -

DCB=(RECFM=V|VB|F|FB|U)
  • F - Specifies the records are fixed length.
  • V - Specifies the records are variable length.
  • B - Specifies the records are blocked.
  • U - Specifies the records are undefined length.
Example - Define a PS file with fixed-length records 80 bytes.
//NEWPS DD DSN=MTH.DATA.PSFILE,
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(TRK,(3,2),RLSE),
//         DCB=(DSORG=PS,RECFM=F,LRECL=80,BLKSIZE=800)

LRECL

LRECL (Logical Record Length) parameter is used to specify the record length for new datasets during their creation.

Syntax -

DCB=(LRECL=record_length)
  • record_length - Specifies the physical record length in bytes. The value is 1 to 32,767 for non-VSAM datasets.
Example - Defining an PS with LRECL of 95 bytes.
//NEWPS DD DSN=MTH.DATA.PSFILE,
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(TRK,(3,2,2),RLSE),
//         DCB=(DSORG=PS,RECFM=FB,LRECL=95,BLKSIZE=950)

BLKSIZE

BLKSIZE parameter is used to specify the size of the physical blocks used when reading or writing a dataset.

Syntax -

BLKSIZE={value|valueK|valueM|valueG}
  • Value - specifies the storage in bytes.
  • ValueK - specifies the storage in Kilobytes.
  • ValueM - specifies the storage in Megabytes.
  • ValueG - specify the storage in Gigabytes.
Note! The value should be multiples of 4 and maximum BLKSIZE is 2GB.
Example - Define a PS file with fixed-length records with block size of 1600 bytes.
//NEWPS DD DSN=MTH.DATA.PSFILE,
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(TRK,(3,2),RLSE),
//         DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

DCB

DCB (Data Control Block) is a parameter that is used to define how a dataset is to be processed. The DCB parameter provides information about the organization, record format, record length, block size, and other dataset attributes.

Syntax -

DCB=(subparameter[,subparameter]...)

Frequently used parameters -

Some mostly used DCB parameters and their meanings include -

  • BLKSIZE - Specifies the block size of the dataset.
  • DSORG - Specifies the organization of the dataset. Valid values include PS (physical sequential), PO (partitioned organization), and PDS (partitioned dataset).
  • KEYLEN - Specifies the key length of the dataset.
  • LRECL - Specifies the record length of the dataset.
  • RECFM - Specifies the record format of the dataset. Valid values include F (fixed length), V (variable length), and U (undefined).
  • DSNTYPE - Specifies the type of dataset. Valid values include LIBRARY (for a PDS), and BASIC or EXTENDED (for a PS dataset).
Example - Define a PS file with fixed-length record of 80 and a block size of 800 bytes.
//NEWPS DD DSN=MTH.DATA.PSFILE,
//         DISP=(NEW,CATLG,DELETE),
//         UNIT=SYSDA,
//         SPACE=(TRK,(3,2),RLSE),
//         DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

VOLUME

VOLUME parameter is used to specify the name of the DASD (Direct Access Storage Device) volume on which a dataset is stored or is to be stored.

Syntax -

{VOL}=([PRIVATE][,RETAIN][,volume-sequence-number][,volume-count] {VOL}=[SER=(serial-number[,serial-number]...)]
  • PRIVATE - requests a private volume.
  • volume-sequence-number - specifies the unique number to identify the volume. Values are 1 - 255.
  • volume-count - specifies the maximum number of volumes.
  • SER=serial-number - specifies the volume serial number.
Example - Defines a PDS on single volume.
//MATEPKP  JOB (123),'MTH',CLASS=A,
//             MSGCLASS=A,MSGLEVEL=(1,1), 
//             NOTIFY=&SYSUID
//*
//STEP01 EXEC PGM=IEFBR14                
//DD1   DD DSN=MATEPK.TEST.PDS,         
//         DISP=(NEW,CATLG,DELETE),     
//         SPACE=(TRK,(10,10,10),RLSE), 
//         UNIT=SYSDA,VOLUME=SER=DEVHD4,
//         DCB=(DSORG=PO,RECFM=FB,LRECL=80,BLKSIZE=800)

LIKE

LIKE parameter allows you to create a new dataset with the attributes of an existing dataset.

Syntax -

LIKE=old-dataset-name
  • old-dataset-name - Specifies the model dataset full name.
Example - Creating a new dataset with the attributes of an existing dataset
//MATEPKP  JOB (123),'MTH',CLASS=A,
//             MSGCLASS=A,MSGLEVEL=(1,1), 
//             NOTIFY=&SYSUID
//*
//STEP01   EXEC PGM=PROG1 
//INPUT    DD DSN=MTH.OLD.DATASET,DISP=SHR
//OUTPUT   DD DSN=MTH.NEW.DATASET,
//            DISP=(NEW,CATLG,DELETE),
//            LIKE=INPUT

* or DATA - Specifies the starting of instream dataset.

DUMMY - Specifies no physical dataset required to run the step.

Rarely used parameters -


Note! Click on the parameter name to go through the detailed information about it.
Keyword ParameterPurpose
RECORG Specifies the record organization
DSNTYPE Specifies the type of the dataset
DEST Sends the sysout dataset to specified destination
EXPDT Specifies the expiration date for the dataset
KEYLEN Specifies the length of the key in the dataset
OUTLIM Specifies the logical records limit in the dataset
RETPD Specifies the retention period of the dataset
DYNAM DYNAM parameter to provide the compatibility with previous system.
OUTPUTAssociates with one or more output datasets
LABELSpecifies the information about the dataset label

Comment -


Comment used to make a note of the current statement. The comment field follows the parameter field and should have a blank after the parameter field.

Examples -


Scenario1 - Define a PS file with fixed-length records with block size of 1600 bytes.

//STEP01 EXEC PGM=SAMPLE
//INPUT1  DD DSN=MTH.INPUT.FILE1,DISP=SHR
//OUTPUT  DD DSN=MTH.DATA.PSFILE,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(TRK,(3,2),RLSE),
//           DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=1600)

Scenario2 - Two files as input.

//STEP01 EXEC PGM=SAMPLE
//INPUT1 DD DSN=MTH.INPUT.FILE1,DISP=SHR
//       DD DSN=MTH.INPUT.FILE2,DISP=SHR