Mainframe Path Start learning free
Core8 min readLesson 3 of 5

DD statements: connecting programs to data

A DD statement answers one question: when this program asks for the file it calls INFILE, what should it actually get? The answer can be a dataset, a printer, some text typed inline, or nothing at all.

The five kinds of DD you will meet

KindWritten asUsed for
Existing datasetDSN=name,DISP=SHRReading a file that already exists
New datasetDSN=name,DISP=(NEW,CATLG,DELETE),SPACE=…Creating output
Printed outputSYSOUT=*Messages and reports going to the spool
Inline data* or DATA, ending with /*Control cards typed straight into the JCL
TemporaryDSN=&&TEMP,DISP=(NEW,PASS)A work file passed between steps and then discarded
All five, in one step
//STEP010  EXEC PGM=SORT
//SORTIN   DD DSN=PROD.PAY.MASTER,DISP=SHR
//SORTOUT  DD DSN=&&SORTED,DISP=(NEW,PASS),
//            SPACE=(CYL,(20,5)),UNIT=SYSDA
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=(1,8,CH,A)
  INCLUDE COND=(9,1,CH,EQ,C'Y')
/*

The parameters, in the order you meet them

The ddnames you will see in nearly every job

DDNAMEPurpose
STEPLIBExtra program libraries searched for this step's load modules
JOBLIBSame, but for the whole job — placed after the JOB statement
SYSINControl input, often inline
SYSOUTProgram messages
SYSPRINTUtility and compiler listings
SYSUDUMP / SYSABENDWhere a dump is written if the step abends
SORTIN / SORTOUT / SYSINThe sort utility's standard three
Concatenated input
//INFILE   DD DSN=PROD.PAY.JAN,DISP=SHR
//         DD DSN=PROD.PAY.FEB,DISP=SHR
//         DD DSN=PROD.PAY.MAR,DISP=SHR

Example, line by line

JCLWhat it means
//OUTFILE DD DSN=PROD.PAY.CALC,
The name of the dataset this step will create. The comma continues the statement.
// DISP=(NEW,CATLG,DELETE),
Create it; catalog it if the step ends normally; delete it if the step abends.
// SPACE=(CYL,(50,10),RLSE),
50 cylinders to start, 10 more per extension, and release what is not used.
// DCB=(RECFM=FB,LRECL=200,BLKSIZE=0)
Fixed-length blocked records of 200 bytes; BLKSIZE=0 lets the system choose the block size.

Try it yourself

TRY IT YOURSELF

Write the DISP parameter that lets your step read PROD.PAY.MASTER while other jobs read it too.

Show a hint

You want shared, read-only use of an existing dataset.

Show the solution

DISP=SHR — the dataset already exists and other jobs may read it at the same time.

Common mistakes

Mismatched LRECL between program and dataset

An S013 abend on open usually means the record length or format the program expects does not match the file it was given.

Forgetting SPACE on a new dataset

Without space information the allocation fails, unless storage management supplies a default class.

Putting the biggest library last in a STEPLIB concatenation

Search order is top down and the first match wins. A stale module in the first library silently overrides the new one below it.

Using DUMMY to make an error go away

It will make the error go away and quietly produce wrong results. Use it deliberately, never as a workaround.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← The JOB and EXEC statementsDISP, the parameter that causes the most trouble →