Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open file with append for logging and archive 2

Status
Not open for further replies.

municipal

Programmer
Jan 1, 2001
62
IL
Hi
I want to open a file that does not exist as a LOG file.
In my program I dont know if the file was created before
and i want to know if there is a way to verify that the file exist or not.
if not then to open it for the first time as output.

TIA.
 
Hi,

In the CA-REALIA environment the usual way is:

INIT.
OPEN I-O NAME-FILE
IF NAME-FILE-STATUS IS NOT EQUAL TO ZERO
OPEN OUTPUT NAME-FILE
PERFORM INIT-CHK-FILE-STATUS
CLOSE NAME-FILE
PERFORM INIT-CHK-FILE-STATUS
OPEN I-O NAME-FILE
PERFORM INIT-CHK-FILE-STATUS
END-IF

That is for indexed files. By opening it, you get yes or no a problem with the file status. If yes, you open for output, else you open EXTEND. I am not sure, but I even think that if you open EXTEND the file doesn't need to be there before. If you open the file without a problem, you know it exists.

To control all problems, use the declaratives.

Regards and Luck!

Crox


 
hI
THE OPSYS IS OPENVMS
WHEN I OPEN THE FILE AS I-O I GET FILE NOT FOUND
AND THE PROGRAM TERMINATED
TIA
 
Hi Muni,

How do you allocate a file in your environment?
In an IBM OS390 env we code a JCL stmt like this:
Code:
//name dd dsn=my.log.file,disp=(mod,keep),
//        space=(cyl(2.1),rlse),etc.
This allocates the file immediately before the pgm executes.
How do you do it?

Regards, Jack.
 
I like to know whom pushed the link:

"Let municipal know
this post was helpful!"

Please explain me why that question was helping someone and on the other hand the answer wasn't.

Just curious...


 
Hi Crox,

There's just no accounting for taste. :)

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top