[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

10.6.6 Printing a Linage-File Report

The default PRINT command inserts a page ejection when a form nears the end of a page. Therefore, when the default PRINT command refers to a linage-file report, it can change the report's page spacing.

On Tru64 UNIX systems, to print a linage-file report, use this command:


% lpr report-file-specification  <>

On OpenVMS systems, to print a linage-file report, use the /NOFEED qualifier with the DCL PRINT command as follows:


$ PRINT report-file-specification/NOFEED

On OpenVMS systems, the LINAGE clause causes an HP COBOL report file to be in print-file format. (See Chapter 6 for more information.) <>

When a WRITE statement positions the file to the top of the next logical page, the device is positioned by line spacing rather than by page ejection or form feed.

For more information on printing your report, see Section 10.7.

10.6.7 A Linage-File Report Example

Example 10-5 shows an HP COBOL program that produces a linage-file report.

The LINAGE clause in the following File Description entry defines the logical page areas shown in Figure 10-8:


FD  MINIF1-REPORT
    LINAGE IS 13 LINES
                       LINES AT TOP      2
                       LINES AT BOTTOM   5.

Figure 10-8 shows a 20-line logical page that includes a top margin (T), a page body (P), and a bottom margin (B).

Figure 10-8 A 20-Line Logical Page


The first line to which the logical page can be positioned is the third line on the page; this is the first print line. The page-overflow condition occurs when a WRITE statement causes the LINAGE-COUNTER value to equal 15. Line 15 is the last line on the page on which text can be written. The page advances to the next logical page when a WRITE statement causes the LINAGE-COUNTER value to exceed 15. The pointer is then positioned on the first print line of the next logical page.

LINAGE is the sum of N (where N represents the number of lines of text) plus X (where X represents the number of lines at the top) plus Y (where Y represents the number of lines at the bottom). The sum total should not exceed the length of the physical page, which is usually 66 lines.

Example 10-5 Programming a 20-Line Logical Page Defined by the LINAGE Clause with Automatic Page Overflow

IDENTIFICATION DIVISION.
PROGRAM-ID. REPLINAG.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT INPUT-FILE   ASSIGN TO "REPIN.DAT".
    SELECT MINIF1-REPORT ASSIGN TO "MINIF1.DAT".
DATA DIVISION.
FILE SECTION.
FD  INPUT-FILE.
01  INPUT-RECORD.
    02  I-NAME.
        03  I-FIRST                      PIC X(10).
        03  I-MID                        PIC X.
        03  I-LAST                       PIC X(15).
    02  I-ADDRESS.
        03  I-STREET                     PIC X(20).
        03  I-CITY                       PIC X(15).
        03  I-STATE                      PIC XX.
        03  I-ZIP                        PIC 99999.
FD  MINIF1-REPORT
    LINAGE IS 13 LINES
           LINES AT TOP    2
           LINES AT BOTTOM 5.
01  MINIF1-PRINT-LINE                    PIC X(80).
WORKING-STORAGE SECTION.
01  END-OF-FILE                          PIC  X     VALUE SPACE.
01  LINE-UP-OK                           PIC  X     VALUE SPACE.
01  MINIF1-LINE-3.
    02  FILLER                           PIC X(9)   VALUE SPACES.
    02  MINIF1-LAST                      PIC X(15).
    02  FILLER                           PIC X(23)  VALUE SPACES.
    02  FILLER                           PIC X(6)   VALUE "Date: ".
    02  MINIF1-DATE                      PIC 99/99/99.
01  MINIF1-LINE-13.
    02  FILLER                           PIC X(4)   VALUE SPACES.
    02  MINIF1-NAME                      PIC X(26).
01  MINIF1-LINE-14.
    02  FILLER                           PIC X(4)   VALUE SPACES.
    02  MINIF1-STREET                    PIC X(20).
01  MINIF1-LINE-15.
    02  FILLER                           PIC X(4)   VALUE SPACES.
    02  MINIF1-CITY                      PIC X(15).
    02  FILLER                           PIC X      VALUE SPACE.
    02  MINIF1-STATE                     PIC XX.
    02  FILLER                           PIC X      VALUE SPACE.
    02  MINIF1-ZIP                       PIC 99999.
PROCEDURE DIVISION.
A000-BEGIN.
    OPEN OUTPUT MINIF1-REPORT.
    ACCEPT MINIF1-DATE FROM DATE.
    PERFORM A300-FORM-LINE-UP UNTIL LINE-UP-OK = "Y".
    OPEN INPUT  INPUT-FILE.
    PERFORM A100-READ-INPUT UNTIL END-OF-FILE = "Y".
A010-WRAP-UP.
    CLOSE INPUT-FILE
          MINIF1-REPORT.
    DISPLAY "END OF JOB".
    STOP RUN.
A100-READ-INPUT.
    READ INPUT-FILE AT END MOVE "Y" TO END-OF-FILE.
    IF END-OF-FILE NOT = "Y"
       PERFORM A200-PRINT-REPORT.
A200-PRINT-REPORT.
    MOVE I-LAST          TO MINIF1-LAST.
    WRITE MINIF1-PRINT-LINE FROM MINIF1-LINE-3 BEFORE ADVANCING 1 LINE.
    MOVE SPACES TO MINIF1-PRINT-LINE.
    WRITE MINIF1-PRINT-LINE AFTER ADVANCING 9 LINES.
    MOVE I-NAME          TO MINIF1-NAME.
    WRITE MINIF1-PRINT-LINE FROM MINIF1-LINE-13 BEFORE ADVANCING 1 LINE.
    MOVE I-STREET        TO MINIF1-STREET.
    WRITE MINIF1-PRINT-LINE FROM MINIF1-LINE-14 BEFORE ADVANCING 1 LINE.
    MOVE I-CITY          TO MINIF1-CITY.
    MOVE I-STATE     TO MINIF1-STATE.
    MOVE I-ZIP       TO MINIF1-ZIP.
    WRITE MINIF1-PRINT-LINE FROM MINIF1-LINE-15 BEFORE ADVANCING 1 LINE.
A300-FORM-LINE-UP.
    MOVE ALL "X" TO INPUT-RECORD.
    PERFORM A200-PRINT-REPORT 3 TIMES.
    DISPLAY "Is Alignment OK? (Y/N): " WITH NO ADVANCING.
    ACCEPT LINE-UP-OK.

10.7 Modes for Printing Reports

Your HP COBOL program can spool the report to a mass storage device for printing later. Section 10.7.1 describes this mode of printing.

10.7.1 Spooling to a Mass Storage Device

To spool your report to a mass storage device (such as a disk or magnetic tape) for later printing, your HP COBOL program must include a file specification. For example, to spool JAN28P.DAT you would include the following code in your program:


SELECT REPORT-FILE ASSIGN TO "USER1$:JAN28P".   (OpenVMS)
SELECT REPORT-FILE ASSIGN TO "/usr1$/JAN28P".   (Tru64 UNIX)

Spooling to a mass storage device has the following advantages:

  • You can run your job at any time regardless of other printer activity and printer status.
  • Your application program does not make immediate resource demands on the printer.
  • You can schedule the printing based on production and shop requirements, and print the file according to your priority needs.
  • You optimize use of the printer. Spooling results in printing the maximum number of lines per minute.
  • You have a backup of the file.

Spooling to a mass storage device has the following disadvantages:

  • You do not see immediate results.
  • It is difficult and expensive to input preprinted form numbers (for example, check numbers) from your forms into your report file.

10.8 Programming a Report Writer Report

Report Writer allows you to describe the appearance of a report's format. To do this, you specify the Report Writer statements that describe the report's contents and control in the Report Section of the Data Division. These statements replace many complex, detailed procedures that you would otherwise have to include in a conventional or linage-file report.

The following sections explain how to produce a report with the Report Writer. These sections describe how to do the following:

  • Use the REPORT clause in the FD statement of the FILE section.
  • Define the Report Section and the report description.
  • Define the Report Writer logical page.
  • Specify multiple reports.
  • Define and increment totals.
  • Process a Report Writer report.
  • Select a Report Writer type.

Detailed examples using Report Writer are documented in Section 10.9.

10.8.1 Using the REPORT Clause in the File Section

To create a report with Report Writer, you must write a report to a specific file. That file is described by a File Description (FD) entry; however, unlike a conventional or linage-file report, your FD entry for a Report Writer file must contain the REPORT clause, and you must assign a name for each report in the REPORT clause.

For instance, in the following example, the File Description on the left does not specify Report Writer; however, the example on the right correctly shows a Report Writer File Section entry:


FD  SALES-REPORT                        FD  SALES-REPORT
    .                                   .
    .                                   .
    .                                   .
01  SALES-AREA     PIC X(133).
01  PRINT-AREA     PIC X(133).          REPORT IS MASTER-LIST.

To completely describe the report that you specify in the REPORT clause, you must define a Report Section in the Data Division. Section 10.8.2 describes the Report Section.


Previous Next Contents Index