The DISP (disposition) parameter specifies the status of a data set when a job step begins processing, and determines what happens to the data set when the step ends normally or abnormally. This parameter is crucial for controlling data set availability, sharing, and retention throughout the job's execution.
1//ddname DD DSN=dataset.name,DISP=(status,normal-disp,abnormal-disp)
123//ddname DD DSN=dataset.name,DISP=status //ddname DD DSN=dataset.name,DISP=(status,normal-disp) //ddname DD DSN=dataset.name,DISP=(,,abnormal-disp)
Value | Description |
---|---|
NEW | Create a new data set. The system allocates space for the data set on a direct access volume. |
OLD | The data set exists and is exclusively allocated to this job step (no sharing). |
SHR | The data set exists and can be shared with other jobs (read sharing). |
MOD | If the data set exists, position at the end for addition of records. If the data set does not exist, create it (like NEW). |
Value | Description |
---|---|
DELETE | Remove the data set from the system. |
KEEP | Retain the data set on the volume, but don't catalog it. |
PASS | Make the data set available to subsequent steps in the job. |
CATLG | Retain the data set and record its location in the catalog. |
UNCATLG | Retain the data set but remove its catalog entry. |
Same values as normal termination disposition: DELETE, KEEP, CATLG, UNCATLG. Note that PASS is not valid for abnormal termination.
Status | Default Normal Disposition | Default Abnormal Disposition |
---|---|---|
NEW | DELETE | DELETE |
OLD | KEEP | KEEP |
SHR | KEEP | KEEP |
MOD | KEEP (if exists), DELETE (if new) | KEEP (if exists), DELETE (if new) |
1234//OUTFILE DD DSN=USER.NEW.DATASET, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920)
Creates a new data set; catalogs it if step ends normally; deletes it if step abnormally terminates
1//INFILE DD DSN=SYS1.PAYROLL.DATA,DISP=SHR
Accesses an existing data set with shared access; keeps it after step ends (default)
1//UPDATE DD DSN=PROD.MASTER.DATA,DISP=(OLD,KEEP)
Accesses an existing data set with exclusive access; keeps it after normal completion
1//APPEND DD DSN=PROD.LOG.DATA,DISP=(MOD,CATLG,KEEP)
Appends to existing data set or creates it if not found; catalogs after normal completion
1234//STEP1 EXEC PGM=SORT //SORTWK1 DD DSN=&&TEMP1,DISP=(NEW,PASS),SPACE=(CYL,5) //STEP2 EXEC PGM=REPORT //INFILE DD DSN=&&TEMP1,DISP=(OLD,DELETE)
Creates temporary data set in STEP1, passes it to STEP2, then deletes it
1//MASTER DD DSN=PROD.CRITICAL.DATA,DISP=(SHR,,KEEP)
Uses SHR status but explicitly ensures data is kept even if job fails
1234//GDGOUT DD DSN=ACCT.MONTH.DATA(+1), // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(50,10)), // DCB=(RECFM=FB,LRECL=200,BLKSIZE=27800)
Creates a new generation in a GDG; catalogs it if successful
Pattern | Use Case | Example |
---|---|---|
DISP=(NEW,CATLG,DELETE) | Standard pattern for creating permanent data sets | Creation of output files from a job |
DISP=(NEW,PASS,DELETE) | Creating temporary data sets passed between steps | Working files in multi-step jobs |
DISP=(NEW,DELETE) | Creating truly temporary data sets | Sort work files, intermediate results |
DISP=SHR | Reading shared data sets | Reference data, lookups, inputs |
DISP=(OLD,KEEP) | Updating existing data sets | Master files, transaction processing |
DISP=(MOD,CATLG,KEEP) | Append to existing data sets | Log files, cumulative reports |
DISP=(OLD,UNCATLG) | Remove catalog entries but keep data | Archive processes |
If one job uses | Another job can use | Another job cannot use |
---|---|---|
DISP=SHR (read-only) | DISP=SHR (read-only) | DISP=OLD, DISP=(NEW), DISP=(MOD) |
DISP=OLD (exclusive) | None | DISP=SHR, DISP=OLD, DISP=(NEW), DISP=(MOD) |
DISP=(NEW) (new allocation) | None | DISP=SHR, DISP=OLD, DISP=(NEW), DISP=(MOD) |
DISP=(MOD) (append) | None | DISP=SHR, DISP=OLD, DISP=(NEW), DISP=(MOD) |
In addition to basic DISP sharing, enhanced data set sharing can be accomplished using:
1//BAD DD DSN=MASTER.DATA,DISP=SHR // Wrong if updating the file!
1//RISKY DD DSN=CRITICAL.DATA,DISP=(NEW,CATLG) // What if step fails?
1//INPUT DD DSN=SOURCE.DATA,DISP=(SHR,DELETE) // Will delete after step!
12//LASTSTEP EXEC PGM=FINAL //OUTPUT DD DSN=RESULT.DATA,DISP=(NEW,PASS) // Not passed to anyone!
1//APPEND DD DSN=LOG.FILE,DISP=(MOD,KEEP) // Creates new file if missing
12//STEP1 DD DSN=TEST.DATA,DISP=(NEW,DELETE) // Deleted after STEP1 //STEP2 DD DSN=TEST.DATA,DISP=OLD // Will fail - file was deleted!