0

We have a Job which takes a Back-up of VSAM file followed by standard Delete-Define-Repro of the same VSAM file. To handle the scenario of trying to delete a non-existing file we are following a standard practice to set MAXCC/LASTCC to 0 if Delete returns a non-zero return code and then continue the process as if there are no errors.

But sometimes we are facing a situation where Delete is not working because file is opened by some user or being read in some other Job. In this case Job fails because while Defining a new VSAM file because file is already present (Delete could not purge it).

Any work-arounds for this situation? Or can we force delete a file even if it is held by some other process/user?

Thanks for reading!

Mayur Manani
  • 795
  • 4
  • 12
  • I can understand making a backup of a file, and then delete/recreating it. But backing it up and delete/recreate while another process holds it is difficult to understand - you pretty much have to crash whatever process holds the file - doesn't sound very polite to me! I think a bit more analysis of this situation is warranted. – NealB Jan 28 '13 at 20:13
  • I agree with you and have the same feeling about this situation but this question was asked by one of my friends and he wanted to force delete the file anyhow! Anyway, thanks for the help! – Mayur Manani Jan 29 '13 at 04:52

1 Answers1

2

You should be able to work out that it would not be a good idea to delete a VSAM file (or any other) whilst it is being used by "something else".

Why don't you test for the specific value from the DELETE?

If you are doing a backup, then delete/define, it would be a really, really good idea to get exclusive control of the file, else something is going to get messed-up.

You could put a DD with DSN being the VSAM file in question with DISP=OLD, so that your job would only be selected when nothing is using the file.

How are you doing the backup? Why are other jobs accessing the file at the same time anyway? Is this in a "test" environment? What type of VSAM file is it? Why are you doing the REPRO, and do you feel that that is the best way to do it?

An actual answer is difficult without knowing all this, and more.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
  • I am Sorry but I do not have all those details as this question was asked by one of my friends and I could not think of a solution so thought of seeking help here. Thanks! – Mayur Manani Jan 29 '13 at 04:54
  • The DISP=OLD trick is the best answer in this scenario. One up vote from me. – MikeC Jul 02 '13 at 22:47