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
| Kind | Written as | Used for |
|---|---|---|
| Existing dataset | DSN=name,DISP=SHR | Reading a file that already exists |
| New dataset | DSN=name,DISP=(NEW,CATLG,DELETE),SPACE=… | Creating output |
| Printed output | SYSOUT=* | Messages and reports going to the spool |
| Inline data | * or DATA, ending with /* | Control cards typed straight into the JCL |
| Temporary | DSN=&&TEMP,DISP=(NEW,PASS) | A work file passed between steps and then discarded |
//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
- DSN= the dataset name. Add
(MEMBER)for one member of a library. - DISP= what state the dataset is in and what to do with it afterwards — the next lesson is entirely about this.
- SPACE= how much room a new dataset gets:
SPACE=(CYL,(primary,secondary),RLSE). RLSE gives back what was not used. - UNIT= the device group, usually
SYSDAfor ordinary disk. Often supplied automatically by storage management. - DCB= / RECFM / LRECL — record format and length.
FBmeans fixed-length blocked;VBvariable. LetBLKSIZE=0choose the block size for you. - SYSOUT= send to spool.
SYSOUT=*uses the job's MSGCLASS. - DUMMY — the program thinks it has a file; reads hit end-of-file immediately and writes are discarded.
The ddnames you will see in nearly every job
| DDNAME | Purpose |
|---|---|
| STEPLIB | Extra program libraries searched for this step's load modules |
| JOBLIB | Same, but for the whole job — placed after the JOB statement |
| SYSIN | Control input, often inline |
| SYSOUT | Program messages |
| SYSPRINT | Utility and compiler listings |
| SYSUDUMP / SYSABEND | Where a dump is written if the step abends |
| SORTIN / SORTOUT / SYSIN | The sort utility's standard three |
//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
//OUTFILE DD DSN=PROD.PAY.CALC,// DISP=(NEW,CATLG,DELETE),// SPACE=(CYL,(50,10),RLSE),// DCB=(RECFM=FB,LRECL=200,BLKSIZE=0)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
An S013 abend on open usually means the record length or format the program expects does not match the file it was given.
Without space information the allocation fails, unless storage management supplies a default class.
Search order is top down and the first match wins. A stale module in the first library silently overrides the new one below it.
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
- Most sites use system-managed storage, so UNIT and VOLUME are usually omitted and a storage class decides where the dataset lands.
- Reading someone else's job means reading the DD statements first — they tell you what the job actually touches.
- When a job needs a new file, copy the DD from a similar existing job rather than inventing SPACE and DCB values.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.