A while ago I was asked about the name of the dead letter queue of a MQ system. I did not know the naming convention for dead letter queues on the installation and had to pass on the question. Then it stroke me that it must be possible to look up the name. And of course you can by using the MQ administration system or by using a program.
The easiest way is by using the command TSO MQM. You must fill in the different MQ manager fields correctly on the main panel.Then you must use 1 in the Action field, QMGR (or MANAGER) in the Object field and then press Enter. On the displayed panel you will see the name of the dead letter queue in the field Dead-letter Queue. You will also notice that there are a lot of other information about the queue manager on the panel. You are also able to page through more panels filled with more or less interesting information. When you go back to the main panel please notice that if you place the cursor in the Object type field and press F4 you get a list of all types of information you are able to extract from the MQ administration system. There are lots of information to extract.
You can extract all the information you are able to extract from the MQ administration system using a program by calling the MQINQ function. Here is an example of a PL/I function that returns the name of the dead letter queue for the MQ subsystem that the program is connected to:
In order to make the above piece of code work properly you must use the correct includes/copybooks (CMQP and CMEPP). Your program must also issue a MQCONN if you execute the program in batch or from TSO. Please note that the variable objdesc.objecttype corresponds to field Object type in the TSO MQM main panel. The difficult part is to find the MQ variable that corresponds to the Object type you are interested in extracting information about. Here I have used the one corresponding to the object type QMGR. It is possible to fetch more fields with one call, but I have chosen to fetch only one as stated in variable selectorcount. The information I am interested in I specify in the variable selectors(1). Here I need to use the MQ variable that corresponds to field Dead-letter Queue. The result of the call to MQINQ is stored in the variable charattrs.
To simplify the the example I do not examine the value of mqrc and mqreas after each call. You must of course remember to do so. Especially you must remember to execute a MQCLOSE after MQINQ or you risk to run into serious trouble. You can read more about MQINQ in the manual MQ application reference. The link leads you to a recent version of the bookshelf containing MQ manuals which unfortunately are available only in PDF format. That is why I have not supplied a link directly to the chapter describing MQINQ because it takes quite a while to download the PDF version.