IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Invoke the PUTENV utility from a COBOL program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Wed May 28, 2008 3:02 pm
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
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 191
Location: USA

PostPosted: Wed May 28, 2008 3:05 pm
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

Moderator Emeritus


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

PostPosted: Wed May 28, 2008 10:22 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top