There are many ways of releasing unused space in ordinary datasets. You can use the RLSE parameter in the SPACE option in JCL. There is a command in ISPF 3.4 named F to do the same thing and there are lots of homegrown programs out there doing it. But what if High Used RBA is far away from High Allocated RBA on a VSAM dataset, then what to do?
There is a command for ADRDSSU that fixes the issue. It is called RELEASE and is extremely simple to use. I have created an example where I want to release a lot of free space in a DB2 tablespace being allocated way too big, which often happens in test environments:
//STOPDB EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DB2T) -STOP DB(D2900DB1) SPACE(S2900K74) END /* //RELEASE EXEC PGM=ADRDSSU //SYSPRINT DD SYSOUT=* //SYSIN DD * RELEASE INCLUDE(DB2T.DSNDBC.D2900DB1.S2900K74.J0001.A001) /* //STARTDB EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DB2T) -START DB(D2900DB1) SPACE(S2900K74) END /*
To make RELEASE work ADRDSSU needs the dataset exclusively and thus the DB2 tablespace must be stopped before RELEASE is carried out and then started again afterwards. If the VSAM dataset is in use by a CICS region you need to close the dataset inside CICS and open it again afterwards.
There are of course some downsides to the above approach, especially when it comes to VSAM datasets used for DB2 tablespaces. If the DB2 tablespace is heavily used it might be hard to find a time where it can be stopped and started again. And you also have to know the name of the VSAM dataset behind the DB2 tablespace. Fortunately there are many tools that can help you do this. The biggest challenge may be RACF authorisations. The user running the job must have both ALTER access to the VSAM dataset and STOP/START authorisation in DB2 to the DB2 database. Last thing is that some installations protects ADRDSSU so you also need to ensure that the user has access to execute ADRDSSU and use the RELEASE command.