Previous Topic: Basic Steps to Create a ReportNext Topic: Report Maintenance Menu


Simple Sample Report

Using the three steps listed previously, you can create a program that prints a report containing the names of all of the customers in Texas.

  1. Define the report named CUSTRPT, starting with the following command:
    CREATE REPORT CUSTRPT
    

    The Identification fill‑in screen displays.

    => ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL: RPT IDENTIFICATION RPT CUSTRPT (001) TEST SYS: DOC FILL‑IN REPORT Name CUSTRPT Created          03/11/94                By JONES Last Modified    03/11/94 at 14:02       By JONES Short Description Sample report. _________ Description: This is the report description area for wordier descriptions. __ ________________________________________________________________ ________________________________________________________________ ________________________________________________________________

    The identification information shows the name assigned to the report, the creation date, and the user ID assigned to the report creator. The Last Modified information contains the creation date until the report is edited. A Short Description is included. You can also include a longer description, up to five lines.

    After the Identification fill‑in is complete, the Detail fill‑in is accessed to define the content. Each field must be listed in order, by name. You can specify the format or edit pattern for each field with several other attributes.

    => ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ IDEAL : RPT DETAIL DEFN. RPT CUSTRPT (001) TEST SYS: DOC FILL‑IN Field Name, Literal,       Sort Break Function Column Function, or               L A   L S I T M M A H W Command Arithmetic Expression      V /   V K N O A I V D ID Tab Edit Pattern                                     L D   L P D T X N G G TH ‑‑‑‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑ ‑‑ ‑‑‑ ‑‑‑‑‑‑‑‑‑‑‑‑‑ ====== =========== T O P ======= = = = = = = = = = = == === ============= 000100 CUSTOMER.NAME _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000200 CUSTOMER.CITY _ _ _ _ _ _ _ _ _ _ __ ___ _____________ 000300 CUSTOMER.OPEN$ _ _ _ _ _ _ _ _ _ _ __ ___ Z,ZZZ,ZZ9.99 ====== ========= B O T T O M === = = = = = = = = = = == === =============

    This report contains the customer name, city, and outstanding amount owed. The report fields use data from columns in the CUSTOMER dataview, as the Field Names show: CUSTOMER.NAME, CUSTOMER.CITY, and CUSTOMER.OPEN$.

    Notice that an edit pattern is specified for the field CUSTOMER.OPEN$, which is a numeric field. If you do not specify an edit pattern, the edit pattern as defined for the column in the Datadictionary is used. For numeric data, if an edit pattern was not defined in the Datadictionary, a default pattern of Z(i).Z(d) is used, where i is the number of integers to the left of the decimal point and d is the number of decimal places to the right of the decimal point. For information on valid edit patterns, see the appendix "Fill-in Descriptions."

  2. Identify the Report to the Program.

    The following report must be identified to the program on the Resources fill‑in:

    => => => IDEAL : Resource Edit Panel PGM SAMPLE (001) TEST          SYS: DOC DISPLAY Command Type    Name of DVW/PGM/PNL or RPT         Version System Qual? ====== ===     ========== T O P ===============     ====     ===     = 000001 RPT     CUSTRPT                              001      DOC ====== ===     ======= B O T T O M ============     ====     ===     =

  3. Code the PRODUCE Statement.

    You can code the PRODUCE statement anywhere in the program. Usually, it is coded in a LOOP or FOR construct to generate the report details. In this example, the PRODUCE statement is coded in the FOR EACH construct. The WHERE clause criteria limit the set to all customers in Texas.

    FOR EACH CUSTOMER
        WHERE STATE EQ 'TX'
        PRODUCE CUSTRPT
    ENDFOR
    

    With each iteration of the FOR construct, the PRODUCE statement writes the contents of the specified columns of the current row to the report file as a detail line. A MOVE or SET statement is not needed. The customers are listed in the sequence in which the database accessed them, therefore, they are not in alphabetical order by name or city.

    There is nothing in the program that formats the data or deals with pagination, headings, and so on.

The following is a sample of the resulting report:


NAME                          CITY                 OPEN$
CHEMICAL MUTUAL               FORT WORTH           931.72
GULF LAND USA                 DALLAS             7,100.00
TEXAS LIFE & CASUALTY CO.     DALLAS               543.21
AFTON INDUSTRIES              DALLAS             1,234.51
PALMOLIVE INNS                FORT WORTH           758.93
  .
  .
  .

In this example, the column headings and width were taken from the definition in the dictionary facility. By default, two spaces are inserted between each column. One line is inserted between the column heading and the detail lines. There are no other headings or footings in this report.