Schedule use of a resource by a task (enqueue).
ENQ >>-ENQ--RESOURCE(data-area)--+--------------------+-------------> '-LENGTH(data-value)-' .-UOW---------------. >--+-------------------+--+-----------+------------------------>< +-MAXLIFETIME(cvda)-+ '-NOSUSPEND-' '-TASK--------------'
Conditions: ENQBUSY, INVREQ, LENGERR
This command is threadsafe if it is defined as LOCAL. It is non-threadsafe if it is defined as GLOBAL.
ENQ causes further execution of the task 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–255 bytes, established by in-house standards, to protect against conflicting actions between tasks, or to cause single threading within a program.
If a task enqueues on a resource but does not dequeue from it, CICS® automatically releases the resource during syncpoint processing (including DL/I, PCB, and TERM calls), or when the task is terminated. Option UOW forces the dequeue at the end of a unit of work (UOW). Option TASK forces the dequeue at the end of a task. If there are several units of work in a task, the enqueue carries over the UOWs.
If more than one ENQ command is issued for the same resource by a given task, the resource remains owned by that task until the task issues a matching number of DEQ commands.
The resource to be enqueued on must be identified by one of the following methods:
When an EXEC CICS ENQ (or DEQ) command is issued for a resource whose name matches that of an installed ENQMODEL resource definition, CICS checks the value of the ENQSCOPE attribute to determine whether the scope is local or sysplex-wide. If the ENQSCOPE attribute is left blank (the default value), CICS treats the ENQ as local to the issuing CICS region. If no ENQMODEL matches the resource name, the scope of the ENQ command is local. See the CICS Resource Definition Guide for more information about the ENQMODEL resource definition.
If a resource is not available when ENQ is issued, the application program is suspended until it becomes available. However, if the NOSUSPEND option has been specified and the resource is unavailable, the ENQBUSY condition is raised, as it is also raised if you have an active HANDLE condition. This allows the application program to handle the case of resource unavailability (by HANDLE CONDITION ENQBUSY) without waiting for the resource to become available.
MOVE DFHVALUE(UOW) TO AREA-A
EXEC CICS ENQ RESOURCE(RESNAME)
MAXLIFETIME(AREA-A)
EXEC CICS ENQ RESOURCE(RESNAME) UOW
EXEC CICS ENQ RESOURCE(RESNAME) TASK
Note, however, that if a HANDLE CONDITION for ENQBUSY is active when the command is executed, action, control is passed to the user label supplied in the HANDLE CONDITION. This takes precedence over the NOSUSPEND option but is, of course, negated by either NOHANDLE or RESP.
If the NOSUSPEND option is not specified, and the ENQ command specifies a resource that is unavailable, the application program is suspended and the ENQBUSY condition is not raised.
Default action: ignore the condition.
Default action: terminate the task abnormally.
Default action: terminate the task abnormally.
EXEC CICS ENQ
RESOURCE(RESNAME)
EXEC CICS ENQ
RESOURCE(SOCSECNO)
LENGTH(9)
The two methods cannot be combined. If one task uses the LENGTH option, and the other task does not, CICS regards the enqueues with and without the LENGTH option as different types of enqueues, and the tasks are not serialized.