[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP COBOL
|
Previous | Contents | Index |
The COLUMN NUMBER clause defines the horizontal location of items within a report line.
You use the COLUMN NUMBER clause only at the elementary level. This clause must appear in or be subordinate to an entry that contains a LINE NUMBER clause. Within the description of a report line, the COLUMN NUMBER clauses must show values in ascending column order. Column numbers must be positive integer literals with values from 1 to the maximum number of print positions on the printer. For example:
01 DETAIL-LINE TYPE DETAIL LINE PLUS 1. 02 COLUMN 1 PIC X(15) SOURCE LAST-NAME. 02 COLUMN 17 PIC X(10) SOURCE FIRST-NAME. 02 COLUMN 28 PIC XX SOURCE MIDDLE-INIT. 02 COLUMN 40 PIC X(20) SOURCE ADDRESS. 02 COLUMN 97 PIC $$$,$$$,$$$.99 SOURCE INVOICE-SALES. |
Omitting the COLUMN clause creates a null (nonprinting) report item. Null report items are used to accumulate totals and force control breaks as described in Section 10.8.4.
The following example shows the use of a COLUMN NUMBER clause in a LINE clause:
02 LINE 15 COLUMN 1 PIC X(12) VALUE "SALES TOTALS". |
The previous example results in the following output:
1 2 3 4 column 1234567890123456789012345678901234567890 SALES TOTALS |
In the next example, the COLUMN NUMBER clauses are subordinate to a LINE NUMBER clause:
02 LINE 5 ON NEXT PAGE. 03 COLUMN 1 PIC X(12) VALUE "(Cust-Number". 03 COLUMN 14 PIC 9999 SOURCE CUST-NUM. 03 COLUMN 18 PIC X VALUE ")". 03 COLUMN 20 PIC X(15) VALUE "TOTAL PURCHASES". 03 COLUMN 36 PIC $$$$,$$$.99 SUM TOT-PURCHS. |
The previous example produces the following output:
1 2 3 4 column 1234567890123456789012345678901234567890123456 (Cust-Number 1234) TOTAL PURCHASES $1,432.99 |
In a Report Writer program, one way you specify a value for an item is to use the VALUE clause. This clause designates that the data item has a constant literal value. You often use this clause with REPORT HEADING and PAGE HEADING report groups, because the data in these groups is usually constant, as shown in the following example:
01 TYPE IS PAGE HEADING. 02 LINE 5. 03 COLUMN 1 PIC X(27) VALUE "CUSTOMER MASTER FILE REPORT". 03 COLUMN 40 PIC X(5) VALUE "SALES". |
The previous example results in the following output:
1 2 3 4 5 column 12345678901234567890123456789012345678901234567890 CUSTOMER MASTER FILE REPORT SALES |
To assign a variable value to an item in a Report Writer program, you use the SOURCE clause.
The SOURCE clause, written in the Report Section, is analogous to the MOVE statement.
The clause names a data item that is moved to a specified position on the print line. Before an item that contains a SOURCE clause is printed, the Report Writer moves the value in the field named in the SOURCE clause into the print line at the print position specified by the COLUMN clause, as shown in the following example. Any data editing specified by the PICTURE clause is performed before the data is moved to the print line.
01 DETAIL-LINE TYPE DETAIL LINE PLUS 1. 02 COLUMN 1 PIC X(15) SOURCE LAST-NAME. 02 COLUMN 17 PIC X(10) SOURCE FIRST-NAME. 02 COLUMN 28 PIC XX SOURCE MIDDLE-INIT. 02 COLUMN 35 PIC X(20) SOURCE ADDRESS. 02 COLUMN 55 PIC X(20) SOURCE CITY. 02 COLUMN 75 PIC XX SOURCE STATE. 02 COLUMN 78 PIC 99999 SOURCE ZIP. |
You can also code a SOURCE clause with PAGE-COUNTER or LINE-COUNTER as its operand, as the following example shows. PAGE-COUNTER references a special register created by the compiler for each Report Description entry in the Report Section. This counter automatically increments by 1 each time the Report Writer executes a page advance. The use of PAGE-COUNTER eliminates Procedure Division statements you normally would write to explicitly count pages, as shown in the following example:
01 TYPE IS PAGE HEADING. 02 LINE 5. 03 COLUMN 1 PIC X(27) VALUE "CUSTOMER MASTER FILE REPORT". 03 COLUMN 52 PIC X(4) VALUE "PAGE". 03 COLUMN 57 PIC ZZZ9 SOURCE PAGE-COUNTER. |
This example produces the following output:
1 2 3 4 5 6 column 123456789012345678901234567890123456789012345678901234567890 CUSTOMER MASTER FILE REPORT PAGE 9 |
To include two or more reports in one file, you specify multiple identifiers in the REPORTS clause and provide multiple RDs in the Report Section.
To identify the lines of two or more reports in one file, you use the CODE clause, as shown in the following example:
FILE SECTION. FD REPORT-FILE REPORTS ARE REPORT1 REPORT2 REPORT3. REPORT SECTION. RD REPORT1... CODE"AA". RD REPORT2... CODE"BB". RD REPORT3... CODE"CC". |
The CODE clause specifies a 2-character nonnumeric literal that
identifies each print line as belonging to a specific report. When the
CODE clause is specified, the literal is automatically placed in the
first two character positions of each Report Writer logical record.
Note that if the clause is specified for any report in a file, it must
be used for all reports in that file.
10.8.10 Generating and Controlling Report Headings and Footings
When you write a report that has control headings and/or footings, you must use the CONTROL clause to create control levels that determine subsequent headings and totals.
The CONTROL clause, found in the RD entry, names data items that indicate when control breaks occur. The CONTROL clause specifies the data items in major to minor order. You must define these CONTROL data items, or control names, in the Data Division, and reference them in the appropriate CONTROL HEADING and FOOTING report groups.
When the value of a control name changes, a control break occurs. The Report Writer acknowledges this break only when you execute a GENERATE or TERMINATE statement for the report, which causes the information related to that CONTROL report group to be printed.
In the following example, the report defines two control totals (MONTH-CONTRL and WEEK-CONTRL) in the CONTROL clause. The source of these control totals is in an input file named IN-FILE. The file must be already sorted in ascending sequence by MONTH-CONTRL and WEEK-CONTRL. The Report Writer facility automatically monitors these fields in the input file for any changes. If a new record contains different data than the previous record read, Report Writer triggers a control break.
FD IN-FILE. 01 INPUT-RECORD. 02 MONTH-CONTRL PIC... 02 ... 02 ... 02 WEEK-CONTRL PIC... FD REPORT-FILE REPORT IS SALES-REPORT. . . . REPORT SECTION. RD SALES-REPORT. CONTROLS ARE MONTH-CONTRL, WEEK-CONTRL. 01 DETAIL-LINE TYPE IS DETAIL. 01 TYPE IS CONTROL FOOTING MONTH-CONTRL. 01 TYPE IS CONTROL FOOTING WEEK-CONTRL. |
In the previous example, if the value in WEEK-CONTRL changes, a break occurs and Report Writer processes the CONTROL FOOTING WEEK-CONTRL report group. If the value in MONTH-CONTRL changes, a break occurs and Report Writer processes both CONTROL FOOTING report groups, because a break in any control field implies a break in all lower-order control fields as well.
The same process occurs if you include similar CONTROL HEADING report groups. However, CONTROL HEADING control breaks occur from a break to minor levels, while CONTROL FOOTING control breaks occur from a break to major levels.
The following example demonstrates the use of FINAL, a special control field that names the most major control field. You specify FINAL once, in the CONTROL clause, as the most major control level. When you code FINAL, a FINAL control break and subsequent FINAL headings and footings occur during program execution: once at the beginning of the report (as part of the report group, CONTROL HEADING FINAL), before the first detail line is printed; and once at the end of the report (as part of the report group, CONTROL FOOTING FINAL), after the last detail line is printed.
01 TYPE CONTROL FOOTING FINAL. 02 LINE 58. 04 COLUMN 1 PIC X(32) VALUE "TOTAL SALES FOR YEAR-TO-DATE WAS". 04 COLUMN 45 PIC 9(6).99 SOURCE TOTAL-SALES. |
This example produces the following output:
Previous | Next | Contents | Index |