DISP, the parameter that causes the most trouble
DISP has three parts: what state the dataset is in now, what to do if the step succeeds, and what to do if it fails. Getting it wrong is how jobs delete data they meant to keep, or hang waiting for a file someone else is holding.
Part one: status
| Status | Meaning | Locking |
|---|---|---|
| NEW | Create it; it must not already exist | Exclusive |
| OLD | It exists, and I want it to myself | Exclusive |
| SHR | It exists, and others may read it at the same time | Shared |
| MOD | Append to it, or create it if absent | Exclusive |
Part two and three: what happens afterwards
| Value | Effect |
|---|---|
| CATLG | Keep it and record it in the catalog so it can be found by name |
| KEEP | Keep it but do not catalog it — you will need UNIT and VOLUME to find it again |
| DELETE | Remove it |
| PASS | Keep it available to a later step in this job only |
The four patterns that cover almost everything
* read an existing file, leave it alone DISP=SHR * create a permanent output file; clean up if the step fails DISP=(NEW,CATLG,DELETE) * read an existing file and delete it when done DISP=(OLD,DELETE,KEEP) * temporary file handed to a later step in this job DISP=(NEW,PASS,DELETE) then DISP=(OLD,DELETE)
The rerun problem
DISP=(NEW,CATLG,DELETE) fails on a rerun, because after a successful first run the dataset already exists and NEW insists it must not. Sites solve this in one of three ways, and you should know which one yours uses:
- A delete step at the front of the job — usually IDCAMS or IEFBR14 — removing yesterday's output before creating today's.
- Generation data groups, where each run creates a new generation and the old ones age out automatically. See the datasets topic.
- A date or run-number qualifier in the dataset name so every run writes a different name.
//STEP005 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE PROD.PAY.CALC SET MAXCC=0 <- do not fail if it was not there /*
DISP patterns, side by side
DISP=SHRDISP=OLDDISP=(NEW,CATLG,DELETE)DISP=(MOD,CATLG,CATLG)DISP=(OLD,DELETE,KEEP)Try it yourself
A step creates a report dataset. If the step abends you want it removed. What is the third DISP subparameter?
Show a hint
The third subparameter only applies when the step ends abnormally.
Show the solution
DELETE — for example DISP=(NEW,CATLG,DELETE).
Common mistakes
Unnecessary exclusive locks are the leading cause of batch contention. If you are only reading, use SHR.
Keeps partial output after a failure, which then blocks the rerun and can be read as if it were complete.
MOD will create a file if absent, but with whatever DCB you supplied — often not the one you assumed.
IDCAMS returns a non-zero code when the dataset was not there, which can fail the job on the very rerun it was meant to enable.
What you will see at work
- 'Job X is waiting on dataset Y held by job Z' is a daily conversation. DISP is why.
- Your site will have a standard delete-step template. Use it rather than writing your own.
- When you copy a job, DISP is the parameter to check line by line — copied dispositions cause quiet data loss.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.