View previous topic :: View next topic |
Author |
Message |
arungr Beginner
Joined: 12 Feb 2005 Posts: 16 Topics: 4
|
Posted: Sat Feb 12, 2005 9:00 am Post subject: cobol files |
|
|
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 |
|
 |
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Sat Feb 12, 2005 10:40 am Post subject: |
|
|
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 |
|
 |
arungr Beginner
Joined: 12 Feb 2005 Posts: 16 Topics: 4
|
Posted: Sat Feb 12, 2005 10:48 am Post subject: cobol files |
|
|
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 |
|
 |
dtf Beginner
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
|
Posted: Sat Feb 12, 2005 7:56 pm Post subject: |
|
|
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 |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Sun Feb 13, 2005 1:48 am Post subject: |
|
|
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 |
|
 |
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Mon Feb 14, 2005 4:55 am Post subject: |
|
|
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 |
|
 |
Kathi Beginner

Joined: 14 May 2003 Posts: 25 Topics: 0 Location: Mission Viejo, California
|
Posted: Tue Feb 15, 2005 12:44 pm Post subject: |
|
|
arungr posted Quote: | It means I have to define 50 flags. |
Sometimes we have to do things we don't necessarily like.  |
|
Back to top |
|
 |
|
|