Report Writer

The Report Writer is a special purpose feature which places its emphasis on the organization, format, and contents of an output report. Although a report can be produced using the standard COBOL language, the Report Writer language features provide a more concise facility for report structuring and report production. Much of the Procedure Division programming which would normally be supplied by the programmer is instead provided automatically by the Report Writer Control System (RWCS). Thus the programmer is relieved of writing procedures for moving data, constructing print lines, counting lines on a page, numbering pages, producing heading and footing lines, recognizing the end of logical data subdivisions, updating sum counters, and so on. All these operations are accomplished by the RWCS as a consequence of source language statements that appear primarily in the report section of the data division of the source program.

XOPENAlthough it is a part of the standard COBOL definition, this module is explicity excluded from the X/Open COBOL language definitions and should not be used in a conforming X/Open COBOL source program.

OSVSThe OS/VS COBOL compiler provides support for Report Writer that is based on the ANSI'68 Standard (even when the mainframe LANGLVL(2) compiler option is used - which normally requests ANSI'74 support). However, there are many cases in which that compiler actually supports a cross between the two COBOL Standards. Therefore, you should not attempt to use your COBOL system with OS/VS COBOL emulation along with any other dialect.

OSVSWithin this chapter, many of these OS/VS COBOL extensions are indicated by an OSVS bubble. However, for the exact rules for the OS/VS COBOL Report Writer syntax, you should refer to your IBM OS/VS COBOL Language Reference.

Report Section

The Report Section of a COBOL Data Division contains one or more Report Description entries (RD entries), each of which forms the complete description of a report.

The report named in the RD entry is not assigned directly to an output file. Instead, it is associated with a file-name in the File Section and that file-name is associated with a file when an OPEN statement specifying the file-name is executed. More than one report can be associated with the same file-name and the CODE clause is used to differentiate among the reports. For an external file connector referenced by a file-name, separately compiled programs can specify different reports for the same file-name. This file description entry must specify the name of a report description entry for each report associated with that file-name in this program.

The RD entry contains a set of clauses that names the report and supplies specific information about the format of the printed page and the organization of the subdivisions of the report. An identification code can be given in the RD entry so that each report can be identified separately in an intermediate output file.

Following each RD entry are one or more 01 level-number entries, each followed by a hierarchical structure similar to COBOL record descriptions. Each 01 level-number entry and its subordinate entries describes a report group. Each report group consists of one or more print lines that are regarded as a unit. A report group that is to be printed is printed entirely on one logical page; it is never split across pages.

Report Structure

When structuring a report, major consideration must be given to vertical and horizontal spacing requirements, manipulation of data, and the physical and logical subdivisions of a report.

Vertical Spacing

The Report Writer feature allows the user to describe report groups containing multiple lines. The vert ical positioning of the lines on a page is specified by the LINE NUMBER clause that is associated with each line. The NEXT GROUP clause indicates how many lines to space after presenting the last line of the group. The first LINE NUMBER clause of the next group indicates additional spacing information to be used in positioning of that group.

Horizontal Spacing

The Report Writer allows the user to position the fields of data on a report line by means of the COLUMN NUMBER clause. The RWCS supplies space fill between all defined fields.

Data Manipulation

When the Report Writer feature is used, data movement to a report group is directed by report section clauses rather than Procedure Division statements. The report section clauses that affect the manipulation of data are the SOURCE, SUM, and VALUE clauses.

The SOURCE clause specifies the sending data item of an implicit MOVE statement. The receiving printable item is defined by the description of the report group item in which the SOURCE clause appears.

The SUM clause automatically causes the establishment of a sum counter. The object of the SUM clause names the data item(s) which are added to the sum counter when a GENERATE statement is executed. The moving of the sum counter contents to the receiving printable item, defined by the description of the report group item in which the SUM clause appears, is accomplished automatically when that report group is presented.

The VALUE clause defines a literal that appears in the printable item of a report group each time that report group is to be presented.

In summary, a data item in a report group is presented only if it has a COLUMN NUMBER clause specifying where it is to be presented. The value that is placed in a printable item is determined by the SOURCE, SUM, or VALUE clause stated in the report group description. Under no circumstances can a report group printable item receive a value directly via a Procedure Division statement.

Report Subdivisions

The physical and logical organization of a report interact to determine what is presented on a page.

Physical Subdivision of a Report

The PAGE clause specifies the length of the page, the size of the heading and footing areas, and the size of the area in which the detail lines will appear. The RWCS uses the LINE NUMBER and NEXT GROUP clauses to position these report groups, and when necessary, to advance to a new page with automatic production of PAGE HEADING and PAGE FOOTING report groups.

Logical Subdivisions of a Report

DETAIL report groups can be structured into a nested set of control groups. Each control group can begin with a CONTROL HEADING report group and end with a CONTROL FOOTING report group.

When nested control groups are defined, the recognition of a change in value of a control data item in a control hierarchy is called a control break and the heading and footing lines associated with the control data-name are called CONTROL HEADING and CONTROL FOOTING report groups.

During the execution of a GENERATE statement, the RWCS uses the control hierarchy to check automatically for control breaks. If a control break has occurred, all controls that are minor to it are considered to have changed, even though they may not in fact have changed. The occurrence of a control break causes the following sequence of events to take place:

  1. ALL CONTROL FOOTING report groups are presented up to and including the one at the level at which the control break occurred.
  2. ALL CONTROL HEADING report groups are presented from the control break level down to the most minor control.
  3. The DETAIL report group named in the GENERATE statement is presented.

Procedure Division Report Writer Statements

The Report Writer statements that appear in the Procedure Division are: INITIATE, GENERATE, TERMINATE, SUPPRESS, and USE BEFORE REPORTING.

The INITIATE statement causes the RWCS to perform automatically a number of initialization functions. A report must be initiated before any detail processing can take place.

The GENERATE statement which specifies a data-name causes the named DETAIL report group to be formatted and written to the output device. In addition, it triggers the RWCS to perform the many implicit actions described in the preceding section.

The GENERATE statement which specifies a report-name provides a means of summary reporting. A report produced by this type of statement has all detail print lines suppressed automatically and consists of only the summary totals accumulated during the processing of the DETAIL report group. The RWCS processing for a GENERATE report-name statement is identical to that which occurs for a GENERATE data-name statement, except that the former results in the suppression of detail print lines.

The TERMINATE statement causes the RWCS to perform all of the automatic functions associated with the termination of a report. The TERMINATE statement must be executed before the file containing the report is closed.

The SUPPRESS statement provides the object time facility to suppress the printing of an entire report group.

The BEFORE REPORTING phrase of the USE statement provides a mechanism whereby Procedure Division statement can be executed at specific instances in the automatic procedures performed by the RWCS. The statements in the USE BEFORE REPORTING procedure can alter the contents of the data items that are referenced by SOURCE clauses. Thus control is possible over the contents of data items referenced in report groups that are produced automatically.

Language Concepts

Report File

A report file is an output file having sequential organization. A report file has a file description entry containing a REPORT clause. The content of a report file consists of records that are written under control of the RWCS.

A report file is named by a file control entry and is described by a file description entry containing a REPORT clause. A report file is referred to and accessed by the OPEN, GENERATE, INITIATE, SUPPRESS, TERMINATE, USE BEFORE REPORTING, and CLOSE statements.

Special Register PAGE-COUNTER

The reserved word PAGE-COUNTER is a name for a page counter that is generated for each RD entry in the report section of the Data Division. The implicit description is PIC 9(6) BINARY. The value in PAGE-COUNTER is maintained by the RWCS and is used by the program to number the pages of a report. PAGE-COUNTER can be referenced only in the SOURCE clause of the Report Section and in Procedure Division statements. (See the section PAGE-COUNTER Rules.)

Special Register LINE-COUNTER

The reserved word LINE-COUNTER is a name for a line counter that is generated for each RD entry in the report section of the data division. The implicit description is PIC 9(6) BINARY. The value in LINE-COUNTER is maintained by the RWCS, and is used to determine the vertical positioning of a report. LINE-COUNTER can be referenced only in the SOURCE clause of the report section and in Procedure Division statements; however, only the RWCS can change the value of LINE-COUNTER. (See the section LINE-COUNTER Rules.)

Special Register PRINT-SWITCH

OSVS

The reserved word PRINT-SWITCH is a name for a register whose value may be set to non-zero in the course of a USE BEFORE REPORTING declarative procedure. This has the effect of suppressing printing of the corresponding report group.

Subscripting

In the Report Section, neither a sum counter nor the special registers LINE-COUNTER and PAGE-COUNTER can be used as a subscript.