What happens when we reopen a ps file and start reading.

All sort of Mainframes Interview Questions.
Post Reply
Rahul
Registered Member
Posts: 23
Joined: Thu Jan 23, 2014 9:06 am

What happens when we reopen a ps file and start reading.

Post by Rahul »

Hi,

This was asked in an interview and I was not very sure of the answer. The question was:

What happens when we reopen a ps file and start reading
I mean it will read from Beginning or it will read from where it left?

I thought compiler will give error if we re-open in the same program, right?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: What happens when we reopen a ps file and start reading.

Post by Robert Sample »

As long as the file is closed before being reopened, this will not generate any kind of compiler error and is quite acceptable. The reopen causes the file to be read from the first record again.
Rahul
Registered Member
Posts: 23
Joined: Thu Jan 23, 2014 9:06 am

Re: What happens when we reopen a ps file and start reading.

Post by Rahul »

why 'open' is so important in COBOL? Is this applicable to Windows and or Linux too, I've not heard about it?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: What happens when we reopen a ps file and start reading.

Post by Robert Sample »

Windows and Linux machines open files as well -- but implicitly for the most part. COBOL being well over 50 years old needs the open explicitly stated.
Rahul
Registered Member
Posts: 23
Joined: Thu Jan 23, 2014 9:06 am

Re: What happens when we reopen a ps file and start reading.

Post by Rahul »

Thanks.

But is it recommended to have multiple opens for a file in the COBOL program?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: What happens when we reopen a ps file and start reading.

Post by Robert Sample »

It is rare to open one file more than once in a COBOL program. I've done it a few times in my last 48 years of writing COBOL code but the total can be counted on my fingers.
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 “Interview Questions.”