View previous topic :: View next topic |
Author |
Message |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Tue Mar 06, 2018 4:40 pm Post subject: Is it possible to write to two members of a PDS in COBOL |
|
|
I have a COBOL program which writes multiple jobs to the Internal Reader. I would like to save one copy of each JCL run to individual members of a PDS.
Before I run each set of JCL on the Internal Reader, I perform a dynamic allocation of the output file using the BPXWDYN program. These members do not exist, but the PDS does exist.
I call BPXWDYN the first time using:
Code: | ALLOC DD(OAUDTJCL) DSN(dataset-name(member1)) OLD REUSE |
I display the return code, which is 0.
I then do a COBOL OPEN OUTPUT statement of the AUDIT-JCL-FILE (whose DDNAME is OAUDTJCL). I write JCL lines to this file and the Internal Reader. I then close the AUDIT-JCL-FILE.
After I close the file, I then attempt to free the file by calling BPXWDYN:
Code: | FREE DSN(dataset-name(member1)) DD(OAUDTJCL) |
I display the return code which is also 0. The Internal reader job works as expected and dataset-name(member1) contains the JCL that was just run.
I then try to reallocate another member in the same PDS using similar logic.
Code: | ALLOC DD(OAUDTJCL) DSN(dataset-name(member2)) OLD REUSE |
This fails in BPXWDYN with a 032P error.
I also get the following error message:
Quote: | THERE WAS AN UNSUCCESSFUL OPEN OR CLOSE OF FILE OAUDTJCL IN PROGRAM program-name AT RELATIVE LOCATION X'1316'.
NEITHER FILE STATUS NOR AN ERROR DECLARATIVE WERE SPECIFIED. THE STATUS CODE WAS 96. |
The error related to this is NO DD Statement for the file .
I have tried a number of combinations including not FREEING the file and just allocating the 2nd file, changing the order of processes (freeing the file before closing), etc. No combination seems to work.
Is it possible to dynamically allocate files and point to different physical output files assigned to the same DDNAME during a single run of a job? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Wed Mar 07, 2018 10:38 am Post subject: Re: Is it possible to write to two members of a PDS in COBOL |
|
|
jim haire wrote: |
After I close the file, I then attempt to free the file by calling BPXWDYN:
Code: | FREE DSN(dataset-name(member1)) DD(OAUDTJCL) |
|
Jim,
Do not issue the FREE after the CLOSE as you intend to use the same DDNAME for another file. So a simple close of the file will do. And then you can once again allocate another file to the SAME DDNAME.
I suggest that you use SHR REUSE instead of OLD REUSE on the ALLOC statement unless you truly need an exclusive lock on the PDS members
BTW check this topic which reads the entire pds and dynamically allocates the members
https://www.mvsforums.com/helpboards/viewtopic.php?p=48493#48493 _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Wed Mar 07, 2018 11:34 am Post subject: |
|
|
Thank you Kolusu. This worked perfectly!
One more question. After my final allocation and processing, should I attempt a "FREE" or will the termination of the COBOL program do that for me?
Thanks again! |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Wed Mar 07, 2018 12:12 pm Post subject: |
|
|
jim haire wrote: | Thank you Kolusu. This worked perfectly!
One more question. After my final allocation and processing, should I attempt a "FREE" or will the termination of the COBOL program do that for me?
Thanks again! |
Jim Haire,
The COBOL Termination exit will automatically take care of Freeing the DDNAME, so you really do not have to issue FREE command. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|