DISP Parameter Example


Scenario1 - Create new PS file.

Code -

----+----1----+----2----+----3----+----4----+----5----+
//STEP10   EXEC PGM=IEFBR14
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(TRK,(3,2),RLSE),
//            UNIT=SYSDA,VOLUME=SER=DEVHD4,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

Explaining Example -

The statements request the system to CATLOG the new dataset if the step terminates normally and DELETE the dataset if the step terminates abnormally.

Scenario2 - Using DISP=OLD

Code -

----+----1----+----2----+----3----+----4----+----5----+
//STEP10   EXEC PGM=PROG1
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE,DISP=OLD

Explaining Example -

This parameter specifies that an existing dataset will be used. If a dataset with the specified name does not exist, the job will fail.

Scenario3 - Using DISP=SHR

Code -

----+----1----+----2----+----3----+----4----+----5----+
//STEP10   EXEC PGM=PROG1
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE,DISP=SHR

Explaining Example -

This parameter specifies that the dataset will be opened in "shared" mode. This allows multiple jobs to access the same dataset simultaneously.

Scenario4 - Using DISP=(OLD,DELETE)

Code -

----+----1----+----2----+----3----+----4----+----5----+
//STEP10   EXEC PGM=PROG1
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE,DISP=(OLD,DELETE)

Explaining Example -

This parameter specifies that an existing dataset will be used, and if the job completes successfully, the dataset will be deleted.

Scenario5 - Using DISP=(NEW,KEEP)

Code -

----+----1----+----2----+----3----+----4----+----5----+
//STEP10   EXEC PGM=IEFBR14
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE,
//            SPACE=(TRK,(3,2),RLSE),
//            UNIT=SYSDA,VOLUME=SER=DEVHD4,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

Explaining Example -

This parameter specifies that a new dataset will be created, and if successful, it will be kept even if the job abnormally terminates.