Print Headings Utility Module 
Author Message
 Print Headings Utility Module

Sharing files across separately compiled modules became practical with the
1985 standard by properly declaring the file as EXTERNAL

From the VS COBOL II Application Programmers Guide for MVS

" EXTERNAL:  Is used for separately compiled programs.  A file that is
 defined as EXTERNAL can be referenced by any program in the run unit
 describes that file.  See "Input/Output Using EXTERNAL Files" in
 topic 4.1.3 for an example."

The example shows a multi module application sharing a file across all of
the modules including accessing the records of the file in a module with
no procedural I/O verbs.

With VS COBOL II, the only special consideration for this construct is
that you are at release 3.0 or above (note that only R4.0 is supported),
and that you are not running CMPR2 (do not use true 85 features, make it
look like a 74 standard with IBM extensions).

Mon, 23 Feb 1998 03:00:00 GMT  
 Print Headings Utility Module


>I want to write a COBOL module that print headings to a file. This module
>accept input and open a file and print headings to it.

>I am having problems when  come back from the utility with the file open
>and then try to write to it. If I have to close the file in the utility
>module then I have to
>pass back a line count to the calling module and skip that many lines when
>write to the file the first time so the headings are not over written. Is
>there a better way. This program will be running under Batch in MVS
>written in VSII

>              GT

Well I have run against this a couple of times.  There are two ways
I have handled this.  One way is to use the new COBOL85 option EXTERNAL
So that the open can occur in the main program and be used in the subroutine.

Main program:
    fd  my-file
        block contains 0 records
        data record is my-record.
    01  my-record   pic x(80).

open output-myfile

     call 'yoursub'

close output-myfile.

stop run.

The old way is to have the subroutine open and close the file.  Unless
you do a cancel, the file will remain open between calls.  So you
can have a flag to tell the subroutine to open the file, or close
the file.  Call your subroutine with the sole purpose to close the
file at the end of processing.  Let your main program keep track
of the context/time to close the files...

01  Link-tell-sub-to-open  pic x.
    88 open-the-file    value 'Y'.
    88 close-the-file   value 'C'.
    88 do-neither       value  space.

The subroutine will have....

     If open-the-file
         open output the-file.
     if close-the-file
         close the-file
         exit program.
     continue regular processing...

Chris Mason
"The Unknown COBOL Programmer"
The opinions expressed are mine, not my Employers.

LMSC5:  Tons of Beautiful Big Blue Iron...

Tue, 24 Feb 1998 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Begin printing between 2 headings!

2. Second try for problems with Printing Headings


4. Dictionary Print Utility - CW2

5. VA Printing utility

6. Page Break in Print from Utility template

7. Dictionary Print Utility Template

8. Flagship Printing Utilities

9. Questions about Standard Utility Modules and Records With Variant Parts

10. Source Printing Utility

11. Pretty Print utility?

12. VGA Character Print Screen Utility


Powered by phpBB® Forum Software