Joined: 28 Dec 2006 Posts: 27 Location: Baltimore, MD 21215
I have managed to figure out how to use BPXWDYN in a COBOL program to dynamically allocate files.
I can allocate new files, if I just stick to using two disposition parameters (i.e. DISP=(NEW,CATLG) - or in BPXWDYN terminology: NEW CATALOG
But is there a way to get it to recognized a third dipsosition option ??
Specifically, I want to allocate the new dataset as:
DISP=(NEW,CATLG,KEEP). - so that the file will be retained in an ABENDED outcome.
This first attempt failed on syntax. The failed allocation string was:
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
The BPXWDYN documentation for dynamic allocation refers to the TSO ALLOCATE command syntax, which does not support the option you're wanting to use. Since BPXWDYN is pretty closely based on the TSO ALLOCATE command, I suspect it is not possible to provide the abnormal termination disposition to BPXWDYN.
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
In an SMS environment you would not be allowed to keep an uncatalogued dataset - and why would you. If, in an abend situation, you need to look at the file as part of your diagnosis then surely you would need it catalogued anyway so that you can find it.
Joined: 28 Dec 2006 Posts: 27 Location: Baltimore, MD 21215
Thanks to all the responses. They inspired me to re-read the BPXWDYN documentation and read up on the 'TSO ALLOCATE' documentation.
It would appear that unlike JCL, BPXWDYN only offers two disposition options:
(1) the status option i.e. OLD, SHR, MOD, NEW
(2) the 'free up' option (my nickname) - CATALOG, UNCATALOG, KEEP, DELETE. The free-up option is where you enter the desired disposition for the dataset after it is freed up (i.e. after the process completes regardless of whether it is a normal completion or abended completion)
I ran many tests and for example discovered that:
==> When using NEW without any accompanying free-up option, the dataset gets allocated as new, BUT, after the process finishes successfully (i.e. no abend), the dataset is NOT retained. (i.e. as if I had used NEW DELETE).
==> When using NEW CATALOG, the dataset gets allocated as new, AND, after the process finishes the dataset is retained in the catalog, EVEN if the process abended in the middle. By the way, I get the same result when I use NEW KEEP. I guess in an SMS environment, KEEP and CATALOG do the same thing. (needless to say, the dataset gets retained in the catalog when the process finishes successfully without abending).
==. When using MOD DELETE, I can safely delete any pre-existing versions of a dataset using BPXWDYN, and I will still get a zero return code even if there are no pre-existing versions.
If I am correct in my conclusions, I guess BPXWDYN does not offer that convenient flexibility of having an ABEND automatically delete a dataset. However, if it is an ABEND that I forced on my own in the program, at least we can manually delete it by calling BPXWDYN using MOD DELETE.
thanks again to everyone who helped. Feel free to reply if you disagree with my conclusions.