LongEx Mainframe Quarterly - February 2011
Catalogs are essential for anyone accessing z/OS datasets, including z/OS itself. However accessing information from these catalogs has not necessarily been straightforward. This article looks at doing exactly this: accesssing catalog information. Both from interactive sessions, and programs. Catalogs are special datasets that hold information about traditional z/OS datasets. From humble beginnings tracking which physical device each dataset was on, catalogs today hold information like:
Although UNIX Systems Services file and directories don't use the z/OS catalogs,
everyone dealing with all other z/OS datasets use them every day. From creating
dataset lists to opening a dataset, you're accessing the catalog. ISPF SessionsLet's start with the no-brainer: ISPF option 3.4 (DSLIST).
This is the classic utility for listing datasets. Any TSO/E user with datasets will use 3.4 every day to list and manage their datasets. Although you can specify a volume serial number when creating the dataset list, no-one ever does, and so the dataset lists come straight from the z/OS catalogs. However 3.4 doesn't immediately give you a lot of catalog information; just the dataset name and volume where it is found. Putting an I next to the dataset will give you more information, including VSAM-related information. DSLIST is limited in the dataset lists it can produce it can only be used to list datasets based on their name. If you want a list of all VSAM indexes beginning with 'PROD', DSLIST can't help you. Included free with z/OS, the ISPF based Interactive Storage Management Facility (ISMF) is a valuable tool for storage administrators to manage DFSMS rules and classes. However it is also a far more powerful utility for listing and managing datasets. Tailored dataset lists based on any catalog-related information can be produced. However you won't find many people who enjoy using the user-unfriendly panels. Use of ISMF is also restricted by many mainframe sites.
ISMF is also the weapon of choice for obtaining ATL and tape information from the catalog. Both ISMF and ISPF designed for the ISPF user. If you need access to catalog information from a program or batch job, they're not going to help you. LISTCATThe Access Method Services LISTCAT command is the command to access all catalog
information. Although it is the bread-and-butter interface for catalogs and
VSAM datasets, many are scared off by the confusing syntax. For example, to
simply list all the catalog information for the dataset DASP1.C.SOURCE, the
command is:
However LISTCAT is very powerful. Not only will it list all catalog information, it can also produce dataset lists. In fact the often-overlooked LEVEL parameter will list of datasets based on a dataset name pattern. For example:
The NAME, HISTORY, VOLUME, ALLOCATION and ALL parameters provide at least some control over how much information is produced. LISTCAT can be called as a TSO/E command (LISTCAT), or from batch using the IDCAMS program: ISPF users can also use LISTCAT in 3.4 or ISMF by entering: For users who have no wish to start coding, calling LISTCAT from TSO/E and batch is the only way to access catalog information from batch and automation scripts. Because of this, there are a lot of tasks around that call LISTCAT, and then process the output using something like REXX, SAS or CA-EzyTrieve. However processing LISTCAT output in this manner is a risk. Any change to the format of the output may cause problems. This could be something as simple as a PDS changing to a PDS/E, or an index added to a VSAM Cluster. It could also come from IBM changing the format of the output; they did exactly this in z/OS 1.8. So how else can batch jobs and programs easily access catalog information?. CAMLIST and LOCATECAMLIST and LOCATE are the two basic assembler macros used to access the catalog, and are documented in the DFSMS Advanced Service manual. CAMLIST is used to specify what catalog information to get, and LOCATE does the work. For example:
This code will insert the volume(s) where the dataset DASP1.C.SOURCE resides in the 265 byte area LOCAREA. The first halfword is the number of volumes, followed by 12 byte areas holding:
CAMLIST and LOCATE can only be used with a fully qualified datasetname, GDG name or alias to return a volume list. It cannot be used to get any other information from the catalog. Similar information is returned by the TSO/E IKJEHCIR service, another option for programs running under TSO/E. Not only can IKJEHCIR get volume serial information, it can also get lists of dataset names based on a name pattern. The downside is that this pattern must be fully qualified (eg. USER1.PDS.): no wildcards allowed. Yet another option for programs running under ISPF is the TSO/E ICQGCL00 services, which can generate lists of datasetnames from criteria similar to IKJEHCIR. Catalog Search InterfaceIt's not all bad news for programmers needing to get access to the catalog. The DFSMS Catalog Search Interface (CSI) is what almost everyone turns to. It can be used to create tailored dataset lists with any catalog information you need from any programming language. IBM documents it in the DFSMSdfp Managing Catalogs manual. Callers call the program IGGCSI00, specifying an area to hold the output, and the selection criteria. This selection criteria can include wildcards (%, * etc.), and you can specify almost any catalog information to be used to generate the dataset list. Selection criteria also specifies what information is to be returned for each list. The CSI is also your only choice for obtaining ATL information from a program. Unfortunately, many programmers will be dismayed at the complexity needed to call this facility. Assembler programmers can see the samples in sys1.samplib, as can REXX programmers. Mark Zelden has built on the REXX sample with his catsrch.txt sample. PL/1 programmers can see Herman Vierendeel's sample in Xephon MVS Update Jan 2000. C programmers can also see an example in our Resources section. ConclusionCatalog remain critical to everyday z/OS operations, and we all use them every day. However IBM hasn't made the job of accessing catalog information easy. ISPF users have basic facilities that can help out. Users with a need to access information from programs, batch jobs and automation scripts often have relied on calling LISTCAT and processing the output. However investing the time in producing callable modules that use the Catalog Search Facility will never be time wasted. |