Datasets are ENQueued by allocation and deallocation processing when it is necessary to control access to a file. For example, a job which creates a dataset with DISP=NEW must have exclusive control over the dataset, so that other tasks cannot create or use a similarly-named dataset at the same time. Exclusive control must also be obtained when deleting a dataset, so that other tasks cannot access the dataset while it is being deleted. Allocation and deletion processing use the ENQueue mechanism to obtain either exclusive or shared control over datasets as needed. If the proper ENQueue cannot be obtained for a dataset being allocated or deleted, the allocation or deletion process fails.
Unfortunately, in many instances, when an attempt to create, delete, or access a dataset fails due to an enqueue conflict, it is difficult to know what other jobs or tasks may have been using the dataset and on what system they are running. Depending upon the circumstances, the system may or may not issue messages indicating who the culprits are. A DISPLAY GRS console command can be used to obtain enqueue information, but this can only be performed after-the-fact (by which time the conflicting task may have freed the dataset) and requires console command authority.
ACC users can use the DEFENV statement in the ACC policy rules to enable the ALLOCENQ environment to automatically receive control when an enqueue conflict causes the allocation or deallocation of a dataset to fail. Currently, ALLOCENQ receives control for two dynamic allocation return codes. These are return code x’210’ (requested dataset allocated to another job) and return code x’20C’ (request for exclusive use of a shared dataset cannot be honored). If the ACC policy rules in this environment set the value of &ENQERRMSG to YES, then ACC will scan the GRS queues for other tasks which are using the dataset. Message ACC20641 will then be issued to indicate which tasks and systems are holding the enqueue and preventing the allocation from completing. If the ACC policy rules also set the value of &JCLFAIL to YES, then allocation with fail with return code x’215’ (an invalid dynamic allocation return code) and message ACC29700 in order to draw attention to the error.
Examples 25 and 26 in this manual show the use of the ALLOCENQ environment.