Schedules use of a resource by a task (enqueue).
ENQ causes further execution of the task that is issuing the ENQ command to be synchronized with the availability of the specified resource; control is returned to the task when the resource is available.
A resource in the context of this command is any string of 1 through 255 bytes, established by in-house standards to protect against conflicting actions between tasks.
ONE TWO
EXEC CICS ENQ OMEGA EXEC CICS ENQ OMEGA
EXEC CICS WRITE record1 EXEC CICS STARTBR
EXEC CICS WRITE record2 EXEC CICS READNEXT
EXEC CICS WRITE record3 EXEC CICS READNEXT
... ...
EXEC CICS SYNCPOINT EXEC CICS ENDBR
The ENQ of OMEGA serializes the access to the file. In the absence of an explicit DEQ, this action occurs at the commit/rollback phase in the SYNCPOINT. If the ONE transaction has been successfully prepared, and a systems failure occurs, the records are again prepared. However, after the system restart, no logged ENQ information is available to draw on, and a fresh ENQ is not obtained. The transaction TWO obtains the ENQ on the original data and starts to do its summary; the READNEXTs will be successful because CICS® allows locked records to be read. If the ONE transaction resolution says ABORT, TWO might have used some of the new values that are about to be erased, giving an incorrect summary.
The ENQBUSY condition allows a conditional ENQ to be used. If a resource is not available when enqueued, the ENQBUSY condition occurs.
For COBOL programs only, the execution of a HANDLE CONDITION ENQBUSY command returns control to the task at the ENQBUSY label, without waiting for the resource to become available.
If a task enqueues on a resource but does not dequeue from it, CICS automatically releases the resource during syncpoint processing or when the task is terminated.
EXEC CICS ENQ
RESOURCE(RESNAME)
EXEC CICS ENQ
RESOURCE(SOCSECNO)
LENGTH(8)
Default action: Wait for the resource to become available. (This default action can be overridden by the NOSUSPEND option.)
Default action: Terminates the task abnormally.