MainframeMaster

JCL Tutorial

DD Statement

Progress0 of 0 lessons

DD Statement Purpose

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.

Primary Functions of the DD Statement

  • Identify datasets by assigning them a name (DDname)
  • Define the dataset's physical location on storage media
  • Specify dataset characteristics such as record format, length, and organization
  • Establish access methods and buffer requirements
  • Control dataset disposition (new, old, shared, etc.)
  • Allocate space for new datasets
  • Designate special processing options

Basic DD Statement Format

jcl
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.

DD Statement Format

The DD statement follows a specific format with several fields.

DD Statement Fields

1. Identifier Field (columns 1-2)

  • Must contain // for all JCL statements

2. Name Field (columns 3-10)

  • Contains the DDname (1-8 characters)
  • First character must be alphabetic (A-Z) or national (@, #, $)
  • Remaining characters can be alphanumeric (A-Z, 0-9) or national
  • Must be unique within the job step
  • Should match the file name used in the program
  • Some DDnames have special meaning (STEPLIB, JOBLIB, etc.)

3. Operation Field (column 12+)

  • Contains DD to identify this as a DD statement

4. Operand Field

  • Various dataset parameters separated by commas
  • Can span multiple lines using continuation techniques
  • Parameters define dataset attributes and allocation requirements

DD Statement Naming

DDnames serve several important purposes:

  • Link the JCL with the program's I/O operations
  • Provide a logical name for the dataset
  • Allow for dataset concatenation
  • Enable dataset reference through backward references

Some DDnames have special meanings:

Special DDnamePurpose
JOBLIBLibrary containing programs for the entire job
STEPLIBLibrary containing programs for a specific step
SYSOUTSystem output for print or online viewing
SYSUDUMPSystem dump in case of abnormal termination
SYSINInput stream (inline data) for many programs

Core DD Statement Parameters

The most essential DD statement parameters define what dataset to use and how to access it.

DSN (Dataset Name)

Specifies the name of the dataset to be processed:

Format:

jcl
1
2
3
4
DSN=dataset.name DSN=&&temporary DSN=*.stepname.ddname DSN=dataset.name(member)

Examples:

jcl
1
2
3
4
//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
  • Dataset names can be up to 44 characters long
  • Segments are separated by periods (maximum 22 segments)
  • Each segment can be 1-8 characters (A-Z, 0-9, @, #, $)
  • Double ampersand (&&) denotes a temporary dataset
  • *.stepname.ddname references a dataset defined in a previous step
  • Member name in parentheses for partitioned datasets

DISP (Disposition)

Controls dataset status, what happens after normal completion, and what happens after abnormal termination:

Format:

jcl
1
2
3
4
DISP=(status,normal,abnormal) DISP=status DISP=(status,normal) DISP=OLD | SHR | NEW | MOD
Status ValueMeaning
OLDDataset exists and needs exclusive use
SHRDataset exists and can be shared with other jobs
NEWDataset doesn't exist yet and will be created
MODIf dataset exists, adds to end; if not, creates it
Normal/Abnormal ValuesMeaning
DELETERemove the dataset
KEEPRetain the dataset (don't catalog)
CATLGRetain and catalog the dataset
UNCATLGRetain but remove from catalog
PASSPass to later steps (normal only)

Examples:

jcl
1
2
3
4
//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 and VOL

UNIT specifies the device type, and VOL specifies volume information:

Format:

jcl
1
2
UNIT=device-type | UNIT=device-name | UNIT=group-name VOL=SER=volume-serial | VOL=(,,,n) | VOL=REF=*.stepname.ddname

Examples:

jcl
1
2
3
4
//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
  • UNIT=SYSDA generally refers to online disk devices
  • VOL=SER specifies the volume serial number
  • VOL=(,,,n) requests n volumes for a dataset
  • VOL=REF refers to a volume used in a previous DD statement

Dataset Attributes and Allocation

These parameters specify the physical characteristics of a dataset and allocate space.

DCB (Data Control Block)

Specifies dataset characteristics:

Format:

jcl
1
DCB=(attribute1=value1,attribute2=value2,...)
Common AttributesDescriptionValues
RECFMRecord formatF, FB, V, VB, U, etc.
LRECLLogical record lengthNumeric value
BLKSIZEBlock sizeNumeric value
DSORGDataset organizationPS, PO, DA, etc.

Example:

jcl
1
2
3
//DD1 DD DSN=NEWFILE,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=3120,DSORG=PS)

SPACE

Allocates space for a new dataset on direct access storage:

Format:

jcl
1
2
3
4
SPACE=(unit,(primary,secondary,directory),RLSE,CONTIG,ROUND) SPACE=(TRK,(10,5)) SPACE=(CYL,(5,2,10)) SPACE=(blksize,(100,50))
  • unit can be TRK (tracks), CYL (cylinders), or block size
  • primary is the initial allocation amount
  • secondary is the additional allocation when primary is filled
  • directory is the number of directory blocks (for partitioned datasets)
  • RLSE releases unused space when the dataset is closed
  • CONTIG requests contiguous space
  • ROUND rounds up to complete cylinders

Examples:

jcl
1
2
3
4
5
6
7
8
// 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)

Special DD Statement Types

Several special DD statement formats serve specific purposes.

SYSOUT

Directs output to a system output device (printer or online output):

Format:

jcl
1
2
3
SYSOUT=class SYSOUT=(class,program,form) SYSOUT=*

Examples:

jcl
1
2
3
4
//PRINT1 DD SYSOUT=A //PRINT2 DD SYSOUT=* //PRINT3 DD SYSOUT=(A,,SPEC) //REPORT DD SYSOUT=A,DEST=REMOTE1
  • class is a single character (A-Z, 0-9) that defines the output class
  • SYSOUT=* uses the MSGCLASS from the JOB statement
  • program specifies an output writer program
  • form specifies a special forms requirement
  • DEST can be added to route output to a specific destination

DUMMY

Creates a dummy dataset that's recognized by the program but doesn't actually exist:

Format:

jcl
1
2
DUMMY DUMMY,other-parameters

Examples:

jcl
1
2
//INPUT DD DUMMY //CHECK DD DUMMY,DCB=(RECFM=FB,LRECL=80)
  • For input files, reads are simulated as end-of-file
  • For output files, write operations are acknowledged but discarded
  • Useful for testing or bypassing processing without changing the program
  • Equivalent to specifying DSN=NULLFILE
  • Any parameters after DUMMY are checked for syntax but ignored

* (In-stream Data)

Includes data directly in the JCL stream:

Format:

jcl
1
2
3
4
5
6
* data lines /* * ,DLM=delimiter data lines delimiter

Example:

jcl
1
2
3
4
5
6
7
8
9
10
11
//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 ##
  • Data follows immediately after the DD statement
  • Terminated by /* (default) or custom delimiter (DLM=)
  • Commonly used with SYSIN for program control statements
  • Limited to 80 characters per line unless otherwise specified
  • Cannot be continued like normal JCL statements

Dataset Concatenation

Combines multiple datasets to be processed as a single dataset:

Format:

jcl
1
2
3
//ddname DD DSN=dataset1,DISP=SHR // DD DSN=dataset2,DISP=SHR // DD DSN=dataset3,DISP=SHR

Example:

jcl
1
2
3
//LIBRARY DD DSN=SYS1.MACLIB,DISP=SHR // DD DSN=SYS1.AMODGEN,DISP=SHR // DD DSN=USER.MACLIB,DISP=SHR
  • Only the first DD statement has a DDname
  • Subsequent DD statements start with // (without a name)
  • Datasets are processed in the order they appear
  • When end-of-file is reached on one dataset, the next is processed
  • Commonly used for libraries and input files

Complete DD Statement Examples

Here are some complete examples of DD statements for different purposes.

Creating a New Permanent Dataset

jcl
1
2
3
4
5
//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.

Creating a Partitioned Dataset (PDS)

jcl
1
2
3
4
5
//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.

Accessing an Existing Dataset

jcl
1
2
//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.

GDG (Generation Data Group) Example

jcl
1
2
3
4
5
6
//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.

Temporary Dataset

jcl
1
2
3
4
5
//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.

JOBLIB and STEPLIB

jcl
1
2
3
4
5
//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.