JCL DISP Parameter
DISP Parameter in JCL stands for DISPOSITION and DISP Parameter is mainly used to inform about 3 things-
a) What will be the Current Status of the Dataset? The dataset will be a new or existing one? If it is old dataset then whether the new content must be appended at the end of the file or it should override the file?
b) What will happen to the Dataset, if the JCL terminates Normally?
c) If the JCL terminates Abnormally, then what you need to do for the dataset?
The Syntax for DISP parameter:
- CS – It denotes the Current Status. The allowed values are – NEW, OLD, SHR, MOD
- ND – It denotes Normal Disposition. The allowed values are – CATLG, UNCATLG, KEEP, PASS and DELETE. If a step terminates normally (without any ABEND), then we have to code that what needs to be done with that dataset. If a step terminates normally (without any ABEND), then we have to code that what needs to be done with that dataset.
- AD – It denotes Abnormal Disposition. If a step terminates Abnormally(ABEND), then we have to define, what needs to be done with the dataset. The allowed values are – KEEP, DELETE, CATLG, and UNCATLG
Let us discuss in detail about the values that CS can take-
CS will take one among these values –
- NEW – This tells the system to create a new dataset.
- OLD – This means that this dataset already exists and will use this dataset exclusively in this step for this particular Job.
- SHR – This dataset already exists and should be used in shared mode. For example – If you have a job called JOB1 and you have another job called JOB2 and both the jobs want to refer a dataset called DATASET1. so, the best way to share the dataset is to code DISP=SHR for both the datasets in the JCL. In this case, both the jobs will be able to share the resource DATASET1 in SHR mode.
- MOD – There are 2 possibilities if we want to code MOD –
a) Retrieve the dataset if it already exists based on volume. In this case, we need to code VOL=SER or VOL=REF
b) Create the dataset if this dataset does not exist. In this case, we do not need to code
VOL=SER or VOL=REF
Let us discuss in detail about the values that ND and AD can take-
In case of Normal or Abnormal disposition, they can take any one of these values –
1) DELETE – This means, delete the dataset and uncatalog the dataset as well.
2) KEEP – This means that do not delete the dataset, just retain it.
3) CATLG – This means that we should create an entry of the dataset in the Catalog.
4) UNCATLG – This means, we should not delete the dataset but we need to uncatalog it.
5) PASS – This is only used in case of Normal Disposition. In this case, the dataset will be retained for use by a later step.
Sample Example of DISP=(NEW, CATLG, DELETE)
In case, the dataset does not exist before the job runs and once the job completes successfully, then it will create a new dataset as shown here. MATEKS.TEST.BACKUP is created newly with the contents copied from MATEKS.TEST.PSFILE.
Sample Example of DISP=(NEW,DELETE,DELETE)
In this case, we gave DISP=(NEW, DELETE, DELETE) and once the job is successful, it deleted the dataset as well.
Note: In actual production, it is rare to code DISP=(NEW, DELETE, DELETE) as nobody wants to delete the file in case of Normal Disposition until it is really required to do so. This example is just to show the difference between DELETE and CATLG etc.