How do I use VISION:Report Automatic Reporting?

Document ID : KB000031013
Last Modified Date : 14/02/2018
Show Technical Document Details

The automatic reports that VISION:Report can generate are based on the number of fields, and the length of each field.
You will need to add two statements: a REPORT statement, and a PRINT REPORT statement.
We'll examine both of these statements, their syntax (don't go away - it's not that complicated!), and where these statements typically are placed.

The REPORT statement

REPORT flddef [SPACEnn] [nC|nE|nN|n mask-code] [(override-headers)] [flddef ...]

Don't worry - it's not as bad as it looks. We'll break it down and you'll see how easy it is:

flddef

This is the field that you wish to print. It can be previously defined or you can reference a storage field.

Examples:

AR-KEY, INF1-5, WST6-10
AR-PHONE, AR-BILL-DATE AR-BAL-PARTPAY

SPACEnn

Allows you to specify control of spacing between data columns, where nn is a 1- or 2-digit number stating the number of spaces between the report columns. It should be stated between two field definitions or preceding the first field definition in the REPORT declarative.

Examples:

REPORT FLD-A FLD-B SPACE5 AR-KEY
REPORT FLD-A SPACE10 AR-BILL-DATE

 

[nC|nE|nN|n mask-code]

This defines the edit mask code for numeric fields

C - Commas are inserted as appropriate.
E - European variation of commas/decimals appear.
N - Zero suppression is not performed.
n - Specifies how many digits are to appear to the right of the decimal point, 0-9.

Any VISION:Report or user-supplied edit masks may be applied.
The following example also shows a phone number mask.

Examples:

REPORT AR-NAME AR-PHONE P CLIENT-NO

Override Headers

Headings written follow the data names they head. If headers are not specified,
VISION:Report generates column headings from the equated names and field definitions
in the REPORT declarative.

Example:

REPORT AR-KEY INF1-20 (AR-LAST-NAME) 
AR-FIRST-NAME INF90-94 (ZIP)
AR-BILL-DATE AR-BAL-PARTPAY

The above example causes a heading of:

  • AR-KEY above the data columns containing the field AR-KEY

  • AR-LAST-NAME AR-KEY above the data columns containing the field INF1-20

  • AR-FIRST-NAME above the data columns containing the field AR-FIRST-NAME

  • ZIP above the data columns containing the field INF90-94

  • etc.

The PRINT REPORT statement

PRINT REPORT [DOUBLESPACE|TRIPLESPACE] [SUMMARY] [OMIT] FLDDEF ...]

This statement is used in conjunction with the REPORT statement previously described.
The fields stated in the REPORT statement are in the report in the same order you list them.

DOUBLESPACE

Causes one blank line before printing your report line.

TRIPLESPACE

Causes two blank lines before printing your report line.

SUMMARY

Produces a summary report. Using the SUMMARY operand produces a report showing only total lines
for each break group. For instance, if you code a BREAK statement for DEPT, your report shows only
total lines for each department, never showing the detail from each record. In our examples here,
we will not show examples of using the SUMMARY operand.

OMIT

Suppresses printing of the specified fields.

Assume the following REPORT declarative was coded:

REPORT AR-KEY INF1-20 (AR-LAST-NAME) 
AR-FIRST-NAME INF90-94 (ZIP)
AR-BILL-DATE AR-BAL-PARTPAY

Examples:

PRINT REPORT OMIT AR-BILL-DATEAR-BAL-PARTPAY

Everything would be printed except AR-BILL-DATE and AR-BAL-PARTPAY

Sample Programs

Here is a very simple and basic program. Statements that are operating system dependent have
comments that identify the applicable operating system, such as VSE or OS/390, which includes z/OS.
It is assumed that the proper JCL has been coded.

Example 1:

  OPTION UEXIT1=QUIKINCL  INFKSDS    0352          /* VSE to describe files  EQU  AR-ENT-RECORD          INF000-000  ++INCLUDE Q.ARDEFINE   /* VSE for "COPY" books  REPORT AR-CUST-NAME AR-ACCT-CODE  010  GET INF  PRINT REPORT  GOTO 010  9999END

Example 2:

  EQU ACCTNO        INF004  EQU ACCTCODE      INF182  EQU ACCT-TOTAL    CTA1-8  REPORT ACCTNO (ACCOUNT'NUMBER) SPACE5  ACCTCODE (CODE)  ACCT-TOTAL (TOTAL)  BREAK 1 ACCTCODE SB 1 SA 0  010   GET INF ATEND EOJ  CHECKBREAKS  ACCUM ONE IN A 8 BYTE CTA  PRINT REPORT  GO TO 010  9999END

Example 3:

This last example shows the power of incorporating other statements, in conjunction with the Automatic Report:

  1. BREAK, CHECKBREAKS, and ACCUM statements, with Space Before/Space After on zip code and state. 

  2. REPORT declarative with overriding headers.

  3. SORT input file, INK, by zip code in descending order.

  4. Issue a PRINT REPORT based on first digit of zip code. When the first digit of the zip code is a 7, we omit printing the last name and we double space.

  5. Note also the usage of the pair, IF and ENDIF. 

  6. Usage of TITLE statement.
    OPTION UEXIT1=QUIKIPDS    /* OS/390 onlyEQU  AR-ENT-REC             INK000-000  /* Input file storage area++INCLUDE ARDEFINE     /* OS/390 "COPYBOOK" from PDSEQU  AR-ZIP-ALL             WST1-5EQU  AR-ZIP-ALL                      /* REDEFINESEQU  AR-ZIP-1                 (1)    /* FIRST DIGITEQU  AR-ZIP-2-5               (4)TITLE 'EXAMPLE 3:  A LITTLE OF EVERYTHING'BREAK 1 AR-ZIP   SB 2 SA 2 PRINT C'ZIP BREAK'BREAK 2 AR-STATE SB E SA E PRINT C'STATE BREAK'REPORT   AR-ZIP           (Z,  I,   P)AR-STATE         (STATE)AR-ACCOUNT       (ACCOUNT-NR)AR-ACCT-CODEAR-LAST-NAME     (CUSTOMER LAST NAME)AR-CITY          (CITY)SORT FILE INK ON AR-ZIP (D)  AR-STATE /* SORT DESCENDING ORDER010  GET INK ATEND EOJ* EDIT RECORDS THAT ARE "BAD"IF AR-ZIP           IS NOT NUMERICGOTO 010.IF AR-STATE         = SPACESGOTO 010.IF AR-CUST-NAME     = SPACESGOTO 010.CHECKBREAKSACCUM AR-INSTL-BAL  IN A 7 BYTE CTAMOVE AR-ZIP TO AR-ZIP-ALL /* BREAK DOWN ZIP-CODEIF AR-ZIP-1 EQ C'7'   /* CHECK ZIP STARTING WITH A '7'PRINT REPORT DOUBLESPACE OMIT AR-LAST-NAME  /* SKIP LAST NAMEELSEPRINT REPORT                                 /* ELSE PRINT ALLENDIFGOTO 010.9999END