Presentation is loading. Please wait.

Presentation is loading. Please wait.

COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)

Similar presentations


Presentation on theme: "COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)"— Presentation transcript:

1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus) John Wiley & Sons, Inc. 11th edition

2 CHAPTER 17 The Report Writer Module

3 OBJECTIVES To familiarize you with: 1. The Report Writer Module. 2. The options available for printing reports.

4 CONTENTS Introduction The Benefits of the Report Writer Module –For Detail and Summary Printing –For Control Break Processing –For Printing Headings and Footings

5 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

6 CONTENTS PROCEDURE DIVISION Statements –INITIATE Statement –GENERATE Statement –TERMINATE Statement

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

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

9 The Benefits of the Report Writer Module

10 For Detail and Summary Printing You will recall that many reports in business require: 1. Detail printing - The printing of one or more lines for each input record. 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.

11 For Control Break Processing A report has both detail and summary printing. That is, when input records with the same department number are read, the records are printed and the total amount of sales for each salesperson is accumulated.

12 For Control Break Processing When a change or “break” in the department number occurs, the accumulated total of all amounts of sales is printed as a control total line. –We call department number a control field. Summary printing is performed as a result of the control break that occurs when there is a change in thee department number.

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

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

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

16 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

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

18 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 LABEL RECORDS ARE OMITTED [RECORD CONTAINS integer-1 CHARACTERS] {REPORT IS} {REPORTS ARE} report-name-1...

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

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

21 The RD Entry within the REPORT 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.

22 The Format for the RD Entry within the REPORT SECTION The RD entry describes the report and it can have numerous subordinate clauses. 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]

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

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

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

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

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

28 The RD Entry within the REPORT 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

29 QUESTIONS?

30 SELF-TEST SALES Record Layout Field SizeType DIVISION2Alpha DEPT2Alpha ITEM2Alpha AMT-OF-SALES6Numeric *2 decimal positions

31 SALES REPORT PAGE NO. 9999 DIVDEPTITEMAMT OF SALES XXXXXXX$9999.99... TOTAL ITEM AMT $99999.99* XXXXXXX$9999.99... TOTAL ITEM AMT $99999.99* TOTAL DEPT AMT $99999.99**... FINAL TOTAL $999999.99**** SELF-TEST

32 1. DIV, DEPT, and ITEM are called ____ fields. SOLUTION: control

33 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)

34 SELF-TEST 3. The printing of a line for each input record is called ____ printing. SOLUTION: Detail

35 SELF-TEST 4. The printing of total lines for DIV, DEPT, and ITEM is called ____ printing. SOLUTION: summary or group

36 SELF-TEST 5. Each total line is referred to as a ____. SOLUTION: CONTROL FOOTING

37 SELF-TEST 6. The major-level control item, as specified on the output, is ____. SOLUTION: DIV (after FINAL)

38 SELF-TEST 7. The intermediate-level control item is ____, and the minor-level control item is ____. SOLUTION: DEPT; ITEM

39 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. SOLUTION: two; ITEM

40 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

41 SELF-TEST 10. A ____ prints after all records and control totals, at the end of the job. SOLUTION: final total

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

43 SELF-TEST 12. (T or F) 01 - level record description entries must not follow the above FD entries. SOLUTION: T

44 SELF-TEST 13. The REPORT SECTION must follow the ____ and ____ SECTIONs in the ____ DIVISION. SOLUTION: FILE; WORKING- STORAGE; DATA

45 SELF-TEST 14. The name following the RD level- indicator is the same as the name following the ____ clause in the ____ SECTION for the output file. SOLUTION: REPORT IS or REPORTS ARE; FILE

46 SELF-TEST 15. Code the RD entry and its clauses for the preceding illustration. SOLUTION: 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.

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

48 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] [NEXT GROUP Clause]

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

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

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

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

53 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 one CONTROL FOOTING per control item. CONTROL FOOTING FINAL is used to print final totals at the end of a report.

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

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

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

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

58 PROCEDURE DIVISION Statements

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

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

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

62 CHAPTER SLIDES END HERE CHAPTER SUMMARY COMES NEXT

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

64 CHAPTER SUMMARY 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.

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

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

67 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. 3. Before closing the files, TERMINATE report-name-1.


Download ppt "COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)"

Similar presentations


Ads by Google