Solved

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

Posted on 2013-01-28
4
575 Views
Last Modified: 2013-01-29
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
0
Comment
Question by:Enyinnaya
  • 2
  • 2
4 Comments
 
LVL 57

Accepted Solution

by:
giltjr earned 500 total points
Comment Utility
IEFBR14 does not accept any "input" data.  It is a "dummy" program that clears the value in register 15 and then branches back to the "caller", which is the z/OS.

You could use IDCAMS using the IDCAMS delete command.  So in your file you would have lines like:

DELETE  GO1.OSCR.D1UNL.GO1DDEV1.GO1SCAM1.PUNCH

Then your JCL would be something like

//S01OF99 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=DSN=GO1.OGADM31.ATEMPFIL,DISP=SHR

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.GO1DDEV1.GO1SCAM1.PUNCH,DISP=(MOD,DELETE)

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.
0
 

Author Comment

by:Enyinnaya
Comment Utility
I just tried the IDCAMS suggestion and it did not work. I got the following error for all the files I wanted to delete:

 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

Is there something that I am doing wrong here?

Thanks
0
 
LVL 57

Expert Comment

by:giltjr
Comment Utility
That tells me the data set either does not exist or is not cataloged.
0
 

Author Comment

by:Enyinnaya
Comment Utility
I've requested that this question be closed as follows:

Accepted answer: 0 points for Enyinnaya's comment #a38831708

for the following reason:

Again thank you
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now