Page 1 of 1

Unable to write in the file

PostPosted: Mon Oct 31, 2011 10:32 pm
by nm992
Hi..

I have a file in which i need to read 4 fields..and after meeting some condition..need to update the status for each record in the same file in field say 5.

I declared the file as i-o and access mode is sequential..

The way I am doing is

Read the file
check the condition
move "fail' to status
Write file.

But I am getting file status 48.and the status is not being written.

Can anyone please suggest where am i wrong?

Re: Unable to write in the file

PostPosted: Mon Oct 31, 2011 10:35 pm
by dick scherrer
Hello,

Do not try to re-write this sequential file - there is no good reason to do so. Well managed organizations will not even permit this.

Read the "input", make the changes, and write the output.

Re: Unable to write in the file

PostPosted: Mon Oct 31, 2011 11:01 pm
by nm992
hi Dick..

I did not get what you tried to say.

my quest is my File has 5 fields..
Field 1 ,Filed 2 ,Field 3,Field 4,Field 5

Field 5 is empty.I need to do some processing for field 1 to 4 and need to update Field 5.

Should I write in a seperate file and then merge Field 1 to Field 4 and output file..

Re: Unable to write in the file

PostPosted: Tue Nov 01, 2011 12:45 am
by Robert Sample
Should I write in a seperate file and then merge Field 1 to Field 4 and output file..
Yes, absolutely -- you never want to attempt to do input AND output processing on a sequential file. Period. Use one file for input and one file for output. What you do with the fields (whatever THAT means -- files have records and each record has columns)is totally up to you and your program.

Re: Unable to write in the file

PostPosted: Tue Nov 01, 2011 12:51 am
by dick scherrer
Hello,

Read the "input" data (4 fields with data and one empty field) and write the 5-field data into a new file.

There need be no "merging" - this should be a simple read A and write B process.

Re: Unable to write in the file

PostPosted: Tue Nov 01, 2011 1:01 am
by BillyBoyo
It would be worth checking on the error code you got. There is a table in the Cobol manuals. There is a discrepency between the type of file you are using, the type of open you are using, and the type of write that you are doing.

If you have a sequential file (DSORG=PS) then read input file, write seperate output file as has been suggested to you already. If you have a VSAM file, your requirement may be to update it in place. Check exactly how you are achieving the rewriting against what is in the manual - and remember to back-up the file before your job runs, and to restore the file before your job re-runs in the event of failure/error.

Re: Unable to write in the file

PostPosted: Tue Nov 01, 2011 7:34 pm
by Ed Goodman
I have a hunch that you are trying to change the record length. To use REWRITE, the record length has to stay the same. Remember, you are trying to replace the record in the SAME SPOT on the media.

Oh, and don't use REWRITE. It's the cause of great sorrow and misery around the world.

Re: Unable to write in the file

PostPosted: Tue Nov 01, 2011 7:36 pm
by Ed Goodman
Ahh, wait...
manual says a "48" means
The execution of a WRITE statement was
attempted on a file not open in the I-O,
output, or extend mode.

So...are you using the "WRITE" verb, or the "REWRITE" verb?

Re: Unable to write in the file

PostPosted: Tue Nov 01, 2011 9:43 pm
by dick scherrer
Hello,

As most places will not allow a process to overwrite an input qsam dataset, i suggest this not be pursued any further. If this was a vsam file, sure have at the re-write.

The most widely accepted way to do this that i've seen is to read the input and write a new output with the required changed/new data.