How do you find out if a dataset exists on the mainframe. My guess is that you use DSLIST in ISPF (also known as menu item 3.4). If you then needed to find a dataset from a program I am pretty sure you hav coded a REXX and made calls to the ISPF services that performs the same functionality as DSLIST does. Maybe your need was just to find out wheteher a given dataset was already cataloged or not. In this case you have probably used the SYSDSN function and maybe you sometimes use LISTCAT to perform any of the above.
Actually there is a service in MVS called CSI (stands for Catalog Service Interface) which you may call from almost any programming language and is able to create lists of datasets and find individual datasets. My friend Johnny Mossin made me aware of CSI. Probably some of you already know CSI, but without Johnny I would never have discovered it. The advantage of CSI is that you avoid using ISPF services and you may also use CSI from other languages than REXX. By using CSI it is possible to retrieve all information hidden in the MVS catalog structure (that is a lot) and last but not least it runs extremely fast.
Unfortunately the interface to CSI is very hard to use, especially if you want to retrieve the many different data about a dataset. I will give you two examples on how to use CSI, one from PL/I and one from REXX. Both examples perform exactly the same function which is to retrieve the name of the volume where a specific dataset is located. This is very practical if you need to find out wheteher a dataset is migrated or not because CSI does not issue any HSM recall. In PL/I it looks like this:
And in REXX it looks like this:
In the PL/I function I have used the names from the CSI manual. I have not used any fields names in the REXX function, because REXX does not support structures. If the dataset name does not exist in the MVS catalog the volume serial variable will contain spaces and if it is migrated it will contain MIGRAT.
CSI only issues return codes not equal to zero if something went very wrong. The output area provided to CSI must be at least 1024 bytes long and the length of the output area must be present in the first four bytes in binary format. If you do not allocate storage in your program for the length provided in the first four bytes your storage may be destroyed or you may provoke a 0C4 abend. The same things may happen if you forget to put a reasonable value into the first four bytes.
You may use wildcards in the input dataset name. Then CSI will start returning all the dataset names with the requested information which matches your wildcard. Such a list of dataset information is returned in a special format described in appendix B in the manual Managing Catalogs. In this appendix you will find all the information IBM provides regarding CSI.