The DD (Data Definition) statement is one of the most important JCL statements. It defines a dataset to be used by a program during a job step and specifies the resource allocation parameters, physical attributes, and logical attributes of the dataset.
1//ddname DD parameter1,parameter2,...
Each DD statement begins with a DDname, which associates the statement with specific program input/output operations. The DDname must match the name used in the program's file definition.
The DD statement follows a specific format with several fields.
1. Identifier Field (columns 1-2)
2. Name Field (columns 3-10)
3. Operation Field (column 12+)
4. Operand Field
DDnames serve several important purposes:
Some DDnames have special meanings:
Special DDname | Purpose |
---|---|
JOBLIB | Library containing programs for the entire job |
STEPLIB | Library containing programs for a specific step |
SYSOUT | System output for print or online viewing |
SYSUDUMP | System dump in case of abnormal termination |
SYSIN | Input stream (inline data) for many programs |
The most essential DD statement parameters define what dataset to use and how to access it.
Specifies the name of the dataset to be processed:
Format:
1234DSN=dataset.name DSN=&&temporary DSN=*.stepname.ddname DSN=dataset.name(member)
Examples:
1234//DD1 DD DSN=SYS1.PROCLIB,DISP=SHR //DD2 DD DSN=&&TEMP,DISP=(NEW,PASS) //DD3 DD DSN=*.STEP1.DD1,DISP=SHR //DD4 DD DSN=MY.PDS(MEMBER1),DISP=SHR
Controls dataset status, what happens after normal completion, and what happens after abnormal termination:
Format:
1234DISP=(status,normal,abnormal) DISP=status DISP=(status,normal) DISP=OLD | SHR | NEW | MOD
Status Value | Meaning |
---|---|
OLD | Dataset exists and needs exclusive use |
SHR | Dataset exists and can be shared with other jobs |
NEW | Dataset doesn't exist yet and will be created |
MOD | If dataset exists, adds to end; if not, creates it |
Normal/Abnormal Values | Meaning |
---|---|
DELETE | Remove the dataset |
KEEP | Retain the dataset (don't catalog) |
CATLG | Retain and catalog the dataset |
UNCATLG | Retain but remove from catalog |
PASS | Pass to later steps (normal only) |
Examples:
1234//DD1 DD DSN=MYFILE,DISP=SHR //DD2 DD DSN=NEWFILE,DISP=(NEW,CATLG,DELETE) //DD3 DD DSN=MASTER,DISP=(OLD,KEEP) //DD4 DD DSN=TEMPFILE,DISP=(MOD,DELETE)
UNIT specifies the device type, and VOL specifies volume information:
Format:
12UNIT=device-type | UNIT=device-name | UNIT=group-name VOL=SER=volume-serial | VOL=(,,,n) | VOL=REF=*.stepname.ddname
Examples:
1234//DD1 DD DSN=FILE1,DISP=OLD,UNIT=SYSDA,VOL=SER=VOL001 //DD2 DD DSN=FILE2,DISP=NEW,UNIT=TAPE,VOL=(,,,2) //DD3 DD DSN=FILE3,DISP=NEW,UNIT=3390,VOL=SER=SYS001 //DD4 DD DSN=FILE4,DISP=NEW,VOL=REF=*.STEP1.DD1
These parameters specify the physical characteristics of a dataset and allocate space.
Specifies dataset characteristics:
Format:
1DCB=(attribute1=value1,attribute2=value2,...)
Common Attributes | Description | Values |
---|---|---|
RECFM | Record format | F, FB, V, VB, U, etc. |
LRECL | Logical record length | Numeric value |
BLKSIZE | Block size | Numeric value |
DSORG | Dataset organization | PS, PO, DA, etc. |
Example:
123//DD1 DD DSN=NEWFILE,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120,DSORG=PS)
Allocates space for a new dataset on direct access storage:
Format:
1234SPACE=(unit,(primary,secondary,directory),RLSE,CONTIG,ROUND) SPACE=(TRK,(10,5)) SPACE=(CYL,(5,2,10)) SPACE=(blksize,(100,50))
Examples:
12345678// Basic allocation in tracks //DD1 DD SPACE=(TRK,(20,10)) // Cylinder allocation with directory blocks for PDS //DD2 DD SPACE=(CYL,(5,2,10)) // Block allocation with release of unused space //DD3 DD SPACE=(6160,(500,100),RLSE)
Several special DD statement formats serve specific purposes.
Directs output to a system output device (printer or online output):
Format:
123SYSOUT=class SYSOUT=(class,program,form) SYSOUT=*
Examples:
1234//PRINT1 DD SYSOUT=A //PRINT2 DD SYSOUT=* //PRINT3 DD SYSOUT=(A,,SPEC) //REPORT DD SYSOUT=A,DEST=REMOTE1
Creates a dummy dataset that's recognized by the program but doesn't actually exist:
Format:
12DUMMY DUMMY,other-parameters
Examples:
12//INPUT DD DUMMY //CHECK DD DUMMY,DCB=(RECFM=FB,LRECL=80)
Includes data directly in the JCL stream:
Format:
123456* data lines /* * ,DLM=delimiter data lines delimiter
Example:
1234567891011//SYSIN DD * SORT FIELDS=(1,10,CH,A) /* //CARDS DD *,DCB=BLKSIZE=80 CARD DATA LINE 1 CARD DATA LINE 2 /* //DATA DD *,DLM=## THIS IS SPECIAL DATA WITH A CUSTOM DELIMITER ##
Combines multiple datasets to be processed as a single dataset:
Format:
123//ddname DD DSN=dataset1,DISP=SHR // DD DSN=dataset2,DISP=SHR // DD DSN=dataset3,DISP=SHR
Example:
123//LIBRARY DD DSN=SYS1.MACLIB,DISP=SHR // DD DSN=SYS1.AMODGEN,DISP=SHR // DD DSN=USER.MACLIB,DISP=SHR
Here are some complete examples of DD statements for different purposes.
12345//OUTPUT DD DSN=USER.DATA.FILE, // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, // SPACE=(TRK,(50,20),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120)
Creates a new fixed-block dataset with 80-byte records. It allocates 50 tracks initially with 20 tracks of secondary space. The dataset will be cataloged if the step is successful or deleted if the step fails.
12345//OUTPDS DD DSN=USER.SOURCE.COBOL, // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, // SPACE=(TRK,(100,50,20)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120,DSORG=PO)
Creates a new partitioned dataset (library) with 20 directory blocks. The DSORG=PO parameter indicates a partitioned organization, and the third value in the SPACE parameter allocates directory space.
12//INPUT DD DSN=PROD.MASTER.FILE,DISP=SHR //BACKUP DD DSN=PROD.MASTER.BACKUP,DISP=OLD
The first statement accesses an existing dataset in shared mode, allowing other jobs to use it simultaneously. The second statement accesses an existing dataset in exclusive mode, preventing other jobs from using it.
123456//OLDGEN DD DSN=USER.PAYROLL.DATA(0),DISP=SHR //NEWGEN DD DSN=USER.PAYROLL.DATA(+1), // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, // SPACE=(CYL,(5,2)), // DCB=(RECFM=FB,LRECL=200,BLKSIZE=6000)
Accesses the current generation (0) of a GDG and creates a new generation (+1). Generation data groups are useful for maintaining multiple versions of related datasets, such as daily, weekly, or monthly backups.
12345//TEMPDD DD DSN=&&TEMP, // DISP=(NEW,PASS), // UNIT=SYSDA, // SPACE=(TRK,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)
Creates a temporary dataset using the double ampersand notation. The dataset is passed to subsequent steps (DISP=PASS) but will be automatically deleted at the end of the job.
12345//JOBLIB DD DSN=USER.LOADLIB,DISP=SHR // DD DSN=TEAM.LOADLIB,DISP=SHR //STEP1 EXEC PGM=SPECIAL //STEPLIB DD DSN=SPECIAL.LOADLIB,DISP=SHR
JOBLIB defines libraries to search for programs used throughout the job. STEPLIB defines libraries for a specific step, overriding JOBLIB for that step.