Back in 2012 I wrote a tip about DDLIST and claimed assembler is the only language in MVS you can use to query enqueues. This is no longer the case. For quite a while it has been possible to query enqueues using an ISPF service. And ISPF services can be called from REXX (and other languages) and then I am a happy man. The interface to this service turned out to be somewhat different from other ISPF services which typically returns zero to many records. This is the first ISPF service I know which returns its result in an ISPF table.
The service is called QUERYENQ and is able to return the same data as the ENQ command in DDLIST. Unfortunately it is quite hard to figure out which input parameters on the ENQ panel matches which parameters for QUERYENQ. I have made a simple REXX which might help (I hope):
/* REXX: ENQEXMPL */ ARG MAJORNAMEPREFIX MINORNAMEPREFIX ADDRESSIDPREFIX QNAME = MAJORNAMEPREFIX RNAME = MINORNAMEPREFIX REQ = ADDRESSIDPREFIX ENQS = 0 ADDRESS ISPEXEC 'CONTROL ERRORS RETURN' 'QUERYENQ TABLE(ENQEXMPL) QNAME(QNAME) REQ('REQ') RNAME(RNAME)' 'TBTOP ENQEXMPL' 'TBSKIP ENQEXMPL' DO WHILE RC = 0 ENQS = ENQS + 1 IF ENQS = 1 THEN SAY LEFT('MAJOR', 9)''LEFT('MINOR',55)'JOB NAME' SAY LEFT(ZENQNAME, 9)''LEFT(ZENRNAME,55)''ZENJOB 'TBSKIP ENQEXMPL' END 'TBEND ENQEXMPL' IF ENQS = 0 THEN SAY 'NO ENQUEUES FOUND' EXIT
The QUERYENQ service creates the ISPF table using the specified name (ENQEXMPL), but you must remember to remove the ISPF table again by using TBEND. The REQ parameter may be empty/blank and will thus match all address space names (jobnames). You may also use % to substitute one character and * for zero to many characters. Both QNAME and RNAME may be terminated with a *. Try for instance to call the REXX ENQEXMPL using TSO %ENQEXMPL * * youruserid to print all the enqueues held by your TSO user address space.
Please notice the mixing of variable names and constants/values on the different parameters for QUERYENQ. You need to be very careful. The ISPF table created by QUERYENQ holds more variables than the ones I have used, so there is more information. Use the above link to QUERYENQ to learn more. Also be aware that the ISPF table is not created if there are no matching enqueues. This is why I use CONTROL ERRORS RETURN. It is of course better to examine the value of RC after the call to QUERYENQ.