One of my very first tip were about the ISPF tool ISRDDN which I hope is an integrated part of your toolbox today. As you might know ISRDDN shows you all DD names and connected datasets allocated to your TSO session. Sometimes it would be very handy to have access to the DD names in batch. In fact it is quite easy to get access to all the DD names allocated to the step executing a batch program, but the information available is quite limited.
The following example written in COBOL shows you how to access the DD names. Those of you who prefer PL/I, C or REXX will have to create the corresponding piece of code. Here are the declarations needed in data division:
All variables declared in working storage are pure work variables. The interesting part is located using the linkage section variables. The PSA area is located in address zero and contains pointers to almost anything. The interesting pointer in our case is the address of the TCB area. In the TCB area is a pointer to the TIOT (Task Input Output Table) which contains all DD names allocated to the currently executing step. The TIOE area describes each DD name. The following piece of code lists all the DD names in TIOT:
The TIOT is rather unusual because each entry in the table has varying length. That is why the pointer addressing is pretty akward. If a TIOT entry represents a concatenated dataset then the DD name is blank (as far as I remember). The field JFCBTOKEN is a key to information about what is allocated to the DD name. Unfortunately it is only possible to translate JFCBTOKEN into a storage address by using assembler as far as I know.
Well now you may ask what the above example may be used for. I have found several applications. To look in the TIOT is far more elegant than the method I use back in week 10/2005. As the TIOT is located directly in storage it is far more efficient compared to executing an OPEN FILE. By looking in the TIOT you are able to avoid using an OPEN FILE which will fail if the DD name is not available. In PL/I you are able to open files with variable DD names which gives you many new possibilities combined with a scanning of the TIOT.