[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index


Chapter 10
Producing Printed Reports

There are three Hewlett-Packard COBOL programming capabilities for producing formatted reports: conventional, linage file, and Report Writer. This chapter presents the following topics to help you format and produce reports:

10.1 Designing a Report

The design of a report is dictated by the data you must include in the report. If you have a general idea of what the report is to contain, you can produce a rough outline using a report layout worksheet.

To create the worksheet, either use an online text editor or draw a layout worksheet like the one displayed in Figure 10-1.

Figure 10-1 Sample Layout Worksheet


The layout worksheet in Figure 10-1 has 132 characters on a line and 60 lines on a page. When you outline your worksheet, include specifics such as page headings, rows and columns, and column sizes.

Section 10.2 describes other report components that you must plan for when you design a report. Note that you can use your worksheet later when you write the HP COBOL program that produces the report.

10.2 Components of a Report

There are seven components of a report. Example 10-1 illustrates them.

Example 10-1 Components of a Report

(1)  ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
                            ******************
                            *                *
                            *  YEAR TO DATE  *
                            *  SALES REPORT  *
                            *                *
                            ******************
                          FOR INTERNAL USE ONLY
                               DO NOT COPY
                FOR SECURITY CLEARANCE LEVELS 1, 2, AND 3
    ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
(1)  ********************** COMPANY CONFIDENTIAL **********************
                                   .
                                   .
                                   .
(2)  04-NOVEMBER-96            Year To Date Sales Report      Page    1
    Salesman  Salary/Bonus  Client Name    Client Address  Total Sales

(3)  ************************ JANUARY REPORT **************************

(4)  SMITH      $30,000.00   STREN         2742 NORTH ST.  $225,000.00
      JOHN     $10,000.00     TOM         MANCHESTER, NH
       .            .           .                 .             .
       .            .           .                 .             .
(4)     .            .           .                 .             .
(5)  TOTAL  JANUARY  SALES:  $ 2,000,000.00
    ******************************************************************
    ************************ FEBRUARY REPORT *************************
    .            .           .                 .             .
    .            .           .                 .             .
    .            .           .                 .             .
(6)  ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
(6)  <<<<<<<<<<<<<<<<<<<<<<<CONTINUED ON NEXT PAGE>>>>>>>>>>>>>>>>>>>>>
                             .
                             .
                             .
   04-NOVEMBER-96            Year To Date Sales Report      Page 1324

(7)  ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
                            ******************
                            *                *
                            *     END OF     *
                            *  YEAR TO DATE  *
                            *  SALES REPORT  *
                            *                *
                            ******************
               Total  Records:                123456
               Total  Salesmen:                 6754
               Total  Sales:         $123,456,789.99
               Total  Salaries:      $  9,876,543.21
               Total  Bonus:         $  6,789,012.34
               Total  Report Pages:             1324
    ********************** COMPANY CONFIDENTIAL **********************
    ********************** COMPANY CONFIDENTIAL **********************
(7)  ********************** COMPANY CONFIDENTIAL **********************

The numbers in the following list correspond to the circled numbers in Example 10-1:

  1. Report Heading (RH)---The report heading (the lines marked with 1 and all the lines between) consists of information printed before the main body of a report. It can be printed on a separate page, or as the first page heading, with the remaining page headings abbreviated to save paper. The report heading can include information such as handling and distribution instructions. It can also include the selection criteria, sort order, and assumptions made when creating the report.
  2. Page Heading (PH)---The page heading (the line marked with 2 and the line following) consists of information printed on the top one or more lines of every page in the report. It usually names and dates the report, gives the report page number, and produces a title for each column of information in the detail line.
  3. Control Heading (CH)---The control heading consists of one or more lines of information identifying the beginning of a new logical area on a page.
  4. Detail Lines (DL)---The detail (the lines marked with 4 and all the lines between) consists of one or more lines of the primary data of the report.
  5. Control Footing (CF)---The control footing (the line marked with 5 and the following line) consists of one or more lines of information identifying the end of a logical area. The control footing can contain one or more totals and an accompanying message.
  6. Page Footing (PF)---The page footing (the lines marked with 6 and all the lines between) consists of one or more lines of information at the bottom of each page.
  7. Report Footing (RF)---The report footing (the lines marked with 7 and all the lines between) consists of information printed after the main body of the report. It can be continued on the same page of the report body, or it can be on a separate page. It may contain information such as hash or control totals. A report footing is a convenient place to print run-time statistics, such as the number of records read and written for each file. It can also provide warning messages, such as when a table is close to overflowing.
    It is suggested that all reports have an END OF REPORT message or other indicator at the end of the report, so that you can tell at a glance that you have all the pages. (The consecutive page numbers tell if a page is missing, but they do not indicate which page is the last.)

10.3 Accumulating and Reporting Totals

Your program can report three types of totals in the control footings and report footings of your report:

  • Subtotals---Subtotaling is the process of summing a detail item from each detail line. For example, in Figure 10-2, Salary, Bonus, and Total Sales are subtotaled. To get the first salary subtotal for January on page 1 ($75,000.00), the program must add each salesman's salary ($30,000+$25,000+$20,000). After printing the salary total, the program must zero the total to begin subtotaling for the next month.
  • Crossfoot Totals---Crossfooting is the process of summing subtotals from a common group of totals. For example, in Figure 10-2, TOTAL SALARY EXPENSE is crossfooted by adding TOTAL SALARY and TOTAL BONUS. To get the first TOTAL SALARY EXPENSE crossfoot total for the January report, the program must add the salary subtotal and the bonus subtotal before the program clears the subtotals.
  • Rolled Forward Totals---Rolling-forward is the process of summing either subtotals or crossfoot totals. For example, in Figure 10-2, the YEAR TO DATE TOTALS at the bottom of page 1 are rolled forward from both the JANUARY and FEBRUARY totals. The program computes the salary and bonus YEAR TO DATE TOTALS from the previous salary and bonus subtotals. It computes the total salary expense figure from the previous total salary expense crossfoot totals.

Figure 10-2 Subtotals, Crossfoot Totals, and Rolled Forward Totals



Previous Next Contents Index