When I have logged on to a MVS system I sometimes need to know which DB2 subsystems are available on this MVS. Previously I did this by using SDSF or SYSVIEW and display the active tasks matching the filter *DBM1. It works and if you know about MVS control block structures for active tasks you may produce the list using a program, but it is a bit clumsy. This solution has also the disadvantage of being unable to show you which data sharing group the different DB2 subsystems belong to.
Fortunately all this information is available in storage if you know where to look and how the information is linked together. It took me some time to figure out, but here is the result. I have coded my program in PL/I. If you prefer another programming language you will have to perform the required translation yourself. Let me start with the necessary declarations:
A DB2 subsystem has to be defined as a MVS subsystem in order to run on a MVS system. All subsystems on a MVS are defined in the SSCT (SubSystem Control Table). The PSA, CVT and JESCT are areas which you have to traverse in order to get to the SSCT. In the SSCT there is a pointer to the socalled ERLY which I do not quite understand the use of except it contains the name of the data sharing group and identifies the MVS subsystem as being a DB2 subsystem. The following code shows you how to navigate the above areas:
I cannot guarantee that the above code works on your MVS, because the information in the SSCT is not standardised. The fields in the SSCT prior to the ssvt_pointer must conform to certain rules but the ssvt_pointer and the following fields are defined by the subsystem. This is the reason why I validate the ssvt_pointer and erly_pointer against the address range of MVS. Before I introduced these validations my program abended on some MVS systems.
After the first successful execution of the above code I was surprised to see that a lot of DB2 subsystems which I had never heard of were defined as subsystems without being active. You may experience the same situation. On the other hand you are able to find the active ones which is far more interesting. If the groupname field is blank the DB2 subsystem is not connected to any data sharing group. You may use the product id to find out which version of DB2 the subsystem belongs to when you are running version 6, 7 or 8, but I do not know if it works for DB2 9.