ENQ - IBM Mainframe

ENQ command is issued by a task to schedule resource usage (enqueue). The command causes the task life to be extended and synchronized by CICS with the availability of the specified resource, and then control is returned to the task once the resource becomes available. The resource definition of this command is any character string with a length between 1 and 255 bytes. A conditional ENQ can be setup by issuing the HANDLE CONDITION ENQBUSY. Specifying the ENQBUSY condition prior to the ENQ command will allow control to return to the issuing task (ENQBUSY label) if the resource is unavailable without waiting. Any task not releasing a ENQ'ed resource prior to termination will have CICS automatically releases the resource during syncpoint processing or when the task is terminated. For every ENQ command issued in the task there must be a corresponding DEQ command before the resource is. released by the task. The enqueued resource is identified by one of the two following methods:

  • Data area specified as a resource. With this method the location in storage is what is important not the contents. Multiple tasks using this method must reference the same storage location, which could be accomplished by using the same CWA storage location.
  • Data value specified as a resource. With this method the contents of the data value is what's important not the location in storage. Multiple tasks using this method to enqueue on the same resource or a different resource must have the contents in the identical location(s). The length must be supplied in the LENGTH option. The syntax of the ENQ command is given below:
  • ENQ


The various options of the command are described below:

  • LENGTH (data_value) - Halfword binary (range 1-255). The resource to be enqueued has a length value specified by this option. If the LENGTH option is used on an enqueue command then it also must be used on the dequeue command and they both must be the exact same value. When using, a data value containing a unique argument, this option is required. But when using a data resource this option is omitted. CICS determines which option (data_value, data_resource) is being used by the presence or absence of this option.
  • MAXLIFETIME (cvda) - Defines the enqueue function duration is to be automatically released by CICS. There are two values that can be passed to CICS for this option and they are:
    1. LUW - The enqueue duration is the logical unit of work. A syncpoint rollback would be an example. Another example, which is the default, is a syncpoint if the application does not issue the DEQ command before the LUW ends.
    2. TASK - The enqueue duration is the life of the task. An enqueue will be maintained throughout all LUWs during the life of the task. This option MAXLIFETIME (TASK) should be used cautiously because of the possibility that other tasks may be also trying to acquire the same resource causing those tasks to be suspended until the end of this task. There are two possible ways to code this option:
  • Assign a value to CVDA with the translator routine DFHVALUE. This allows a program to change the CVDA value dynamically. The following is an example of this:
  • CVDA value dynamically

  • Specify the value directly for an action that is always the same. For example:
  • CVDA value dynamically

    CVDA value dynamically

    When an ENQBUSY occurs, this option specifies that the application is not to be suspended.
  • RESOURCE (dataarea) - Specifies the resource to be enqueued by either defining the area whose address represents the resource or defining the variable that contains the resource.
    Handle Conditions:
  • ENQBUSY - ENQ command tried to acquire an unavailable resource. This returns control to the task without waiting for the available resource. The default action is to wait for the resource to become available.
  • INVREQ - Incorrect CVDA specified with the MAXUFETIME option set.
  • LENGERR - LENGTH option value is outside the range 1-255.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM Mainframe Topics