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

Can we write a PS file opened in IO mode


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Thu Dec 15, 2011 11:52 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Dec 16, 2011 12:04 am
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: 121
Location: Puerto Rico

PostPosted: Fri Dec 16, 2011 12:55 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 16, 2011 1:17 am
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
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

Moderator Emeritus


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

PostPosted: Fri Dec 16, 2011 3:55 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts HILITE on Browse mode? TSO/ISPF 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top