1 / 42

CHAPTER 17 The Report Writer Module

CHAPTER 17 The Report Writer Module. CONTENTS. Introduction The Benefits of the Report Writer Module For Detail and Summary Printing For Control Break Processing For Printing Headings and Footings. CONTENTS. The REPORT SECTION in the DATA DIVISION The RD Entry within the REPORT SECTION

lorie
Télécharger la présentation

CHAPTER 17 The Report Writer Module

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER 17The Report Writer Module

  2. CONTENTS • Introduction • The Benefits of the Report Writer Module • For Detail and Summary Printing • For Control Break Processing • For Printing Headings and Footings

  3. 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

  4. CONTENTS • PROCEDURE DIVISION Statements • INITIATE Statement • GENERATE Statement • TERMINATE Statement

  5. 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.

  6. INTRODUCTION 5. Accumulating of amount fields. 6. Testing for control breaks. 7. Detail and/or summary printing. 8. Printing of totals for control breaks. 9. Printing of a final total when there are no more input records. Summary

  7. For Printing Headings and Footings • A Report Writer program can designate print lines of the following types: REPORT HEADING (RH) - Prints identifying information about the report only once, at the top of the first page of the report. PAGE HEADING (PH) - Prints identifying information at the top of each page. • This may include page numbers, column headings, and so on.

  8. For Printing Headings and Footings CONTROL HEADING (CH) - Prints a heading that typically contains new control values when a control break has occurred. DETAIL (DE) - Prints for each input record read. CONTROL FOOTING (CF) - Prints control totals for the previous group of detail records just printed, after a control break has occurred.

  9. For Printing Headings and Footings PAGE FOOTING (PF) - Prints at the end of each page. REPORT FOOTING (RF) - Prints only once, at the end of the report. • This may include, for example, an ‘End of Report’ message.

  10. The REPORT SECTION in the DATA DIVISION • The DATA DIVISION of a program using the Report Writer Module can consist of three sections that must be coded in the order shown: 1. FILE SECTION 2. WORKING-STORAGE SECTION 3. REPORT SECTION

  11. The REPORT SECTION in the DATA DIVISION • The REPORT SECTION is specified only when the Report Writer Module is used. • Lines must be designated as heading, detail, and footing lines. • These will print as appropriate under the control of the Report Writer Module.

  12. The REPORT SECTION in the DATA DIVISION REPORT CLAUSE • 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 LABELRECORDSAREOMITTED [RECORD CONTAINS integer-1 CHARACTERS] {REPORT IS} {REPORTS ARE} report-name-1 . . .

  13. The REPORT SECTION in the DATA DIVISION • The REPORT SECTION, which follows the WORKING-STORAGE SECTION, defines all aspects of the printed output. It specifies: 1. The report group type that describes each type of line (e.g., Report Heading, Page Heading, Detail). 2. The line on which each record is to print. This can be specified as an actual line number (e.g., 3) or a relative line number that relates to a previous line (e.g., PLUS 2).

  14. The REPORT SECTION in the DATA DIVISION 3. The control fields. 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.

  15. The RD Entry within theREPORT SECTION • The RD entry’s name corresponds to the report-name assigned in the FD for the output print file. REPORT SECTION. RD REPORT - LISTING • Both the REPORT SECTION header and the RD entry are required.

  16. The Format for the RD Entry within the REPORT SECTION • The RD entry describes the report and it can have numerous subordinate clauses. (Naming: FD -> RD) REPORT SECTION RD report-name-1 [{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]

  17. The CONTROL Clause • The CONTROL clause specifies the control fields. • These fields will be tested against their previous value to determine if a control break has occurred. • 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.

  18. The CONTROL Clause How Lines Are Printed When a Control Break Occurs • 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. • This is automatic, none of the control break programming required

  19. The CONTROL Clause • 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. • CONTROL FOOTING (CF) print followed by CONTROL HEADING (CH).

  20. PAGE LIMIT Clause • The PAGE LIMIT clause specifies the layout of a page of the report, indicating actual line numbers on which specific report group types are to print. • The PAGE LIMIT clause indicates: 1. The number of actual lines that should be used for printing (integer-1). • Approximately 60 lines are usually allotted for a page; • this would allow for adequate margins at both the top and bottom of the page.

  21. PAGE LIMIT Clause 2. The line on which the PAGE or first REPORT HEADING record may print (integer-2). 3. The line on which the FIRST DETAIL record may print (integer-3). 4. The line on which the LAST DETAIL record may print (integer-4). 5. The last line on which a CONTROL FOOTING record may print (integer-5). • Only a PAGE or REPORT FOOTING can print beyond integer-5.

  22. The RD Entry within theREPORT SECTION: PAGE LIMIT Clause • 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

  23. Clauses Used at the Group Level within a Report Group Description • The first entry for a report group within the RD is called the report group description entry. • It is coded on the 01 level. • 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.

  24. Clauses Used at the Group Level within a Report Group Description • AN OVERVIEW OF THE FORMAT FOR THE REPORT GROUP DESCRIPTION ENTRY 01 [data-name-1] TYPE Clause [LINE Clause] [NEXTGROUP Clause]

  25. TYPE Clause - Required • The TYPE clause specifies the category of the report group. • The time at which each report group is printed within a report is dependent on its type. • For example, a REPORT HEADING is printed before a PAGE HEADING, a CONTROL FOOTING is printed when a control break occurs, and so on. • 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.

  26. 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.

  27. 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.

  28. 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.

  29. CONTROL FOOTING • The CONTROL FOOTING (or CF) report group is produced at the end of a control group for a given control item. • The CONTROL FOOTING is printed when a control break occurs. • It prints prior to any CONTROL HEADING, which would refer to the next control field’s value. • There can be only oneCONTROL FOOTING per control item. • CONTROL FOOTING FINAL is used to print final totals at the end of a report.

  30. 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.

  31. REPORT FOOTING • The REPORT FOOTING (or RF) report group is produced at the end of the report. • There can be only oneREPORT FOOTING.

  32. LINE Clause • The optionalLINE 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 subordinateto it.

  33. NEXT GROUP Clause • The NEXT GROUP clause is most often used in a report group to indicate the line spacing (absolute or relative) to be performed when the last line of the control footing has been printed. • NEXT GROUP is also used to provide some extra blank lines between the end of one control group the and the start of the next. • It can also be used to force a REPORT HEADING report group to print on a separate page before all other report groups.

  34. PROCEDURE DIVISION Statements • INITIATE Statement • GENERATE Statement • TERMINATE Statement

  35. 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 LINE-COUNTER and PAGE-COUNTER.

  36. 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).

  37. 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.

  38. CHAPTER REVIEW 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.

  39. CHAPTER REVIEW 3. RD clauses. a. Control fields are listed beginning with major controls as: CONTROLS ARE [FINAL,] major control field . . . minor control field. b. The PAGE LIMIT clause describes the number of print lines on each page; • It can also include clauses that indicate what line a heading should print on and/or what line a first detail, last detail, and last CONTROL FOOTING should print on.

  40. CHAPTER REVIEW 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.

  41. CHAPTER REVIEW 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 entry’s level number only if it is accessed elsewhere (e.g., in a CONTROL FOOTING’s 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.

  42. CHAPTER REVIEW 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. 3. Before closing the files, TERMINATE report-name-1. Sample Code

More Related