IBM Support

How can I free a library specified on ISPF table service call?

Question & Answer


Question

I have a dialog that uses table services with the LIBRARY parameter. After the TBCLOSE, if I try to free the data set, I get message FILE MYTAB NOT FREED, DATA SET IS OPEN

For example, I allocate ddname mytab like this:

 address tso 'alloc dd(mytab) dataset(test.table) shr reu' 

then do so some table processing, then close the table like this:

 'tbclose testwrit library(mytab)'

I expect to be able to free the ddname, like this:

 address tso 'free fi(mytab)'  

   

but instead I get an error.

Answer

Here's a trick that will let you free the data set. Use the LIBDEF service to allocate the ddname to a data set that does not exist. Then invoke a table service with that ddname in the library keyword. This will cause ISPF to close the old data set before trying to use the new one. You will need to use CONTROL ERRORS RETURN to get control back after the table service gets an error. Here's a code snippet:

     'control errors return'              
     'libdef mytab dataset id(dummy)'     
     'tbopen testwrit library(mytab)'     
     'libdef mytab dataset id()'          
     

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSBLLD","label":"ISPF for z\/OS"},"Platform":[{"code":"PF035","label":"z\/OS"}],"Component":"","Version":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
05 September 2017

UID

dwa1398824