JCL exclusive access to data set error
According to MVS JCL Reference guide before the job start it requests the exclusive control of a data set:
DISP and ENQ: Before starting the first step of a job, the initiator requests
control of all of the data sets in that job by issuing an ENQ for each of them,
using the value specified for DISP to determine the kind of ENQ issued. The
initiator issues the ENQ for each data set at the highest level required for that
data set by any step of the job. For example, if all steps of the job request
shared control of a specific data set (DISP=SHR) then the ENQ for that data set
is requeste开发者_开发技巧d as SHR. If, on the other hand, any step of the job requests
exclusive control of a specific data set (DISP=NEW, DISP=MOD, or DISP=OLD), then
the ENQ for that data set is requested EXCL.
But I got two different behaviors:
a) I open through ISPF DATASET_A and submit a JCL that uses the same data set with DISP=(NEW,CATALOG,DELETE). I get a TSO message because the data set is requested by the job and the JCL won't start until I release the data set through ISPF.
b) I submit 2 JCL's that use the same data set with DISP=(NEW,CATALOG,DELETE) but both start at the same time.
Why don't the jobs request exclusive access to the data set when running in parallel?
The reason the jobs in b) don't behave like you expect is that you start them at the same time. They both create a new dataset of the same name, which is allowed. When the jobs finish which ever finishes first should catalog the dataset and the second job will get a NOTCAT2 error because it is already catalogued.
The second part of the disp statement (Catalog) is what happens for a successful step and the third part (Delete) is what happens for an unsuccessful step.
To create a new dataset and get exclusive access use
MOD Indicates one of the following:
* The data set exists and records are to be added to the end of it. The data set must be sequential.
* A new data set is to be created.
In either case, MOD specifies exclusive (unshared) use of the data set.
Taken from the IBM Manual
精彩评论