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

HLASM for MVS. PL/I for MVS & Enterprise PL/I for z/OS.
Post Reply
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

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

Post 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 .
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

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

Post 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.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

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

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
Dino
Registered Member
Posts: 52
Joined: Tue Jun 18, 2013 12:12 am

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

Post by Dino »

Thanks Robert/William. This is useful.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Assembler & PL/I.”