Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Invoke the PUTENV utility from a COBOL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dcshnier

New User


Joined: 28 Dec 2006
Posts: 27
Location: Baltimore, MD 21215

PostPosted: Tue May 27, 2008 11:29 pm    Post subject: Invoke the PUTENV utility from a COBOL program
Reply with quote

Thanks to some fine examples on your forum, I have been able to successfully invoke the PUTENV utility from a COBOL program to dynamically allocate files.
I have successfully been able to allocate new output files (NEW CATLG) as well as input files (disposition of: SHR).

However, I have been unable to delete pre-existing files using PUTENV.

To illustrate.
Let us assume my COBOL program has decided to attempt the deletion of a possibly pre-existing file called:
'ABCD.IV.DEV.SQLSTMT.TESTDEL'.
It has assigned it the DDNAME: SQLSTMT2
The COBOL program then formats the following PUTENV string
to attempt the deletion:
SQLSTMT2=DSN(ABCD.IV.DEV.SQLSTMT.TESTDEL) OLD DELETE

The COBOL program then sets the address of the pointer to the above string and calls PUTENV.
I am finding that the call to PUTENV returns a zero return-code, however, the 'ABCD.IV.DEV.SQLSTMT.TESTDEL' dataset, if it pre-existed, does not get deleted. It is still present.
As mentioned, I have been able to successfully call the PUTENV utility to dynamically allocate new outut files (NEW CATLG) or input files (SHR).
I just cannot delete them using PUTENV.

As a work-around, I am calling the IDCAMS utility from the COBOL program in order to dynamically delete any pre-existing files. But this adds overhead. So my preference is to be able to handle everything from calling PUTENV.

Does anyone have any advice ?

thank-you greatly in advance for any assistance.

dcshnier
Back to top
View user's profile Send private message

jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Wed May 28, 2008 3:02 pm    Post subject: Reply to: Invoke the PUTENV utility from a COBOL program
Reply with quote

I don't have an answer to your question but I have advice. But I have advice. I think BPXWDYN is a better solution than putenv for dynamically allocating datasets within cobol. Using it is basically similar to using putenv. There are examples in this forum.

I think 'reuse' might need to be in the parm passed to putenv if the dataset exists.
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Wed May 28, 2008 3:05 pm    Post subject: Reply to: Invoke the PUTENV utility from a COBOL program
Reply with quote

Also, if you a newer version of cobol, extend might be a good solution. From quickref:

EXTEND Permits output operations that append to or create a file.

The EXTEND phrase is allowed for sequential access files only if
the new data is written in ascending sequence. The EXTEND phrase
is allowed for files that specify the LINAGE clause.

For QSAM files, do not specify the EXTEND phrase for a multiple
file reel.

If you want to append to a file, but are unsure if the file
exists, use the SELECT OPTIONAL clause before opening the file
in EXTEND mode. The file will be created or appended to,
depending on whether the file exists.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed May 28, 2008 10:22 pm    Post subject:
Reply with quote

Hello jasorn,

Please re-read the original post.

Your post mentions allocating and/or extending a dataset - the request is how to delete an existing dataset. . .

If you have something to offer about the request, let us know. Once this is done, i'll remove the un-related alloc/extend posts.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu May 29, 2008 12:03 am    Post subject:
Reply with quote

Just a guess, normally disp=(old,delete) deletes the dataset at the end of the step not immediately. Does this dataset still exist after the step ends?
I have not tried PUTENV from COBOL. I call IKJTSOEV then IKJEFTSR to dynamically allocate datasets or execute clists or REXX from COBOL. The delete command could be used this way.
Back to top
View user's profile Send private message
dcshnier

New User


Joined: 28 Dec 2006
Posts: 27
Location: Baltimore, MD 21215

PostPosted: Thu May 29, 2008 11:51 pm    Post subject:
Reply with quote

I want to thank everyone who have answered this thread thus far.

In response to Douglas Wilder's question: 'yes' the dataset that I am attempting to dynamically allocate as OLD, DELETE is still around even after job has entirely completed.

In response, to 'jasorn's' suggestion to use BPXWDYN, I am trying to run some BPXWDYN tests but I keep on failing with the return code of '20' (which according to the documentation means that I am passing an invalid set of parameters).
Perhaps anyone with experience calling it from a COBOL program could assist me on this. The only examples I have seen thus far are calls issued from a C program or REXX program.

For example - what should be the format in working storage of the parameter area where I move my allocation particulars?

If I wanted to allocate as DISP=SHR, this input file 'ABCD.INPUT.TEST'
what would the correct format of the passed parm? I have several variations such as:

ALLOC DD(IFILE) DSN(ABCD.INPUT.TEST) SHR

ALLOC DD(IFILE) DSN('ABCD.INPUT.TEST') SHR

ALLOC FI(IFILE) DA(ABCD.INPUT.TEST) SHR
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts How to Use DebugTool CodeCoverage Uti... neo4u IBM Tools 0 Thu Jun 22, 2017 6:38 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us