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
 

 

Error 48 while writing into sequential file in COBOL

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

New User


Joined: 28 Nov 2010
Posts: 53
Location: Mumbai

PostPosted: Tue Jul 23, 2013 7:02 pm    Post subject: Error 48 while writing into sequential file in COBOL
Reply with quote

Hi ,

I was trying write into sequential file but was getting return code '48'.
Here i have opened sequential file in sequential mode, and opened in I-O mode.
In this program and i read the sequetial file and if certain criteria met then i will add new record in same file.

Can any one pleas suggest how resolve this error.?

Thanks,
Pavan
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Jul 23, 2013 7:06 pm    Post subject:
Reply with quote

A file status code 48 (which is what I assume you meant instead of return code '48' -- terminology is critical in IT where similar things may mean very different things, and "return code" only occurs when the program is ended, not on any type of I/O operation) means (from the COBOL Language Reference manual:
Quote:
The execution of a WRITE statement was attempted on a file not open in
the I-O, output, or extend mode.
So to answer your question as to how to resolve this error -- OPEN THE FILE, CHECK THE FILE STATUS CODE ON THE OPEN, AND DO NOT ATTEMPT TO WRITE TO THE FILE IF YOU DO NOT GET A 00 FILE STATUS CODE ON THE OPEN.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Tue Jul 23, 2013 7:11 pm    Post subject:
Reply with quote

Also, why do you want to possibly corrupt your input file by writing to it? Create a new file or be prepared to pay for the extra overhead in recovering your input file.
Back to top
View user's profile Send private message
Pavankumar.m
Warnings : 1

New User


Joined: 28 Nov 2010
Posts: 53
Location: Mumbai

PostPosted: Tue Jul 23, 2013 7:16 pm    Post subject: Reply to: Error 48 while writing into sequential file in COB
Reply with quote

hi Robert,

Thanks for your time.

While opening the file i am getting status code '00'.
Is there any special consideration i need to take ?..
Even i am able to read the records sucessfully, but only while writing getting isssue.

Thanks,
Pavan Kumar.M
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Tue Jul 23, 2013 7:21 pm    Post subject:
Reply with quote

Are you saying that, for example, you have a 100 record dataset and if the conditions are right when you are record 10 you want to write a record at that point? Well, you cannot as your new record has to go at the end of the file. You can use REWRITE to replace your current record but that is all.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Jul 23, 2013 7:22 pm    Post subject:
Reply with quote

Did you read the COBOL Language Reference manual on the WRITE statement? It starts
Quote:
6.2.40 WRITE statement


The WRITE statement releases a logical record to an output or input/output file.

When the WRITE statement is executed:

The associated sequential file must be open in OUTPUT or EXTEND mode.

The associated indexed or relative file must be open in OUTPUT, I-O, or EXTEND mode.
Your file is sequential -- so you posted.
You cannot open it I-O and expect to WRITE to that file.
Back to top
View user's profile Send private message
Pavankumar.m
Warnings : 1

New User


Joined: 28 Nov 2010
Posts: 53
Location: Mumbai

PostPosted: Tue Jul 23, 2013 7:28 pm    Post subject: Reply to: Error 48 while writing into sequential file in COB
Reply with quote

Hi Nic,

As per your example, i after reading 10th record, if 10th record matches
certail criterial, then i will adding new record in 11th row.

At this time 11th become 12....at total will be 101 records. No i dont want to write at end.

Thanks,
Pavan.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Jul 23, 2013 7:35 pm    Post subject:
Reply with quote

What you want to do CANNOT be done the way you want to do it -- period.
Writing a new record occurs at the end of the file -- period.

You may open your file for input, open a DIFFERENT file for output, and copy records from input to output, adding records as appropriate, but you cannot write a new 11th record in the existing file without destroying all records after old record number 10.
Back to top
View user's profile Send private message
Pavankumar.m
Warnings : 1

New User


Joined: 28 Nov 2010
Posts: 53
Location: Mumbai

PostPosted: Tue Jul 23, 2013 7:39 pm    Post subject: Reply to: Error 48 while writing into sequential file in COB
Reply with quote

Hi Nic\Robert

Thanks alot for your inputs, as suggested will create new file.

Thanks,
Pavan.M
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Tue Jul 23, 2013 7:40 pm    Post subject:
Reply with quote

By the way - you do not add a record at a 'row'. A row is a record in a DB2 table.
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 S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 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 Invoke Webservice Fails with DFHPI100... divated CICS 2 Thu Nov 24, 2016 5:57 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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