MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is it possible to write to two members of a PDS in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
jim haire
Beginner


Joined: 30 Dec 2002
Posts: 140
Topics: 40

PostPosted: Tue Mar 06, 2018 4:40 pm    Post subject: Is it possible to write to two members of a PDS in COBOL Reply with quote

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. Very Happy

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. Crying or Very sad

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Wed Mar 07, 2018 10:38 am    Post subject: Re: Is it possible to write to two members of a PDS in COBOL Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
jim haire
Beginner


Joined: 30 Dec 2002
Posts: 140
Topics: 40

PostPosted: Wed Mar 07, 2018 11:34 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Wed Mar 07, 2018 12:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group