Re: Keeping Files Open after program termination in IBM COBOL?

From: James J. Gavan (jjgavan_at_shaw.ca)
Date: 08/28/04


Date: Sat, 28 Aug 2004 20:58:37 GMT

LX-i wrote:

> Michael A. Newell, WB4HUC wrote:
>
>> Hello,
>>
>> Is there any way to force a file NOT to be closed when a COBOL batch
>> program ends?
>>
>> This particular program may be called many times. The
>> first time it's called it opens a sequential output report
>> file, writes the headings and one detail line for the record that it
>> processed, then it ends via a GOBACK
>> statement.
>>
>> The next time the program is called it knows this isn't
>> the first time, so it just tries to write the output line
>> for the record it processed, but I get an error because
>> it's trying to write to a file that isn't open.
>
>
> I've never worked on an IBM mainframe, but if it knows it's been
> called before, it could do an "Open Extend" on the file, as opposed to
> "Open Output".
>
>> I need the file to stay open between invocations of
>> the program, but according to the Enterprise COBOL
>> Programming Guide, the run-time environment will
>> close any open files during a normal program termination.
>
>
> The above doesn't meet that requirement, though.
>
>
OK Michael,

Let's see. Bill has already pointed you at the manuals - that's the way
to go if you can do it. If anybody can figure this - it will be Bill -
he knows roughly what I'm doing with OO.

Firstly I looked at an old M/F DOS example with an external filename -
called a program to write a series of records and then called another
program to read those records without any intervening CLOSE and re-OPEN.
Without studying it not sure how it achieved that . Certainly the STOP
RUN on exiting the demo program would automatically CLOSE any files.

IBM-wise Bill, could he do anything calling a File program with entry
-points ? I'm thinking of OO where I have a separate class for a File
which is invoked as necessary. In theory any class could open it. (I've
recently added a flag FileOpened/FileNotOpened, which of course allows
you to check that you don't do a 'double' OPEN or CLOSE.). Even when I
quit the Business Class that is using the File Class the file doesn't
automatically get CLOSEd - I specifically have to invoke it to do that.
Quitting the Master Menu jumps you to a STOP RUN which would CLOSE
anything outstanding..

Now following on Michael's thoughts. He wants to pick up on this OPENed
file in many spots in the batch processing. Assuming the entry-point
technique would work, if it is the batch start program that does the
opening/closing then can it treat the File as a sub-program via
entry-points and can intermediary programs also access through those
same entry-points, without clobbering the file when the intermediaries
come to EXIT PROGRAM ?

If Michael had the OO module for Enterprise - he might have a neat solution.

Jimmy, Calgary AB



Relevant Pages

  • Re: Qusnetsoft suddenly unregistered
    ... open the program for the first time, ... If I click yes, the program opens and appears to work except that, as I ... Werner Ruotsalainen - Microsoft MVP - Windows - Mobile Devices. ...
    (microsoft.public.pocketpc)
  • Re: Speeding up Office applications
    ... problem of Outlook "locking up" numerous times. ... >>> opens ... >>>> The reason why the first time it loads slowly and after that it ... Just the first Office app ...
    (microsoft.public.office.misc)
  • Re: Need a batch file or something to autostart LIVE encoding after windows boot up<===CORRECTION
    ... >I can see that the batch file is going to require the session setup ... >the encoder loads and activates the camera. ... >Use a batch file to call to open the same wme file and it just opens ... >>> sure I can put the encoder in the start up folder but that only opens ...
    (microsoft.public.windowsmedia.encoder)
  • Re: Need help resolving modeless dialog issue
    ... I have a modeless dialog I'm launching from a menu. ... Note that by specifying 'this', you make the parent be the current window, so you don't ... and select it again, it opens correctly. ... you only showed the code that handles it for the first time. ...
    (microsoft.public.vc.mfc)
  • Re: SetOption "Default Database Directory"
    ... As I said it works except for the first time the database opens and is set ... even with the rowsource problem solved. ... Database and reopen it and the form, ...
    (microsoft.public.access.formscoding)