Skip to content

Report Section and RD

Each of your Report Descriptions is placed in the REPORT SECTION. The ANS standards, OS/VS COBOL, and DOS/VS COBOL all require this to be the last SECTION of the DATA DIVISION, positioned immediately before PROCEDURE DIVISION. However, the precompiler allows REPORT SECTION to appear anywhere in the DATA DIVISION after FILE SECTION.

Just as the FILE SECTION consists of a series of FD entries, each with record descriptions headed by an 01-level entry to follow, so the REPORT SECTION consists of RD entries, each followed by Report Group Descriptions headed by an 01-level entry.

Your program may produce any number of reports, each with its own Report Description. Each Report Description consists of an RD entry followed by any number of Report Group Descriptions (although there are restrictions according to TYPE; see TYPE clause). The order in which they are coded is immaterial. If several of the reports have strong similarities, you should define the report only once and make use of the DUPLICATED clause.

report section

where report-description-entry is defined as follows:

report description

Report Section and RD: Coding Rules

  • All other DATA DIVISION sections, if present, should precede REPORT SECTION.

  • Each report-name must be unique and must be the same as one of the report-names specified in the REPORT clause of one or more FD entries. (If a report-name appears in more than one FD, the UPON phrase of INITIATE is required, see INITIATE statement.) This correspondence is used to determine where the output is to be written. Each report-name introduced in the FD must match a reportname of an RD.

  • The clauses of the RD may be written in any order; the order is not significant.

  • Each RD entry is followed by at least one Report Group Description. These define all the report groups (sets of one or more report lines) that may be produced in the report. They are fully described in the next part (see TYPE clause).

  • If GLOBAL is specified, the report is available to any program contained in the current program, in the following senses:

    • An INITIATE, GENERATE, or TERMINATE for the GLOBAL report-name may be issued from within a contained program, provided that the contained program itself does not have a locally-defined report of the same name. The contained program need not contain a REPORT SECTION.

    • A GENERATE for any of the DETAIL report groups of the GLOBAL report may be issued from within a contained program, provided that the contained program itself does not have a locally-defined report and DETAIL group with the same names. If a GLOBAL report and a locally-defined report have different names but share DETAIL groups with the same name, these may be distinguished as usual by means of the IN/OF report-name qualifier.

    • The special registers PAGE-COUNTER, LINE-COUNTER, LINE-LIMIT, and CODEVALUE of the GLOBAL report, together with any sum-counters, may be accessed as GLOBAL items. Other report fields are not globally accessible.

  • The CONTROL and SOURCE fields, or any other data items used during the processing of the GLOBAL report, are those that are accessible to the containing - not the contained - program. Thus, SOURCE items must normally also be GLOBAL if you wish to set up values in them and print them from within a contained program.

    If a contained program contains a GLOBAL report with an identical reportname, this will override the scope of original GLOBAL report until the end of the contained program. Similarly, a DETAIL group in a GLOBAL report of a contained program may override an identically-named one in the containing program. The program in which the GLOBAL report is defined must receive control at least once before the report can be accessed, even though it need not itself contain any procedural statements referring to the GLOBAL report.

  • The STYLE clause causes one or more styles to take effect for the report as a whole. Usually this means that a certain control sequence will be sent to the printer just after the INITIATE is executed and another control sequence just before the TERMINATE is executed. If no STYLE clause is coded, an implicit style for the report may take effect, if this has been defined for the output device. STYLE NORMAL ensures that no style takes effect at the report level. Full details are given in the next part (see STYLE clause).

  • The Formats and Rules for the other clauses in the RD are given in the sections that follow.

Compatibility

The following features are provided by new Report Writer only:

  • The GLOBAL phrase, and access to GLOBAL reports

  • Use in ANS-85 contained or batched programs

  • The LINE LIMIT clause

  • The ALLOW clause

  • The OVERFLOW and SUM OVERFLOW clauses

  • The STYLE clause

New Report Writer allows several FD's to be associated with a given report-name, provided that the UPON phrase is used with an INITIATE for the report-name. It does not write to more than one file simultaneously. If you wish to continue to write to two files simultaneously, this may be achieved by means of a file handler that performs a WRITE to each file. See Multiple Reports.

See the end of each section for compatibility notes on the other clauses.

Back to top