MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cobol files

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
arungr
Beginner


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Sat Feb 12, 2005 9:00 am    Post subject: cobol files Reply with quote

Dear All,

I encountered a situation in my program in which I have to open files(PS) which may vary from 1 to 50 in number. While closing the files , how do I know that this file is opened or not because I could have opened any number of files.Since I will get an abend if I try to close a file which is not opened, is there any method to find if this file is opened or close?

Thanks,

arun.
Back to top
View user's profile Send private message
hari_uss
Beginner


Joined: 19 Dec 2002
Posts: 78
Topics: 6
Location: Trivandrum, India

PostPosted: Sat Feb 12, 2005 10:40 am    Post subject: Reply with quote

The simplest solution would be declaring one flag for each of the files and and setting them ON when you open the respective files.
Code:

OPEN FILE-1.
IF FILE-STATUS = ZERO
    SET FILE-1-OPEN TO TRUE
OPEN FILE-2
IF FILE-STATUS = ZERO
    SET FILE-2-OPEN TO TRUE.
------
IF FILE-1-OPEN
    CLOSE FILE-1.
IF FILE-2-OPEN
    CLOSE FILE-2.
Back to top
View user's profile Send private message Send e-mail
arungr
Beginner


Joined: 12 Feb 2005
Posts: 16
Topics: 4

PostPosted: Sat Feb 12, 2005 10:48 am    Post subject: cobol files Reply with quote

Thanks. That' s true. But I have to use 50 files to the maximum. It means I have to define 50 flags. Is there any other way?
Back to top
View user's profile Send private message
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Sat Feb 12, 2005 7:56 pm    Post subject: Reply with quote

Never had a clear answer to this, but I think the operating system will in fact close the files if you don't.
________
Expert insurance


Last edited by dtf on Tue Mar 15, 2011 5:00 am; edited 1 time in total
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Sun Feb 13, 2005 1:48 am    Post subject: Reply with quote

THe file will be automatically closed, and at least if you are using QSAM and buffers will be flushed. I'm not sure flusing buffers with BSAM and since I don't speak COBOL I don't know how it handles the I/O. But regarding the flags, can't you just use an array (or whatever they call that in COBOL)?
Back to top
View user's profile Send private message Visit poster's website
hari_uss
Beginner


Joined: 19 Dec 2002
Posts: 78
Topics: 6
Location: Trivandrum, India

PostPosted: Mon Feb 14, 2005 4:55 am    Post subject: Reply with quote

With BSAM, data management will have no information about the current buffer. So what it might do is, complete if there is any active I/O and then close the dataset.
It would be always advisable to close the files in your program instead of leaving it to OS and take a chance.
Back to top
View user's profile Send private message Send e-mail
Kathi
Beginner


Joined: 14 May 2003
Posts: 25
Topics: 0
Location: Mission Viejo, California

PostPosted: Tue Feb 15, 2005 12:44 pm    Post subject: Reply with quote

arungr posted
Quote:
It means I have to define 50 flags.


Sometimes we have to do things we don't necessarily like. Laughing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group