Page 1 of 1

How to open a file in I-O mode in assembler?

Posted: Sun Oct 13, 2013 8:03 pm
by Dino
Can I open a file in I/O mode in assembler? If yes, how to do that? I have to read and update the same file .

Re: How to open a file in I-O mode in assembler?

Posted: Sun Oct 13, 2013 8:51 pm
by Robert Sample
It is NOT advised to read and write to the same file -- because it becomes impossible to restart the program if needed. And if you are using a sequential file, there is the possibility of making the file unusable.

However, the Assembler OPEN macro supports INOUT (among other options) so you might want to read up on the OPEN options.

Re: How to open a file in I-O mode in assembler?

Posted: Thu Oct 17, 2013 12:08 pm
by Dino
Thanks Robert.
Robert Sample wrote:It is NOT advised to read and write to the same file -- because it becomes impossible to restart the program if needed. And if you are using a sequential file, there is the possibility of making the file unusable.
Should I read this as a general advice or specifically for Assembler? As there are some programs I've seen using RE-WRITE for QSAM and ESDS in COBOL.
However, the Assembler OPEN macro supports INOUT (among other options) so you might want to read up on the OPEN options.
Thanks for the guidance, this helps.

Re: How to open a file in I-O mode in assembler?

Posted: Thu Oct 17, 2013 2:44 pm
by William Collins
If updating a dataset in place, the dataset must first be backed-up. For a QSAM dataset that would be a bit silly. No reason to update a QSAM dataset in place.

An ESDS is reasonable to update in place, as long as backed-up first.

Without the back-up it becomes a corrupt-in-place.

Re: How to open a file in I-O mode in assembler?

Posted: Thu Oct 17, 2013 3:04 pm
by Robert Sample
The only times I have ever used REWRITE in COBOL is with a VSAM KSDS file. No matter the language used, using REWRITE on a sequential file in production code is just asking for problems. If the program fails one in a hundred times, and it runs daily, you're looking at 3 to 4 times a year where the process has to be restarted and hence the sequential file has to be restored before the rerun can occur.

Re: How to open a file in I-O mode in assembler?

Posted: Mon Apr 21, 2014 4:54 pm
by Dino
Thanks Robert/William. This is useful.