WRITE WORK to workfile with DISP=SHR

Is there an explanation why this works:

Workfile definition: //CMWKF01 DD DSN=IPRA964.WORK01,DISP=SHR
Natural program:
1 #WORK (A30)
#WORK := ‘Hello world’

I expected on error message like “Trying to write to a read only workfile” but on the contrary all went well and the work file contains 1 record with “Hello world”.

The fact that you defined the existing work file as “SHR” means nothing to Natural. It only means that the batch job is willing to “share” access to this file with other batch/online jobs (or users). It does not indicate that the file is “read only”.

However, when you try to write to this work file and other jobs are accessing the file there will be contention issues and the results will be unpredictable, except that one of the resources contending for the file access will abend in some manner (I suspect anyways).

In the cases where you are writing to an existing work file where there may be contention for that file, specify “DISP=OLD” to ensure sole update access to that file (for the duration of the batch job).


Thanks Colin,

Ok, that’s right. The DISP parameter has nothing to do with the dataset being “read only” or not.

Next question is of course: Is it possible to have a real “read only” workfile?



At my installation (Natural/DB2 in a mainframe CICS/TSO environment operating in a cold Canadian climate), the way that this is done is through RACF (see http://en.wikipedia.org/wiki/RACF if you don’t know what this is), not through any programmer written application software.

Steve might be able to say how/if it can be done through Natural, although I think that this sort of requirement would be regulated at a higher level (e.g. through RACF) than at the application program level.

Perhaps you can explain what your requirement is for this - then the forum has a better idea of how to satisfy it.


Hey Colin,

Yes I know about RACF, in our installation (Natural/Adabas CICS/TSO in a cold AND WET Belgian climate :wink: ) we use ACF2.
I was just wondering whether it was possible to have a workfile as read-only.

I had a two step job.
The first step creates a dataset (DISP=NEW) and second reads this dataset (DISP=SHR) en creates a second dataset.
At the end of the job the first dataset was empty, nevertheless a counter reported that some records were written.
I figured out that the second program did a erroneous write to the first workfile instead of the second workfile.

To avoid such an error it would be handy to be able to declare the first worfile as read-only. In a situation like this even RACF/ACF2 can’t help.