Previous Topic Next topic Print topic


Report Writer Structures

Use Report Writer structures to code report logic in batch programs and applications after you paint your report mock-up in the Report Painter. Report Writer structures enable you to:
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.
  • Automatically page the report
  • Define headers and footers
  • Calculate field values
  • Test and execute control and page breaks
  • Generate multiple reports
  • Generate all logic necessary to map fields between reports and databases or files

Code these Report Writer structures in the Program Painter for report programs.

IO

FD

Name the input and output files.

RED

Add a Report Section to your program.

CODE

Specify a 2-character literal that identifies each print line with a specific report.

CONTROL

Identify data items that cause control breaks.

WRITE ROUTINE

Override a standard COBOL WRITE statement and execute your own routine.

PAGE LIMIT

Define the report format, such as the number of lines per page and where report lines appear on the page.

MOCK

Identify the report mock-up.

01

TYPE

Describe function, format, and characteristics of each report line.

MOCKUP LINES

Map the report mock-up lines to the lines on the printed report.

OVERPRINT

Highlight or underscore the lines identified in the MOCKUP LINES clause.

SOURCE

Map the report mock-up fields to the output fields on the printed report.

VALUE

Designate a literal value to print for the field each time the line prints.

REFERENCE

Identify a non-printing data field for summing in a control break.

SUM

Establish a sum accumulator for a corresponding SOURCE or REFERENCE data field, and print the total in a control break.

INITIATE

Open report files and initialize page, line, and sum counters and accumulators.

GENERATE

Generate and print all the report lines.

USE BEFORE REPORTING

Specify additional processing for a report group prior to printing.

TERMINATE

End report processing and close all files.

Rules:

The sequence in which mock-up fields are matched with the data item descriptions is the same as a page of text is read–from left to right across each line of the mock-up starting with the top line and continuing to the bottom. AMB matches the report mock-up fields to the data item description entries in your program according to the following rules:

  1. The following are considered literals:
    • The COBOL picture character A.
    • Any one or more consecutive non-space, non-picture characters.
    • Any single COBOL picture character, that is preceded and followed by a space. Exception to this rule: 9 and X.
    • A string of hyphens because of its frequent use for underlining.
    • AMB considers a single COBOL picture character, such as -, X, Z, or 9, that is embedded in a string of non-blank, non-picture characters as part of a literal. For example, the following are literals
      1979
      WXYZ
      EXTRA
      WIZARD
  2. The following are considered pictures beside literals:
    #99 Literal is #, PIC is 99
    l999 Literal is l, PIC is 999
    Section-999 Literal is SECTION, PIC is -999
  3. AMB considers any legal COBOL picture longer than one character to be a COBOL picture, except for the letter S and the hyphen (-), and matches it to the next data item description in the program.
  4. AMB generates a VALUE statement for each literal in the mockup, and does not match the literal with the data item descriptions in the program.
  5. AMB considers any consecutive PIC characters in the mock-up as one PIC character string, unless the string is matched with PIC clauses in multiple, consecutive SOURCE statements.
  6. AMB assigns each PIC character string as the PIC for the next sequential data item description, unless the next description contains a PIC clause.
  7. When a data item description contains a PIC clause, AMB compares it with an equal number of characters in the mock-up, starting with the next sequential, unassigned character in the mock-up.
  8. When comparing a data item description entry with a PIC clause to an equal number of characters in the mock-up and a non-match occurs, AMB continues the comparison by moving one position to the right until it finds a match. AMB considers the non-matched characters from this process to be a literal, and generates a VALUE entry that precedes the data item description with the PIC clause that initiated the comparison.
  9. When a PIC clause in a data item description does not match any series of mock-up characters from the start of a comparison to the end of the mock-up, AMB terminates processing and generates an error message.

Coding Conventions

Code Report Writer structures in the Program Painter, associating the structures with keywords, as shown in this sample skeletal Report Writer program:

Example: Sample Skeletal Report Writer Program

IO     Input/Output statements
              .
 FD     Input FD clause
 01     Input record description
 FD     Output FD clause
 01     Output record description
 RED    reportfilename
        CODE clause
        CONTROL clause
        WRITE ROUTINE clause
        PAGE LIMIT nn LINE
            FIRST DETAIL linenumber
            LAST DETAIL linenumber
            FOOTING linenumber.
 MOCK mockupreportname
 01   TYPE IS REPORT HEADING /*for report header
      MOCKUP LINES clause
      OVERPRINT clause
      SOURCE clause|VALUE clause
 01   TYPE PAGE HEADING        /*for page header
      MOCKUP LINES clause
      SOURCE clause|VALUE clause
 01   TYPE CONTROL HEADING  /*for control header
      MOCKUP LINES clause
      SOURCE clause or VALUE clause
 01   TYPE DETAIL             /*for detail lines
      MOCKUP LINES clause
      SOURCE clause|VALUE clause
      REFERENCE clause
 01   TYPE CONTROL FOOTING   /*for control break
      MOCKUP clause
      SOURCE clause|VALUE clause
      SUM clause
 NTRY
          .
          .
          .
      INITIATE statement
          .
          .
      GENERATE statement
          .
          .
      TERMINATE statement
          .
          .
          .
Previous Topic Next topic Print topic