QueryEnq - Rexx function to get ENQ information

QueryEnq is a Rexx function, written in assembler language, to return information on existing ENQs. With QueryEnq, any z/OS  Rexx program can find out who is using a data set, who holds resources and even what ENQ contention exists on the system.

QueryEnq is available as source code.

To save the source code using Netscape or Internet Explorer, select the link above with the right mouse button and select 'Save Link As...' or Save Target as...'

Function

To return ENQ status on a data set or any rname/qname. This is a Rexx function and it sets Rexx variables.

Calling Syntax from Rexx:

Call QueryEnq rname
Call QueryEnq rname,qname
xx=QueryEnq(rname)
xx=QueryEnq(rname,qname)

Call QueryEnq 'contention'

rname is assumed to be a data set name that follows TSO naming conventions. If it is not in quotes, the user prefix will be added. If qname is specified and is not SYSDSN then the rname is not treated as a TSO style data set name. If rname is the word contention then all ENQs causing contention are returned (both owners and waiters).

qname is the major name of the ENQ to be queried. Qname will default to SYSDSN. Qname must not be specified when rname is 'contention'.

Some combinations you might see include (from dynalloc & ISPF doc):
QNAME RNAME
SYSDSN data set name
SPFEDIT data set name (optional member name in cols 45 to 52)
SYSZOPEN data set name
SYSZVOLS volume serial number

Output variables

ENQJOB.n Stem variable containing jobs enqueued to a resource.

ENQTYPE.n ENQ information about the request made for the address space listed in ENQJOB.n.

Col 1-3 'SHR' or 'OLD'
Col 5-8 'OWN ' or 'WAIT'
Col 10-17 'SYSTEM ', 'SYSTEMS', or 'NONSYS '
Col 10-17 'SYSTEM ', 'SYSTEMS', or 'NONSYS '
COL 19-25 'STEP ' or 'NONSTEP'
COL 27-34 system name on which request was made

ENQQNAME.n The QNAME associated with the enq in ENQJOB.n.

ENQRNAME.n The RNAME associated with the enq in ENQJOB.n. When ENQQNAME.n is 'SYSDSN', ENQRNAME.n is a data set name. The maximum length returned for ENQRNAME.n is 52. If the real rname is longer than 52 bytes, it is truncated to 52 bytes.

ENQTYPE.0, ENQJOB.0, ENQQNAME.0 and ENQRNAME.0 all contain the number of elements returned and will all contain the same number.

RC and RESULT values:
RC=0  - RESULT = 'OK'
RC=16 - RESULT = 'TOO MANY PARAMETERS'
RC=20 - RESULT = 'RNAME NOT SPECIFIED'

Installation

Assemble AMODE(31),RMODE(ANY). Place load module in any accessable load library.

Sample
/* Rexx - QueryEnq example */
Say center(' ENQs on SYS1.BROADCAST ',78,'-')
s = queryenq("'SYS1.BRODCAST'")
Do a = 1 to enqjob.0
  Say enqjob.a  enqtype.a
End

Say center(' ISPF edits of CLIST(MEMBER) ',78,'-')
s = queryenq(left(userid()'.CLIST',44)||'MEMBER  ','SPFEDIT')
Do a = 1 to enqjob.0
  Say enqjob.a  enqtype.a enqrname.a
End

Say center(' ENQ Contention ',78,'-')
Call queryenq 'contention'
If enqjob.0 > 0 Then
  Do a = 1 to enqjob.0
    Say enqjob.a  enqtype.a enqqname.a enqrname.a
  End
Else
  Say 'No enq contention exists on this system.'

produces

 --------------------------- ENQs on SYS1.BROADCAST --------------------------- 
 AOCON4   SHR OWN  SYSTEM   NONSTEP VS1C 
 R469663  SHR OWN  SYSTEM   NONSTEP VS1C 
 R521960  SHR OWN  SYSTEM   NONSTEP VS1C 
 NADEL    SHR OWN  SYSTEM   NONSTEP VS1C 
 NADELY   OLD WAIT SYSTEM   NONSTEP VS1C 
 ------------------------ ISPF edits of CLIST(MEMBER) ------------------------- 
 NADEL    OLD OWN  SYSTEMS  NONSTEP VS1C     NADEL.CLIST                                 MEMBER 
 ------------------------------- ENQ Contention ------------------------------- 
 NADEL    SHR OWN  SYSTEM   NONSTEP VS1C     SYSDSN   NADEL.ISRDDN 
 NADELY   OLD WAIT SYSTEM   NONSTEP VS1C     SYSDSN   NADEL.ISRDDN 
 NADEL    SHR OWN  SYSTEM   NONSTEP VS1C     SYSDSN   NADEL.CLIST 
 NADELY   OLD WAIT SYSTEM   NONSTEP VS1C     SYSDSN   NADEL.CLIST 
 AOCON4   SHR OWN  SYSTEM   NONSTEP VS1C     SYSDSN   SYS1.BRODCAST 
 R469663  SHR OWN  SYSTEM   NONSTEP VS1C     SYSDSN   SYS1.BRODCAST 
 R521960  SHR OWN  SYSTEM   NONSTEP VS1C     SYSDSN   SYS1.BRODCAST 
 NADEL    SHR OWN  SYSTEM   NONSTEP VS1C     SYSDSN   SYS1.BRODCAST 
 NADELY   OLD WAIT SYSTEM   NONSTEP VS1C     SYSDSN   SYS1.BRODCAST 
 *** 
Output of QueryEnq sample