Beruflich Dokumente
Kultur Dokumente
Copyright @ 2000 John Wiley & Sons, In. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without the express permission of the copyright owner is unlawful. Request for further information should be addressed to the permissions Department , John Wily & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages, caused by the use of these programs or from the use of the information contained herein.
9th Edition
OBJECTIVES
To familiarize you with:
CONTENTS
Introduction
CONTENTS
The REPORT SECTION in the DATA DIVISION
The RD Entry within the REPORT SECTION Clauses Used at the Group Level within a Report Group Description Clauses Used at the Elementary Level within a Report Group Description
CONTENTS
PROCEDURE DIVISION Statements
INITIATE Statement
GENERATE Statement TERMINATE Statement
INTRODUCTION
COBOL has a Report Writer Module that greatly facilitates print operations.
By including additional DATA DIVISION entries, the Report Writer Module automatically handles all: 1. Spacing of forms.
2. Skipping to a new page. 3. Testing for end of page. 4. Printing of headings at the top of a page and footings at the bottom of a page.
Structured COBOL Programming, Stern & Stern, 9th edition
INTRODUCTION
5. Accumulating of amount fields.
2. Summary or group printing - The printing of totals or other summary information for groups of records.
The Report Writer Module can be easily used for both detail and/or summary reports.
Structured COBOL Programming, Stern & Stern, 9th edition
Summary printing is performed as a result of the control break that occurs when there is a change in thee department number.
Structured COBOL Programming, Stern & Stern, 9th edition
The FD for the print file in a program using the Report Writer Module contains a LABEL RECORDS clause and may include a RECORD CONTAINS clause.
A REPORT clause is added as in the following:
FD print-file-name LABEL RECORDS ARE OMITTED [RECORD CONTAINS integer-1 CHARACTERS] {REPORT IS} {REPORTS ARE} report-name-1 . . .
Structured COBOL Programming, Stern & Stern, 9th edition
4. The positions within each line where data is to print. Each field can be given a VALUE or can have data passed to it from another field. 5. The fields to be used as summation fields.
With these specifications in the REPORT SECTION, the PROCEDURE DIVISION need not include coding for control break or summary operations.
Structured COBOL Programming, Stern & Stern, 9th edition
The RD entry describes the report and it can have numerous subordinate clauses.
[{CONTROL IS} {{data-name-1 . . .}} {CONTROLS ARE}{ FINAL data-name-1 . ..}] [PAGE [LIMIT IS] integer-1 [LINE LIMITS ARE] [LINE LINES] HEADING integer-2 FIRST DETAIL integer-3 LAST DETAIL integer-4 FOOTING integer-5]
Structured COBOL Programming, Stern & Stern, 9th edition
The sequence in which the data-names are listed in the CONTROL clause indicates their level in the control hierarchy.
Major control fields must be specified before minor ones.
Structured COBOL Programming, Stern & Stern, 9th edition
The action to be taken when a control break occurs is specified by the programmer.
After a control break occurs, we can print a CONTROL FOOTING and/or a CONTROL HEADING.
Both are coded on the 01 level in the REPORT SECTION.
Structured COBOL Programming, Stern & Stern, 9th edition
That is, CONTROL FOOTINGs typically contain accumulated control totals, so they should print first.
Then CONTROL HEADINGs, which relate to the new control fields, will print before any detail or summary lines for these new control fields.
Structured COBOL Programming, Stern & Stern, 9th edition
this would allow for adequate margins at both the top and bottom of the page.
Structured COBOL Programming, Stern & Stern, 9th edition
An example using commands covered thus far would include the following entries: REPORT SECTION
RD REPORT-LISTING
CONTROLS ARE FINAL, CUST-NO PAGE LIMIT IS 60 LINES HEADING 3 FIRST DETAIL 9
Structured COBOL Programming, Stern & Stern, 9th edition
QUESTIONS?
SELF-TEST
SALES Record Layout
Field
DIVISION
Size
2
Type
Alpha
DEPT
ITEM
2
2
Alpha
Alpha
AMT-OF-SALES
SALES REPORT DIV DEPT ITEM XX XX XXX XX XX XXX ... TOTAL ITEM AMT XX XX XXX XX XX XXX ... TOTAL ITEM AMT TOTAL DEPT AMT . . . FINAL TOTAL
SELF-TEST
SELF-TEST
1. DIV, DEPT, and ITEM are called ____ fields.
SOLUTION: control
SELF-TEST
2. The first line printed is called a ____ .
SOLUTION: Page Heading (it is not a Report Heading, which would appear only on the first page of a report)
Structured COBOL Programming, Stern & Stern, 9th edition
SELF-TEST
3. The printing of a line for each input record is called ____ printing.
SOLUTION: Detail
SELF-TEST
4. The printing of total lines for DIV, DEPT, and ITEM is called ____ printing.
SELF-TEST
5. Each total line is referred to as a ____ .
SELF-TEST
6. The major-level control item, as specified on the output, is ____ .
SELF-TEST
7. The intermediate-level control item is ____ , and the minor-level control item is ____ .
SELF-TEST
8. A change in DEPT results in the printing of ____ lines. That is, a DEPT control break also forces a(n) ____ control break.
SELF-TEST
9. A change in DIV results in the printing of ____ lines. That is, a DIV control break causes a ____ line to print, followed by a ____ line and then a ____ line.
SOLUTION: three; ITEM total or footing; DEPT total or footing; DIV total or footing
Structured COBOL Programming, Stern & Stern, 9th edition
SELF-TEST
10. A ____ prints after all records and control totals, at the end of the job.
SELF-TEST
11. Assuming the Report Writer Module will be used in this program, code the FD for the preceding output file.
SOLUTION: A suggested solution is: FD OUTPUT-FILE LABEL RECORDS ARE OMITTED REPORT IS REPORT-OUT.
Structured COBOL Programming, Stern & Stern, 9th edition
SELF-TEST
12. (T or F) 01 - level record description entries must not follow the above FD entries.
SOLUTION: T
Structured COBOL Programming, Stern & Stern, 9th edition
SELF-TEST
13. The REPORT SECTION must follow the ____ and ____ SECTIONs in the ____ DIVISION.
SELF-TEST
14. The name following the RD levelindicator is the same as the name following the ____ clause in the ____ SECTION for the output file.
SELF-TEST
SOLUTION:
15. Code the RD entry and its clauses for the preceding illustration.
REPORT SECTION. RD REPORT - 1 CONTROLS ARE FINAL, DIV, DEPT, ITEM PAGE LIMIT IS 60 LINES HEADING 2 FIRST DETAIL LAST DETAIL 50 FOOTING 59. Note: Assume that DIV, DEPT, ITEM are the input record description data-names.
Structured COBOL Programming, Stern & Stern, 9th edition
The report groups within the REPORT SECTION are classified as headings, detail lines, and footings.
The printing specifications and the format of each are defined in a series of report group descriptions.
Structured COBOL Programming, Stern & Stern, 9th edition
There are also established rules for the formation of each report group.
Data-name-2 and data-name-3 in the format refer to control fields defined in the CONTROL clause of the RD entry.
Structured COBOL Programming, Stern & Stern, 9th edition
REPORT HEADING
A REPORT HEADING, which can be abbreviated as RH, is the title of a report.
It is the first item printed on each report.
Note that there can be only one 01-level entry categorized as a REPORT HEADING.
It appears once - at the top of the first page of the report.
PAGE HEADING
A PAGE HEADING (or PH) indicates a report group that is produced at the beginning of each page. There can be only one 01-level entry categorized as a PAGE HEADING.
DETAIL line
Each DETAIL (or DE) record is described with an 01-level entry. The first detail line of each group indicates the month and day.
We call these GROUP INDICATE fields. They print when a control break has occurred.
The first time a detail group prints is considered a control break as well.
Structured COBOL Programming, Stern & Stern, 9th edition
CONTROL FOOTING
The CONTROL FOOTING (or CF) report group is produced at the end of a control group for a given control item.
CONTROL FOOTING FINAL is used to print final totals at the end of a report.
Structured COBOL Programming, Stern & Stern, 9th edition
PAGE FOOTING
The PAGE FOOTING (or PF) report group is printed at the end of each page. There can be only one 01-level entry designated as a PAGE FOOTING.
REPORT FOOTING
The REPORT FOOTING (or RF) report group is produced at the end of the report. There can be only one REPORT FOOTING.
LINE Clause
The optional LINE clause specifies either:
1. An actual or absolute line number on which the corresponding report line is to be printed (e.g., LINE 3 or LINE 10), or 2. A line number relative to the previous entry or to the previous page (e.g., LINE PLUS 2).
The LINE NUMBER clause can appear on the 01 level or on a level subordinate to it.
Structured COBOL Programming, Stern & Stern, 9th edition
INITIATE Statement
The INITIATE statement begins the processing of a report.
It is usually coded directly after the OPEN statement, and it serves to initiate the Report Writer Module. Its format is:
INITIATE report-name-1 . . .
The INITIATE statement sets all SUM and COUNTER fields to zero, including LINECOUNTER and PAGE-COUNTER.
Structured COBOL Programming, Stern & Stern, 9th edition
GENERATE Statement
The GENERATE statement is used to produce the report.
It usually names a detail report group to be printed after an input record has been read and follows this format:
GENERATE data-name-1 report-name-1
We may generate a DETAIL report group name (data-name-1 in this format) or an RD entry (report-name-1).
Structured COBOL Programming, Stern & Stern, 9th edition
TERMINATE Statement
The TERMINATE statement completes the processing of a report after all records have been processed.
It is usually coded just before the files are closed, and follows this format:
TERMINATE report-name-1 . . . The TERMINATE causes the Report Writer Module to produce all CONTROL FOOTING report groups beginning with the minor ones.
That is, it forces all control totals to print for the last control group and also prints any final totals.
Structured COBOL Programming, Stern & Stern, 9th edition
CHAPTER SUMMARY
A. DATA DIVISION Entries
1. Code a REPORT SECTION following the WORKING-STORAGE SECTION. 2. The FD for the output print file references the RD in the REPORT SECTION: FD . . . REPORT IS report-name-1. ... REPORT SECTION. RD report-name-1.
CHAPTER SUMMARY
3. RD clauses. a. Control fields are listed beginning with major controls as: CONTROLS ARE [FINAL,] major control field . . .
CHAPTER SUMMARY
4. 01 report group description entries can describe REPORT HEADING, PAGE HEADING, CONTROL HEADING, DETAIL, CONTROL FOOTING, PAGE FOOTING, and REPORT FOOTING.
a. A data-name is required on the 01 level only if the data-name is used in the PROCEDURE DIVISION (e.g., with TYPE DETAIL) or in a USE BEFORE REPORTING declarative, which has not been discussed here.
b. A LINE NUMBER clause on the 05 level indicates what actual line or relative line the report group should print on.
Structured COBOL Programming, Stern & Stern, 9th edition
CHAPTER SUMMARY
c. Specifying individual items within a report group:
(1) Each entry indicates the columns in which items are to print. (2) Each entry can contain a (1) SOURCE - where the sending data is located (2) VALUE, or (3) SUM if the item is the sum of some other field. (3) A data-name is required after the entrys level number only if it is accessed elsewhere (e.g., in a CONTROL FOOTINGs SUM clause).
d. If a REPORT or PAGE HEADING or any detail printing requires more than one line, code each on an 05 level subordinate to the corresponding 01-level item.
Structured COBOL Programming, Stern & Stern, 9th edition
CHAPTER SUMMARY
B. PROCEDURE DIVISION Statements
1. INITIATE report-name-1 after the files are opened.
2. GENERATE detail-report-group-name for each input record that has been read. The computer will print all headings, detail lines, control lines, and footings as well.