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
 

 

Can we write a PS file opened in IO mode

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

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Thu Dec 15, 2011 11:52 pm    Post subject: Can we write a PS file opened in IO mode
Reply with quote

Hi,

I have used a PS file in my cobol program to open it in IO mode. I need to read the file and do some manipulation and also i need to write the same file once again when the program abends. but when i write the PS file it shows "write failed". is it because i have opened the file in IO mode.

Note: the file would have only one record every time the program runs or no records.

Could you please suggest of any idea?. Whether REWRITE option could resolve it ?.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Dec 16, 2011 12:04 am    Post subject: Reply to: Can we write a PS file opened in IO mode
Reply with quote

If the file is truly empty and the COBOL program attempts to Open it as I-O (really should be OUTPUT), this will raise an error.

Can you prime the file in a previous step, by writing a single record to it?

The record-contents are yours to choose, but a LOW-VALUES record is used quite often as a "Primer".

When your program Opens the file as I-O, you need to Read the file (maybe or maybe not) and bypass this LOW-VALUES record.

But the fact that the file contains a LOW-VALUES record will allow the Open I-O to occur.

HTH....

Mr. Bill
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Fri Dec 16, 2011 12:55 am    Post subject:
Reply with quote

Good afternoon!

When opening the file as I-O if you get a status of X'05' then you know that the file is empty and should be doing a write to the file otherwise if you are to modifying the record then you should be doing a rewrite to the file. If no condition is raised on the open then you should have a counter or flag for the input records and when reading the input at end condition you should test the counter or flag for records read if no records were read then should be doing a write to the file otherwise if you are to modifying the record then you should be doing a rewrite to the file.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7255

PostPosted: Fri Dec 16, 2011 1:17 am    Post subject: Re: Can we write a PS file opened in IO mode
Reply with quote

abdulrafi wrote:
Hi,

I have used a PS file in my cobol program to open it in IO mode. I need to read the file and do some manipulation and also i need to write the same file once again when the program abends. but when i write the PS file it shows "write failed". is it because i have opened the file in IO mode.

Note: the file would have only one record every time the program runs or no records.

Could you please suggest of any idea?. Whether REWRITE option could resolve it ?.


If'm confused. Can you please re-state what you are trying to do with the file?

If you have errors, can you post the errors as produced in full, including any messages on the job output. Do you know the file-status you received?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Dec 16, 2011 1:36 am    Post subject: Re: Can we write a PS file opened in IO mode
Reply with quote

abdulrafi wrote:
i need to write the same file once again when the program abends.


It is very difficult to write to a file after the program abends!
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: Fri Dec 16, 2011 3:55 am    Post subject:
Reply with quote

Hello,

Quote:
I have used a PS file in my cobol program to open it in IO mode. I need to read the file and do some manipulation and also i need to write the same file once again when the program abends.
Why was this choice made. . . icon_confused.gif

None of the systems i've worked on in a very long time permits this. It is just a terrible design.

I'm sure there are some who can say they "had to do this", but i've not yet seen a business or technical reason to do so. Of many implementations, this is usually the worst possible choice.

Just because it can be made to work sometimes, is NO reason to do this.
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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm


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