Usually I don't update my tips after they have been published. If I were a politician, it would happen all the time without telling you. I think I have a very good reason for updating this tip, because Johnny Mossin, one of my faithful readers and a good friend of mine, told me that IDCAMS is indeed able to delete lots of members from the same dataset without having to allocate and deallocate for every member. Here is an example of how it is done:
You can repeat the line in SYSIN as many times as you like with different member names and there will only be one allocation like when you are using IEHPROGM. The rest of the tip is the originally published text. See the updated danish version by clicking here.
When you want to delete members in a PDS or PDSE it is fairly easy if you only want to delete a single member or up to 10 to 15 members. The easiest way is to use the facilities in ISPF. But how is a lot of selected members deleted, especially if you have to delete hundreds or maybe thousands. Let us look at some of the possibilities:
This step deletes member MYMEMBER in dataset MY.MEMBER.DATASET if the member exists and if the dataset is located on volume MYVOL1. It is very irritating that you have to find out which volume the dataset is located on prior to execution of the job. It is in fact pretty ludicrous because you almost never worry about which volume a dataset is located on. IEHPROGM is the only IBM utility program that is able to delete members, so you have to care about volumes, if you want to use this program. The input line in SYSIN can be repeated as many times as you have members to delete, then all you need is to change the member names. This is straight forward if you have a list of the members to be deleted in another dataset or member.
Of course you can use the IDCAMS delete command:
This is easy, no volumes. The problem with IDCAMS is that it allocates and de-allocates the dataset for every single delete statement, so if you have 500 members to delete in the same dataset, IDCAMS will allocate and de-allocate the same dataset 500 times and that will take some time. IEHPROGM will only allocate and de-allocate once.
You can also code your own delete REXX. Then it will be suitable to use ISPF-services to delete the members. Here is an example:
This REXX does exactly the same as the two other examples. The REXX can be modified in several ways. An input parameter could be the dataset name and maybe the name of a dataset containing the list of the members to be deleted. If you want to delete many members in the same dataset all you have to do is to repeat the LMMDEL service for every member. The other services only needs to be executed once for every dataset. In this way the REXX will only allocate and de-allocate once for every dataset like the IEHPROGM utility.