Page 1 of 1

How can I delete disk files based on names in another file?

PostPosted: Mon Jan 28, 2013 9:33 pm
by Okonita
Hello all,

I need to delete many files each time I run a particular job.
What I have tried and will like to do is to create a file which contains names of the files that I want to delete.

For example, the input file will look like the following:

Input_File:

GO1.OSCR.D1UNL.GO1DDEV1.GO1SCAM1.PUNCH,DISP=(OLD,DELETE,DELETE)
GO1.OSCR.D1UNL.GO1DDEV1.GO1SCJR1.PUNCH,DISP=(OLD,DELETE,DELETE)
GO1.OSCR.D1UNL.GO1DDEV1.GO1SDNF1.PUNCH,DISP=(OLD,DELETE,DELETE)
GO1.OSCR.D1UNL.GO1DDEV1.GO1SGAJ1.PUNCH,DISP=(OLD,DELETE,DELETE)
GO1.OSCR.D1UNL.GO1DDEV1.GO1SGCT1.PUNCH,DISP=(OLD,DELETE,DELETE)
...

I tried the following JCL which ran fine but did not delete the datasets I am interested in:
//UTL1000U EXEC PGM=IEFBR14
//DD01    DD DSN=GO1.OGADM31.ATEMPFIL,DISP=SHR
//*

Can anyone suggest a way to accomplish what I need to get done?
I will greatly appreciate any help that I can get.

Thanks

Re: How can I delete disk files based on names in another fi

PostPosted: Mon Jan 28, 2013 9:44 pm
by Akatsukami
IEFBR14 does nothing but a branch to the (return) address contained in register 14, hence the name. It will not interpret or reformat data included in a data set; indeed, it will do nothing to it (the dispositive processing is done by MVS).

If your data set contains good JCL, you could make it a member of a private proclib and add it to your IEFBR14 step via the INCLUDE statement. Alternatively, you could use the tool of your choice (I'd use Rexx) to create IDCAMS control statements that delete those data sets.

Re: How can I delete disk files based on names in another fi

PostPosted: Tue Jan 29, 2013 1:39 am
by NicC
use the tool of your choice (I'd use Rexx) to create IDCAMS control statements that delete those data sets

or just convert the data into idcams delete statements by hand and feed the dataset into idcams via sysin. No need to go writing a rexx program to do a simple 1-off task. Using ISPF editor commands it will be much quicker to do the change than designing, writing and debugging the program.

Re: How can I delete disk files based on names in another fi

PostPosted: Tue Jan 29, 2013 1:55 am
by Akatsukami
NicC wrote:
use the tool of your choice (I'd use Rexx) to create IDCAMS control statements that delete those data sets

or just convert the data into idcams delete statements by hand and feed the dataset into idcams via sysin. No need to go writing a rexx program to do a simple 1-off task. Using ISPF editor commands it will be much quicker to do the change than designing, writing and debugging the program.

I'd understood from
I need to delete many files each time I run a particular job

that this task would be repeated many times, perhaps indefinitely. Could be that I misunderstood, of course.

Re: How can I delete disk files based on names in another fi

PostPosted: Tue Jan 29, 2013 10:26 pm
by Okonita
Hi all,

I just tried the IDCAMS suggestion but I am getting the following error:

DELETE GO1.FDBEV1.OSCR.D1UNL.GO1SCAM1.PUNCH
IDC3012I ENTRY GO1.FDBEV1.OSCR.D1UNL.GO1SCAM1.PUNCH NOT FOUND
IDC3009I ** VSAM CATALOG RETURN CODE IS 8 - REASON CODE IS IGG0CLEG-42
IDC0551I ** ENTRY GO1.FDBEV1.OSCR.D1UNL.GO1SCAM1.PUNCH NOT DELETED
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 8

What am I doing wrong here? What is VSAM CATALOG RETURN CODE IS 8 - REASON CODE IS IGG0CLEG-42? Of course I am going to research this further but your answers are always a pleasure to read...

Thanks

Re: How can I delete disk files based on names in another fi

PostPosted: Tue Jan 29, 2013 10:42 pm
by steve-myers
I'm not going to research the codes in the messages for you, but I will tell you the 3 most common errors. You can do the donkey work, which you should have done before posting here.
  • The data set name is not cataloged.
  • The data set name is cataloged, but the data set does not exist on the volume where it is cataloged.
  • The data set is cataloged on a tape volume.
What you have to do depends on the error that you determine after analyzing the codes in the message.

Re: How can I delete disk files based on names in another fi

PostPosted: Wed Jan 30, 2013 1:06 am
by Okonita
Steve-myers,
THank you for that information. I did look it up and yes it does exist on my catalog but no entry in the VTOC...something to that effect. It appears I have to add a few extra (optional parms) to get it to work like NONVSAM and PURGE.

That begs the question, why do they call it optional parameters...oh, well

Again Thanks

Re: How can I delete disk files based on names in another fi

PostPosted: Wed Jan 30, 2013 1:24 am
by Robert Sample
They are optional parameters becasue the command does not require them. However, depending upon what you are wanting to do, those "optional" parameters may not be optional. Deleting a VSAM data set, for example, does not require the NONVSAM parameter -- hence NONVSAM is optional and not required by the IDCAMS DELETE -- yet if you want to delete a data set that is not VSAM, that NONVSAM becomes mandartory not optional.

Re: How can I delete disk files based on names in another fi

PostPosted: Wed Jan 30, 2013 5:56 pm
by Okonita
Thank you very much Mr. Sample. Response much appreciated.