MainframeSupports
tip week 28/2009:

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:

working storage section.
01 localEoTiot pic s9(9) binary.
01 areaAddress pic s9(9) binary.
01 filler redefines areaAddress.
  02 areaPointer pointer.
01 areaLength pic s9(4) binary.
01 filler redefines areaLength.
  02 areaChar pic x(2).

linkage section.
01 psa.
  02 filler pic x(536).
  02 tcbpointer pointer.
01 tcb.
  02 filler pic x(12).
  02 tiotPointer pointer.
01 tiot.
  02 jobname pic x(8).
01 tioe.
  02 tioelngh pic x(1).
  02 tioestta pic x(1).
  02 filler1 pic x(2).
  02 ddname pic x(8).
  02 jfcbtoken pic x(3).
01 eoTiot pic s9(9) binary.

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:

move 0 to areaAddress
set address of psa to areaPointer
set address of tcb to tcbPointer in psa
set address of tiot to tiotPointer
set areaPointer to tiotPointer
add 24 to areaAddress
set address of eoTiot to areaPointer
move eoTiot to localEoTiot
perform until localEoTiot = 0
  set address of tioe to areaPointer
  display ddName in tioe
  move tioelngh to areaChar(2:1)
  add areaLength to areaAddress
  set address of eoTiot to areaPointer
  move eoTiot to localEoTiot
end-perform

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.

Previous tip in english        Sidste danske tip        Tip list