Deleting a File That Is “In Use”

Let’s step away from CICS for a minute and look at an issue that comes up from time to time … You want to delete a file, perhaps an old, uncataloged version of a dataset that is always open – say, SYS1.PROCLIB. If you go to the DSLIST screen in TSO (option 3.4) and enter the dataset name and volume, and try to delete it, you will be informed that the delete failed because the dataset was in use. There is a SYS1.PROCLIB in use, but it’s not the one you are trying to delete. You know what you are doing, but z/OS doesn’t trust you, it seems. (Actually, it’s just that z/OS enqueing is by dataset, not dataset and volume.) The way around this is to “zap” the VTOC to change the name of the dataset to something else that is not in use; then you can delete it.

To zap the VTOC of the volume containing the dataset to be deleted, first we need to find out exactly where the text specifying that name is. To do so, run the AMASPZAP utility, specifying the ABSTDUMP ALL paramter. Here is some sample JCL to dump the VTOC on volume VOL999:

//STP1    EXEC PGM=AMASPZAP,REGION=4096K
//SYSLIB   DD  DISP=OLD,DSN=FORMAT4.DSCB,
//             UNIT=3390,VOL=SER=VOL999,
//             DCB=(KEYLEN=44)
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
 ABSDUMPT ALL

In the output from this utility, find the dataset name that you wish to change. The hardware address (CCHHR) will be shown for it. Enter that, along with the text to be changed, in another AMASPZAP job. Let’s assume that the output showed the VTOC entry to be at CCHHR 0517000507, and all we want to do is change the first letter, S (hex E2), to a Z (hex E9). Here is some sample JCL to accomplish this:

//STP1    EXEC PGM=AMASPZAP,REGION=4096K
//SYSLIB   DD  DISP=OLD,DSN=FORMAT4.DSCB,
//             UNIT=3390,VOL=SER=VOL999,
//             DCB=(KEYLEN=44)
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
 CCHHR 0517000507
 VER 00 E2
 REP 00 E9
 /*

Anytime that AMASPZAP is used to change data, be very careful. I usually run such a job with just the VER (verify) statements to ensure that I am hitting the data I expect before adding the REP (replace) statement.

Finally, the VTOC index needs to be changed to the old “OS” format before the dataset can be deleted. To do this, use the ICKDSF utility:

//CNVTOS EXEC PGM=ICKDSF
//DD1      DD UNIT=3390,DISP=OLD,
//         VOL=SER=VOL999
//SYSIN    DD *
 BUILDIX DDNAME(DD1) OS NOPURGE

Find the new dataset name for the file, ZYS1.PROCLIB in this example, and delete it using the DSLIST panel or any other way in which you feel comfortable. Then, convert the index back to “IX” format:

//CNVTIX EXEC PGM=ICKDSF
//DD1      DD UNIT=3390,DISP=OLD,
//         VOL=SER=VOL999
//SYSIN    DD *
 BUILDIX DDNAME(DD1) IX

That’s it! Put this little process away into your systems programmer bag of tricks, as it is all but certain you will need it one day.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s