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:
//JOBCARD
//UTL1000U EXEC PGM=IEFBR14
//SYSUDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//DD01 DD DSN=GO1.OGADM31.ATEMPFIL,DISP=SHR
//SYSIN DD DUMMY
//*
Can anyone suggest a way to accomplish what I need to get done?
I will greatly appreciate any help that I can get.
Thanks
You could use IDCAMS using the IDCAMS delete command. So in your file you would have lines like:
DELETE GO1.OSCR.D1UNL.GO1DDEV1.GO
Then your JCL would be something like
//S01OF99 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=DSN=GO1.OGADM31.ATEMPF
Now, you could also use IEFBR14, but you would need a unique DD statement for each file that would look something like:
//FILE0001 DD DSN=GO1.OSCR.D1UNL.GO1DDEV
You need to use "MOD,DELETE" instead of "OLD,DELETE." If you use OLD and one of the files in the list did not exist, then you would get a JCL error. With "MOD,DELETE" if a file does not exist, the system will create it and then delete it right away.
If the files you are deleting are not SMS managed, then you would also need to add space and volume parameters in case the files don't exist.