HPlogo QUERY/V Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3 QUERY/V COMMANDS

REPORT

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

Lists data item values of entries located by a retrieval command in the format you specify.

Syntax

   R[EPORT] report statement;... END

For example:

       >REPORT

      >>H1,"NAME LIST",20,SPACE A2

      >>D,LAST-NAME,20

      >>D,FIRST-NAME,30

      >>END

or

   >R H1,"NAME LIST",20,SPACE A2;D,LAST-NAME,20;D,FIRST-NAME,30;END

Where header statement = H1,"NAME LIST",20,SPACE A2 and detail statements = D,LAST-NAME,20 and D,FIRST-NAME,30

Parameter

report statements

consist of a sequence of header, detail, sort, group, total, register, edit, and output control statements, as outlined in Table 3-5 “REPORT Statements”. These statements are explained in detail later in this section. Statements can be entered on separate lines or on one line separated by semicolons.

Discussion

If you enter REPORT without following it with report statements, QUERY will prompt you for the statements until you enter an END at the prompt.

If the first report statement is in error, the REPORT command terminates.

The REPORT command is an extension of a retrieval command in that it prints a report of the data entries located by the last FIND, MULTIFIND, or SUBSET command.

REPORT output can be directed to any desired output device through the MPE :FILE command and the QUERY OUTPUT= command. Refer to the OUTPUT= command for further discussion.

You can specify your own user defined procedure(s) to enable your report to perform specialized tasks not provided by QUERY. This is an advanced capability used by programmers. Refer to Appendix F for further discussion.

Table 3-5 REPORT Statements

STATEMENTFUNCTION
HeaderPrints title, column headings, page numbers, time of day, and the date at the top of each report page.
DetailPrints data item or register values or a character string in the column position specified.
SortSorts data based on the value of a specified data item.
GroupPrints a data item value or character string whenever the value of an appropriate "sort item" changes.
TotalPrints count, average, or totals for logical groups or entire report.
EditDescribes edit masks used to punctuate Group, Detail, or Total fields.
RegisterSpecifies an operation to be executed in Register n.
Output controlSpecifies the report output parameters.

 

REPORT Statements

Statements can also contain additional parameters which perform such tasks as skipping to the top of the next report page, spacing between report lines, and indicating edit masks to be used to insert punctuation such as decimal points, dollar signs, etc., into values printed in the report. These options are described in Table 3-6 “REPORT Statement Parameters”.

Table 3-6 REPORT Statement Parameters

PARAMETERFUNCTIONAPPLICABLE
  STATEMENTS
print positiondetermines the rightmost print position (column number) for the print element. For character data, this is the rightmost character; for numeric data, it is the position of the least significant digit.Header, Detail, Group, Total
SPACE A[number]space number lines after printing the report line. If number is omitted, one line is spaced.Header, Detail, Group, Total
SPACE B[number]space number lines before printing the report line. If number is omitted, one line is spaced.Header, Detail, Group, Total
numberis the number of lines to be spaced (from 1 to 5). 
   SKIP {A

         B}
skips to the top of the next report page after printing the report line (SKIP A) or before printing the report line (SKIP B).Detail, Group, Total
   E{number

     Z}
indicates that either an edit mask defined in the identically numbered edit statement (Enumber) is used to punctuate a value or, if you use the letter Z, that leading zeros are to be suppressed. In the latter case, no edit statement is required.Detail, Group, Total

 

Skipping and Spacing

When paging is in effect, the following rules govern skipping and spacing:

  1. If a SKIP B and a SPACE B are both associated with the same output line, the SKIP B is processed before the SPACE B.

  2. If there are not enough lines remaining on the current page to satisfy a SPACE B, a page is ejected and then the spacing is effected.

  3. If a SKIP A and a SPACE A are both associated with the same output line, the SPACE A is ignored.

  4. If there are not enough lines remaining on the current page to satisfy a SPACE A, it is treated as a SKIP A.

  5. A SKIP A on the last line of the report will not be executed.

  6. SPACE A and SPACE B are allowed on the same REPORT statement. The SPACE B is done first, then the SPACE A.

Designing a Report

Report formats vary according to their use. However, many reports assume the general format depicted in Figure 3-7 “General Report Format”. The TITLE and HEADERS describe the report and are printed at the top of each page along with the page number. HEADERS are usually used to describe the report columns.

The report body consists of DETAIL lines, GROUP TITLES, and TOTALS along with other descriptive labels. Normally, each detail line displays information from a single data entry, although information can appear on more than one line per entry. A DETAIL field can be edited to include commas, decimal points, dollar signs, and other punctuation characters.

DETAIL lines can be sorted and grouped according to the values of data items in the entry. For example, a sales report may list sales results by country, region, sales office, and finally by individual salesperson within each office. A GROUP TITLE can be printed whenever a "sort field" changes value. For example, when the country changes, the name of the country could be displayed as a GROUP TITLE. The title can be a series of characters or a data item value.

SUBTOTALS can be printed for logical groups (for example, for each sales office) and GRANDTOTALS for the entire report. These totals add, average, or count the DETAIL fields in each column of the report. Like DETAIL and GROUP fields, TOTAL fields can be edited with punctuation characters.

Figure 3-7 General Report Format

                                  TITLE OF REPORT                 PAGE NO.





                   HEADER             HEADER             HEADER





GROUP TITLE        DETAIL             DETAIL             DETAIL

                   DETAIL             DETAIL             DETAIL

                   DETAIL             DETAIL             DETAIL



                   SUBTOTAL           SUBTOTAL           SUBTOTAL





GROUP TITLE        DETAIL             DETAIL             DETAIL

                   DETAIL             DETAIL             DETAIL

                   DETAIL             DETAIL             DETAIL



                   SUBTOTAL           SUBTOTAL           SUBTOTAL





                   GRANDTOTAL         GRANDTOTAL         GRANDTOTAL

Through the following sections on REPORT Statements, a report is created by adding one statement type at a time and showing how the added statements change the report. Figure 3-8 “Sample Report” contains the final version of the report.

Figure 3-8 Sample Report



 AS OF: 01/07/86                                                  PAGE 1

                             BOBO'S MERCANTILE

                             ON HAND INVENTORY





 BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                               AMOUNT



   0   H & S SURPLUS

                             7391Z22F     8/13/85           $5,012.50

                             5405T14F     9/11/85          $12,129.60

                             6650D22S    12/05/85          $14,985.00



      BIN TOTAL                                            $32,127.10  *





   1   ACME WIDGET

                             2457A11C    12/01/85     $553,477,666.95

       BAY PAPER CO.

                             7391Z22F    12/01/85           $4,704.00

       CARDINAL MILLS

                             5405T14F    11/28/85           $1,396.00









          JAKE'S JUNK

                                3739A14F    12/15/85           $1,189.32



         BIN TOTAL                                       $553,485,956.27 *





      2   ACME WIDGET

                                4397D13P     3/02/85          $55,080.00

          CARDINAL MILLS

                                3586T14Y    11/20/85             $358.56



         BIN TOTAL                                            $55,438.56 *





      3   ACME WIDGET

                                6650D22S    12/03/85          $75,716.62

          H & S SURPLUS

                                6650D22S    12/14/85             $187.85

                                6650D22S    12/15/85             $153.45



         BIN TOTAL                                            $75,057.92 *







         TOTAL INVENTORY                                 $553,248,578.85  **

REPORT - HEADER STATEMENTS

Header statements are used to print report titles and column headings at the top of each report page.

Syntax

   Hheader number,print element,print position[,SPACE A[number] ]  [,SPACE B[number] ]

   [,E{number

       Z}]

For example:

   H2,F-NAME,20,SPACE A5

Where header number = 2, print element = F-NAME, print position = 20, and number of spaces = 5

Parameters

header number

is an integer from 1 to 9. Up to nine lines of header information can be printed in addition to blank lines created by spacing before and after non-blank lines. Header information with the same header number is printed on the same line. The lowest-numbered header statement is printed first, the next-highest numbered statement is printed next. Header statements do not have to be consecutively numbered.

print element

(1) is the name of a simple item or a compound item with an optional subscript parameter. The value of the specified data item is printed. The data item can be qualified with the data base and data set to which it belongs. The form is:

   [data base name:]  [ data set name.

                        dummy data set name.]  data item name

   [(subscript)]

dummy data set name is a temporary data set name used in multiple data set access (refer to the JOIN command).

subscript is a number to indicate which sub-item you want to access. subscript is entered with parenthesis and must be an integer > 1 and <= the number of sub-items defined for the compound item. QUERY will default to the first sub-item if no subscript is specified.

(2) is characters enclosed in quotation marks. The characters are stripped of the surrounding quotation marks and printed.

(3) is PAGENO, DATE, or TIME.

PAGENO

consecutively numbers each page of the report.

DATE

prints the date in the form: MMDDYY. The form of the date varies depending on the language.

TIME

prints the time in the form: HH:MM:SS.

Refer to Table 3-6 “REPORT Statement Parameters” at the beginning of the REPORT command for descriptions of the other parameters.

Discussion

A header can contain up to 9 lines of information and any number of blank lines as long as it does not exceed the page size as defined by the output control statement LINES=. (Refer to the description at the beginning of this section.) A report consisting of only header statements will not generate any output.

Negative data item values of type P, Z, I, J, and K are output with a special character in the rightmost position, unless you use the NOPUNCH output control statement. This type of output is called overpunch. Refer to the REPORT ALL command for more information on overpunch.

   >F ALL INVENTORY.STOCK#

   USING SERIAL READ

   13  ENTRIES QUALIFIED

   >REPORT

   >>H1,"AS OF:",6

   >>H1,DATE,15

   >>H1,PAGENO,71 

   >>H1,"PAGE",69 

   >>H2,"BOBO'S MERCANTILE",45 

   >>H3,"ON HAND INVENTORY",45,SPACE A2 

   >>H7,"BIN#",4 

   >>H7,"SUPPLIER",14 

   >>H7,"STOCK",33 

   >>H7,"SHIP DATE",49 

   >>H7,"INVENTORY",68 

   >>H8,"AMOUNT",68 

          .

          .

          .

In the example above, entries are located first. Then report statements are entered describing the report headings. Characters in quotation marks are printed as they appear in the statement. DATE and PAGENO are generated and printed by QUERY. The following is an example of the specified report. The column and heading markers, in the example below, do not appear in an actual report.



             Col.    Col.         Col.        Col.   Col.          Cols.

              6       15           33          45     49           68 71

              |        |            |           |      |            |  |

              v        v            v           v      v            v  v

   H1--> AS OF: 01/07/86                                          PAGE 1

   H2-->                        BOBO'S MERCANTILE

   H3-->                        ON HAND INVENTORY





   H7-->BIN#  SUPPLIER          STOCK      SHIP DATE          INVENTORY

   H8-->                                                         AMOUNT

REPORT - DETAIL STATEMENTS

Detail statements usually specify a data item name whose value changes with each data entry reported, although a fixed series of characters can be specified as well. The statement specifies the print position, top-of-form, line spacing, and applicable edit masks.

Syntax

   D[detail number],print element,print position[,SPACE A[number] ]  [,SPACE B[number] ]

   [,SKIP {A

           B}]  [,E {number

                     Z}]

For example:

   D2,BADGE#,35,SKIP B,E8

Where detail number = 2, print element = BADGE#, print position = 35, and edit number = 8

   D,R3,15,SPACE A2 

Where print element = R3, print position = 15, number of spaces = 2

Parameters

detail number

is an integer from 1 to 99. If the number is omitted, the print element is printed on a group line when any control break occurs. (Refer to the discussion of both group and sort statements.) The lowest numbered statement is printed first and others follow in numeric sequence. Detail statements with the same number are printed on the same line. Information from a single data entry can therefore be printed on up to one hundred separate lines.

print element

(1) is a simple data item name or a compound data item name with an optional subscript parameter. When a data item is specified, its value is printed for each entry reported. A data item can be qualified with the data base and data set to which it belongs. The form is:

   [data base name:] [ data set name.

                      dummy data set name.]   data item name

   [(subscript)]

dummy data set name is a temporary data set name used in multiple data set access. (Refer to the JOIN command).

subscript is a number that indicates which sub-item you want to access. Subscript must be an integer >= 1 and <= the number of sub-items defined for the compound item. QUERY will default to the first sub-item if no subscript is specified.

(2) is the contents of a register (Rn). If a register is specified, the data in the register is printed. You must enter both the letter and the number. Refer to REPORT Register Statement for more information.

(3) is a series of characters enclosed in quotation marks.

The characters are printed without the surrounding quotation marks, and are printed once for each entry reported.

Refer to Table 3-6 “REPORT Statement Parameters” at the beginning of the REPORT command for descriptions of the other parameters.

Discussion

Negative data item values of type P, Z, I, J, and K are output with a special character in the rightmost position, unless you use the NOPUNCH output control statement. This type of output is called overpunch. Refer to the REPORT ALL command for more information on overpunch.

   >REPORT

   >>H1,"AS OF:",6

   >>H1,DATE,15

   >>H1,PAGENO,71

   >>H1,"PAGE",69

   >>H2,"BOBO'S MERCANTILE",45

   >>H3,"ON HAND INVENTORY",45,SPACE A2

   >>H7,"BIN#",4

   >>H7,"SUPPLIER",14

   >>H7,"STOCK",33

   >>H7,"SHIP DATE",49

   >>H7,"INVENTORY",68

   >>H8,"AMOUNT",68

   >>D1,STOCK#,36

   >>D1,LASTSHIPDATE,48

   >>END

If the same report shown in the header statement example has detail statements added, the result follows. The first detail statement prints the value of STOCK# ending in column 36. The next statement prints LASTSHIPDATE value on the same detail line ending in column 48. Note that detail lines are printed once per entry.

                                        Col.        Col.

                                        36           48

                                         |           |

                                         v           v

       AS OF: 01/07/86                                          PAGE 1

                                  BOBO'S MERCANTILE

                                  ON HAND INVENTORY

   

   

       BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                                     AMOUNT

   D1-->                            6650D22S      120385

   D1-->                            2457A11C      120185

   D1-->                            3586T14Y      112085

      .                             7391Z22F      120185

      .                             5405T14F      112885

      .                             7391Z22F       81385

      .                             5405T14F       91185

      .                             4397D13P       30285

      .                             3739A14F      121585

      .                             6650D22S      120585

      .                             6650D22S      121485

   D1-->                            6650D22S      121585

REPORT - EDIT STATEMENTS

The edit statement is used for formatting data item values printed in a report. The statement performs such functions as suppressing leading zeros in numeric values, inserting characters such as dollar signs, dashes, commas, and decimal points. It also masks characters to eliminate them from the printed output. Edit statements can appear anywhere in the report.

Syntax

   Enumber,"edit mask"

For example:

   E3,"$$$999CR" 

Where number = 3, and edit mask = "$$$999CR"

Parameters

number

is an integer from 0 to 9 identifying the edit statement. A report can have at most ten edit statements, each with a unique number.

"edit mask"

consists of from 1 to 20 characters (if the mask is to edit numeric data item values) or from 1 to the maximum length of the data item, not to exceed the maximum record length of the output device (if the mask is to edit alphanumeric data item values.) In either case, the characters must be surrounded by quotation marks. The length of the edit mask determines the length of the output field that is printed.

Alphanumeric Edit Masks

Alphanumeric edit masks consist of X's (used as place holders) and any other ASCII alphanumeric printing characters (used as insertion characters). QUERY examines the data item value specified in the detail, group, or total statement and the edit mask specified in the referenced edit statement, starting with the leftmost character of each.

If the character in the edit mask is X, a character from the data item value is printed in the corresponding position of the output field. If the character in the edit mask is any character other than an X, the edit mask character is printed in the corresponding position of the output field. For example, if the value ABCD is edited with the mask "X-X-X-X", the result is printed as A-B-C-D.

If there are fewer X's in the edit mask than there are in the data item value, the rightmost characters of the data item value that do not correspond to an X in the mask are omitted. For example, if the value ABCD is edited with the mask "XX", the result is printed as AB.

If there are more X's in the edit mask than there are characters in the data item value, QUERY prints asterisks in place of the unused X's in the edit mask. All insertion characters in the mask are printed in the output field. For example, if the value ABCD is edited with the mask "XXXX-X", the result is printed as ABCD-*.

Here are two more examples of alphanumeric edit masks:

DATA ITEM VALUEEDIT MASKPRINTED RESULT
A34B"X//X-X-X-X"A//3-4-B-*
ABCD"- - - X" - - - A

Numeric Edit Masks

A numeric edit mask consists of the placement holders (9,Z,*,$), the sign characters (CR,-), and any other numeric ASCII printing characters used as insertion characters. Each of the place holders and sign characters serves a special purpose in editing data item values. Characters and their usage are specified in Table 3-7 “Numeric Edit Mask Characters”.

The numeric edit mask edits decimal integer values consisting of up to 20 characters (not counting the sign characters) in the combinations outlined in Table 3-8 “Numeric Edit Mask Combinations”.

If the number of significant digits of the data item value is greater than the number of place holders (9,Z,*,$) in the edit mask, the output field is filled with asterisks. For example, if the value 12345 is edited with the mask "999CR" the result is *****.

Only one decimal point can appear in any edit mask.

If a minus sign appears in the edit mask in any position other than the rightmost character of the mask, the minus is treated as an insertion character. For example, if the value 12345 is edited with the mask 999-99, the result is 123-45.

Figure 3-9 “Sample Output Using Numeric Edit Masks” shows the results of printing numeric data item values using numeric edit masks.

Table 3-7 Numeric Edit Mask Characters

CHARACTEREXPLANATION
9Each 9 in the edit mask is replaced with a decimal digit from the data item value in the corresponding position of the output field.
ZZ is a zero suppression place holder. A Z in the edit mask is replaced with a decimal digit from the data item value in the corresponding position of the output field. If the data item value digit under consideration is a zero appearing to the left of the leftmost significant digit, QUERY inserts a blank in the output field, and all other zeros to the left of the significant digit are replaced by a blank in the output field.
** is an asterisk place holder. An * in the edit mask acts just like a Z with the exception that leading zeros in the data item value are replaced with asterisks in the output field.
$$ is the dollar sign place holder. A $ in the edit mask acts just like a Z, except that the first zero in the data item value to the left of the leftmost significant digit is replaced with the dollar sign in the output field. All zeros to the left of the first leading zero are replaced with blanks in the output field.
CRCR is a sign character, and always appears in the two rightmost positions of the edit mask. If the data item value is negative, QUERY prints the two characters (CR) in the first two rightmost positions of the output field. If the data item value is positive, QUERY prints two blank characters in place of the CR. No characters from the data item value are ever placed in the first two rightmost positions of the output field.
-- is a sign character and acts the same as the CR characters. If the data item value is negative, QUERY prints the minus sign (-) in the rightmost position of the output field. If the data item value is positive, QUERY prints a blank in place of the minus. No character from the data item value is ever placed in the rightmost position of the output field.
Insertion characters Insertion characters consist of any ASCII printing characters not previously mentioned. Insertion characters are printed in the output field in the same position they appear in the edit mask. Any insertion character appearing in the edit mask to the left of the leftmost significant digit of the data item value is replaced with blanks or an asterisk, depending upon which zero suppression character is specified in the edit mask. Only one decimal point can appear in an edit mask.

 

Table 3-8 Numeric Edit Mask Combinations

COMBINATIONSEXAMPLE
9's only
"99"

"999999"

"9999"
Z's only
"ZZ"

"ZZZZZZZZZZ"
Asterisks only
"****"

"**********"
Dollar signs only
"$$$$"

"$$$$$$$$$$$$$$"
Sign characters preceded by 9's
"9999CR"

"999999-"
Sign characters preceded by 9's which are preceded by Z's, asterisks, or dollar signs
"ZZ99999-"

"******9999999CR"

"$$$999CR"
9's preceded by Z's, asterisks, or dollar signs
"ZZZZ9999"

"***99999999"

"$$$999999"
Any of the above combinations including insertion characters such as commas, one decimal point, slashes, etc. located anywhere in the edit mask, except to the right of sign characters.
"$$999,999.99-"

"999-9999"

"99/99/99"

"$$9999.99CR"

 

Figure 3-9 Sample Output Using Numeric Edit Masks



      DATA ITEM VALUE         EDIT MASK              PRINTED RESULT





         0059               "$$$,999"          $059

         001024             "ZZZ,ZZZ"                1,024

         -0010555           "$$,$$$.99CR"            $105.55CR

         00010555           "$$,$$$.99CR"            $105.55

         -0010555           "$$,$$$.99-"             $105.55-

         15039250           "$,$$$,$$$.99CR"         $150,392.50

         00049              "*****"                  ***49

         044240474          "999-99-9999"                  044-24-0474

         -2145              "$,$$$.99"         $21.45

Real Numbers

Real values can be printed in either fixed-point (xx.xxx) or floating-point (xx.xxxExx) form. The default is that R2 values less than .1 or greater than 10 to the sixth (106) and R4 values less than .1 or greater than 10 to the sixteenth (1016) are printed in floating point (scientific notation). All other R2 and R4 values are printed in fixed-point notation. To override the default and specify that fixed point form always be used for real number values, you can use edit masks.

These edit masks work the same way as for other data types except that the placement of the decimal point determines where the number will be placed in the field. Note that fixed R2 values occupy up to eight characters and floating-point R2 values occupy up to 12 characters. R4 values occupy up to 18 and 22 characters for fixed and floating-point respectively.

REAL VALUETYPEDEFAULT REPORT OUTPUT
   0

   8399607

   123456

   .0034567
   R2

   R2

   R2

   R2
   0.00000

   .839961E+07

   123456.

   .345670E-02

REAL VALUETYPEEDIT MASKREPORT OUTPUT WITH EDIT MASK
   0

   8399607

   123456

   .0034567
   R2

   R2

   R2

   R2
   "ZZZZZ9"

   "ZZZZZZ"

   "999999"

   ".9999999"
   0

   839610[2]

   123456

   .0034567
[2]

[2] * Rounding difference: For this number to come out as 8399607 it must be R4 precision.

Example



      >REPORT

      >>H1,"AS OF:",6

      >>H1,DATE,15

      >>H1,PAGENO,71

      >>H1,"PAGE",69

      >>H2,"BOBO'S MERCANTILE",45

      >>H3,"ON HAND INVENTORY",45,SPACE A2

      >>H7,"BIN#",4

      >>H7,"SUPPLIER",14

      >>H7,"STOCK",33

      >>H7,"SHIP DATE",49

      >>H7,"INVENTORY",68

      >>H8,"AMOUNT",68

      >>D1,STOCK#,36

      >>D1,LASTSHIPDATE,48,E2

      >><user|E2,"XX/XX/XX"

      >>END''

In the example above, LASTSHIPDATE is altered with edit mask E2. Edit mask E2 is defined as "XX/XX/XX". Now the report looks like this:

    AS OF: 01/07/86                                                  PAGE 1

                                BOBO'S MERCANTILE

                                ON HAND INVENTORY





    BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                                  AMOUNT

                                6650D22S    12/03/85

                                2457A11C    12/01/85

                                3586T14Y    11/20/85

                                7391Z22F    12/01/85

                                5405T14F    11/28/85

                                7391Z22F     8/13/85

                                5405T14F     9/11/85

                                4397D13P     3/02/85

                                3739A14F    12/15/85

                                6650D22S    12/05/85

                                6650D22S    12/14/85

                                6650D22S    12/15/85

REPORT - SORT STATEMENTS

The sort statement specifies data items whose values are used to sort data entries when they are printed in the report. It also defines control break levels for use by group and total statements in the report.

Syntax

   S[level],data item name [,{ASC

                              DES}]

For example:

S3,BADGE#,ASC

Where level = 3 and data item name = BADGE#

S,L-NAME

Where data item name = L-NAME

Parameters

level

is an integer from 1 to 10. A sort statement with level greater than 1 must be accompanied by sort statements containing all lower level numbers. That is, if S3 appears in the report, S2 and S1 must also appear in it. You need not specify a level. In this case, the sort statement sorts but does not define a control break.

data item name

is the name of a simple data item or a compound data item with an optional subscript parameter, that is contained in data entries selected by the last retrieval command. If you used a FIND CHAIN to retrieve entries, use a master data item in the sort statement. It can also be qualified with the data base and data set to which it belongs. The form is:

   [data base name:]  [data set name.

                       dummy data set name]  data item name



   [(subscript)]

dummy data set name is a temporary data set name used in multiple data set access. (Refer to the JOIN command).

subscript is a number that indicates which sub-item you want to access. Subscript is entered in parenthesis and must be an integer >= 1, and <= the number of sub-items defined for the compound item. QUERY will default to the first sub-item if no subscript is specified.

ASC

indicates that the data item values are to be ordered in ascending order. If you do not specify ASC or DES, the default order is ASC.

DES

indicates that the data item values are to be ordered in descending order.

The following sort statement sorts the entries into the order specified by the value of L-NAME.

   S1,L-NAME



   DATA ENTRIES AFTER FIND



        L-NAME    F-NAME     AGE



         WHITE     ROB       26

         BROWN     JACK      32

         GREEN     ROB       49

         WHITE     LARRY     81

         BROWN     CHRIS     17

         GREEN     SAM       28

         GREEN     BILL      45

         BROWN     DAN       39

         WHITE     WILL      22



   DATA ENTRIES AFTER SORT EXECUTED

        L-NAME    F-NAME    AGE



         BROWN     JACK      32

         BROWN     CHRIS     17

         BROWN     DAN       39

         GREEN     ROB       49

         GREEN     SAM       28

         GREEN     BILL      45

         WHITE     ROB       26

         WHITE     LARRY     81

         WHITE     WILL      22

The higher-numbered sort statement identifies the major (or first) sort field, while the lower-numbered sort statement identifies the minor sort field. The minor sort arranges entries in the order specified, keeping all major sort items with identical values together, in other words, it sorts within subsets of the entire set of entries.

         S1,F-NAME

         S2,L-NAME

If the statements above appear in a report, the result would be as follows.

                           L-NAME                          F-NAME   AGE



   level 2 (major)-->  BROWN       level 1 (minor)-->  CHRIS    17

   Control break       BROWN       control breaks      DAN      39

                       BROWN                               JACK     32

   level 2 (major)-->  GREEN                               BILL     45

   control break       GREEN                               ROB      49

                       GREEN                               SAM      28

   level 2 (major)-->  WHITE                               LARRY    81

   control break       WHITE                               ROB      26

                       WHITE                               WILL     22

Control Breaks

A control break occurs during the printing of a report whenever the value of a current entry for a data item defined in a numbered sort statement is different from the value of the last entry. When the first entry is printed, a control break occurs since the data item value changes from null (no value) to the first value. Totals are not printed when the first control break occurs.

In the previous examples, a control break occurs when the value of L-NAME becomes BROWN, when it changes to GREEN, and again when it changes to WHITE. This is known as a level 2 control break because the data item named L-NAME appears in a sort statement labeled S2. The level 1 control break is associated with the data item named F-NAME and sort statement labeled S1.

A control break occurs for all lower levels whenever a higher level control break occurs. For example, when a control break occurs for level 2 (L-NAME), a control break also occurs for level 1 (F-NAME).

A group or total statement prints only when a control break occurs that is at the same level as the group or total statement. This means that a total statement labeled T1 prints only when a level 1 control break occurs, or a group statement labeled G2 prints only when a level 2 control break occurs. Consult the descriptions of group and total statements later in this section for an explanation of their functions.

Sort statements with no level (i.e., no number) are used to sort entries but do not define control breaks for use by group or total statements.

Major to Minor Sort Fields

Numbered and unnumbered sort statements can appear in the same REPORT command. The order in which unnumbered sort statements appear in the report body is significant. The first unnumbered statement defines the most minor sort field, while the last unnumbered statement defines the most major sort field. QUERY defines sort fields in the following order from most major to most minor:

   MOST MAJOR -----------------------------------------------------> MOST MINOR



   S10 ---> S1 ---> S(last in report body) ---> S(first in report body)
       STATEMENTS                  ORDER



       S2,OFFICE        MONTH      (S3)              MAJOR

       S,PARTNO         OFFICE     (S2)                |

       S1,SLSMAN        SLSMAN     (S1)                |

       S,QUANTITY       QUANTITY   (S last)            v

       S3,MONTH         PARTNO     (S first)         MINOR


Maximum Number of Sort Items

The number of data items you can use to sort is limited in two ways. The maximum number of sort statements allowed in a single report is 66. You can have up to 66 sort statements provided that the combined length of the data items in all of the 66 statements is not greater than 2045 words.

Example

      >REPORT

      >>H1,"AS OF:",6

      >>H1,DATE,15

      >>H1,PAGENO,71

      >>H1,"PAGE",69

      >>H2,"BOBO'S MERCANTILE",45

      >>H3,"ON HAND INVENTORY",45,SPACE A2

      >>H7,"BIN#",4

      >>H7,"SUPPLIER",14

      >>H7,"STOCK",33

      >>H7,"SHIP DATE",49

      >>H8,"AMOUNT",68

      >>D1,STOCK#,36

      >>D1,LASTSHIPDATE,48,E2

      >>E2,"XX/XX/XX"

      >>S2,BINNUM

      >>S1,SUPPLIER

      >>S,LASTSHIPDATE

      >>END

In the example above, BINNUM is defined as a sort level 2, SUPPLIER as sort level 1, and LASTSHIPDATE as a sort without a control break. As shown in the new report, the detail entries are now sorted by BINNUM, SUPPLIER, and LASTSHIPDATE. The values for BINNUM and SUPPLIER will be printed in group statements which are described next.

       AS OF: 01/07/86                                                  PAGE 1

                                   BOBO'S MERCANTILE

                                   ON HAND INVENTORY





       BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                                     AMOUNT

                                   7391Z22F     8/13/85

                                   5405T14F     9/11/85

                                   6650D22S    12/05/85

                                   2457A11C    12/01/85

                                   7391Z22F    12/01/85

                                   5405T14F    11/28/85

                                   3739A14F    12/15/85

                                   4397D13P     3/02/85

                                   3586T14Y    11/20/85

                                   6650D22S    12/03/85

                                   6650D22S    12/14/85

                                   6650D22S    12/15/85

REPORT - GROUP STATEMENTS

A group statement prints the value of a data item, the value in a register (Rn), or a series of characters whenever a control break occurs.

Syntax

   Glevel,print element,print position [,SPACE A[number] ] [,SPACE B[number] ]



   [,SKIP {A}] [,E{number

                   Z}]

For example:

   G3,WEEK,35,SKIP B,E2

Where level = 3, print element = WEEK, print position = 35, and edit number = 2

   G1,R3,55,SPACE B2

Where level = 1, print element = R3, print position = 55, and number of spaces = 2

Parameters

level

is an integer from 1 to 10 corresponding to the level of a sort statement.

print element

(1) is the name of a simple data item or a compound data item with an optional (subscript) parameter. Data items can be qualified with the data base and data set to which they belong. The form is:

   [data base name:] [data set name

                      dummy data set name] data item name



   [(subscript)]

dummy data set name is a temporary data set name used in multiple data set access. (Refer to JOIN command.)

subscript is a number indicating which sub-item to access. Subscript is entered in parenthesis and must be an integer > 1 and <= the number of sub-items defined for the compound item. QUERY will default to the first sub-item if no subscript is specified.

(2) is the contents of a register (Rn).

(3) is a series of characters enclosed in quotation marks. You must specify the quotation marks, but QUERY will strip them when it prints the characters.

Refer to Table 3-6 “REPORT Statement Parameters” at the beginning of the REPORT command for descriptions of the other parameters.

Discussion

Each control break occurs as a result of a sort statement labeled from 1 to 10. When the control break occurs, the group statement with the same number as the sort statement prints the information you specify. (Refer to "Control Breaks" under REPORT Sort Statements for more information.) Whenever a control break occurs, all group statements with a number equal to or less than the level of the sort statement causing the break will print a value and/or series of characters. All group statements print on the same line. Since a control break always occurs at the very beginning of the report, all group statements print their contents before any detail statements are executed.

If the REPORT command contains group statements but no sort statements, an error message is printed.

Negative data item values of type P, Z, I, J, and K are output with a special character in the rightmost position, unless you use the NOPUNCH output control statement. This type of output is called overpunch. Refer to the REPORT ALL command for more information on overpunch.

   >REPORT

   >>H1,"AS OF:",6

   >>H1,DATE,15

   >>H1,PAGENO,71

   >>H1,"PAGE",69

   >>H2,"BOBO'S MERCANTILE",45

   >>H3,"ON HAND INVENTORY",45,SPACE A2

   >>H7,"BIN#",4

   >>H7,"SUPPLIER",14

   >>H7,"STOCK",33

   >>H7,"SHIP DATE",49

   >>H7,"INVENTORY",68

   >>H8,"AMOUNT",68

   >>D1,STOCK#,36

   >>D1,LASTSHIPDATE,48

   >>E2,"XX/XX/XX"

   >>S2,BINNUM

   >>S1,SUPPLIER

   >>S,LASTSHIPDATE

   >>G2,BINNUM,3,SPACE B

   >>G1,SUPPLIER,20

   >>END

In this example, BINNUM will be printed when a control break occurs for sort level 2, and SUPPLIER when a sort level 1 control break occurs.

In the report below, notice that the two items mentioned in the detail statements do not print on the same line as the group statements. This is because the detail statements are numbered. Unnumbered detail statements print on the same line as a group statement whenever a control break occurs.

    AS OF: 01/07/86                                                    PAGE 1

                                BOBO'S MERCANTILE

                                ON HAND INVENTORY





    BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                                  AMOUNT



      0   H & S SURPLUS

                                7391Z22F     8/13/85

                                5405T14F     9/11/85

                                6650D22S    12/05/85



      1   ACME WIDGET       <-------- level 1 and level 2 control break

                                2457A11C    12/01/85

          BAY PAPER CO.          <--------- level 1 control break

                                7391Z22F    12/01/85

          CARDINAL MILLS         <--------- level 1 control break

                                5405T14F    11/28/85

          JAKE'S JUNK            <--------- level 1 control break

                                3739A14F    12/15/85



      2   ACME WIDGET       <------- level 1 and level 2 control break

                                4397D13P     3/02/85

          CARDINAL MILLS

                                3586T14Y    11/20/85



      3   ACME WIDGET

                                6650D22S    12/03/85

          H & S SURPLUS

                                6650D22S    12/14/85

                                6650D22S    12/15/85

REPORT - TOTAL STATEMENTS

The total statement prints a data item value, the value in a register (Rn), a series of characters, or the total, average, or count of a group of data items whenever a control break occurs.

Syntax

   Tlevel,print element,print position [,SPACE A[number] ]  [,SPACE B[number] ]



   [,SKIP{A

          B}] [,E{number

                  Z}] [{,ADD

                        ,AVERAGE

                        ,COUNT} [,NOREPEAT] ]

Or the special form:

   Tlevel, Rn

For example:

   T4,WAGES,60,SKIP A,E2,ADD

Where level = 4, print element = WAGES, print position = 60, and edit number = 2

   T1,"TOTAL WAGES=",40,SPACE B5 

Where level = 1, print element = "TOTAL WAGES=", print position = 40, and number of spaces = 5

   T3,R2

Where level = 3 and n = 2

Parameters

level

is the letter F or an integer from 1 to 10 corresponding to the level of a sort statement. The letter F indicates the information is to be printed only at the end of the report after the last detail line and it relates to the entire report, not just a subgroup.

print element

(1) is the name of a simple data item or a compound data item with an optional subscript parameter. Data items can be qualified with the data base and data set which they belong. The form is:

   [data base name:] [data set name.

                      dummy data set name.] data item name



   [(subscript)]

dummy data set name is a temporary data set name used in multiple data set access (Refer to the JOIN command).

subscript is a number indicating which sub-item to access. Subscript is entered in parenthesis and must be an integer >= 1, and <= the number of sub-items defined for the compound item. QUERY will default to the compound item. QUERY will default to the first sub-item if no subscript is specified.

(2) is the contents of a register (Rn).

(3) is a number enclosed in quotation marks (a numeric literal). You must specify the quotation marks, but QUERY will strip them when it prints the characters.

ADD

prints the control group total of the values for the data item specified as print element. The print element must be the name of a numeric type data item.

AVERAGE

prints the control group average value for the data item specified as the print element. The print element must be the name of a numeric type data item.

COUNT

prints a count of the number of values for that control group. The print element must be the name of a data item.

NOREPEAT

can only be used if the REPORT command follows a MULTIFIND command. The NOREPEAT option allows the total statement to be executed for a compound entry only if the simple entry has not been previously encountered in the statement. By default, the total statement is executed for all compound entries. The number of registers which use the NOREPEAT option, plus the number of sort levels for which the TOTAL statement uses NOREPEAT, must be less than or equal to 10. Refer to the JOIN command for information about compound data sets. A more detailed explanation of this option appears later in this section.

Rn

is the register to be cleared.

Refer to Table 3-6 “REPORT Statement Parameters” at the beginning of the REPORT command for descriptions of the other parameters.

Discussion

If the total statement is labeled TF, the ADD, AVERAGE, and COUNT options apply to all occurrences of the data item in the report.

Negative data item values of type P, Z, I, J, and K are output with a special character in the rightmost position, unless you use the NOPUNCH output control statement. This type of output is called overpunch. Refer to the REPORT ALL command for more information on overpunch.

If you use the special form of the command, specifying only a register without a print element, the register is cleared (reset to zero) when a control break occurs.

A control break results from a sort statement labeled from 1 to 10. When a control break occurs, the total statement corresponding to the sort level causing the break prints the information you specify. Total statements not labeled TF require corresponding sort statements. (Refer to the description of the sort statement for more information on control breaks.)

To perform more than one operation (total, average,count) on the same data item, you must specify a total statement for each operation. The information is printed on the same line if you use the same level for each statement. No more than five (5) data items can be used as print elements in total statements.

   >REPORT

   >>H1,"AS OF:",6

   >>H1,DATE,15

   >>H1,PAGENO,71

   >>H1,"PAGE",69

   >>H2,"BOBO'S MERCANTILE",45

   >>H3,"ON HAND INVENTORY",45,SPACE A2

   >>H7,"BIN#",4

   >>H7,"SUPPLIER",14

   >>H7,"STOCK",33

   >>H7,"SHIP DATE",49

   >>H7,"INVENTORY",68

   >>H8,"AMOUNT",68

   >>D1,STOCK#,36

   >>D1,LASTSHIPDATE,48

   >>E2,"XX/XX/XX"

   >>S2,BINNUM

   >>S1,SUPPLIER

   >>S,LASTSHIPDATE

   >>G2,BINNUM,3,SPACE B

   >>G1,SUPPLIER,20

   >>T2," *",70

   >>T2,"BIN TOTAL",14,SPACE B,SPACE A

   >>TF,"TOTAL INVENTORY",20,SPACE B3

   >>TF," **",71

   >>END

The total statements which have been added merely print character literals. The totals are computed with register statements which are described next. More total statements are added to the example in REPORT Register Statements.

In this example, the first total statement prints an asterisk in column 70 and the next one prints a character literal when a level 2 control break occurs. When the final totals are printed, the last two total statements print the specified characters. The resulting report appears as follows.

   

    AS OF: 01/07/86                                                 PAGE 1

                                BOBO'S MERCANTILE

                                ON HAND INVENTORY





    BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                                  AMOUNT



      0   H & S SURPLUS

                                7391Z22F     8/13/85

                                5405T14F     9/11/85

                                6650D22S    12/05/85



         BIN TOTAL         <------ level 2 control break  *





      1   ACME WIDGET

                                2457A11C    12/01/85

          BAY PAPER CO.

                                7391Z22F    12/01/85

          CARDINAL MILLS

                                5405T14F    11/28/85

          JAKE'S JUNK

                                3739A14F    12/15/85



         BIN TOTAL                                            *





      2   ACME WIDGET

                                4397D13P     3/02/85

          CARDINAL MILLS

                                3586T14Y    11/20/85



         BIN TOTAL                                            *





      3   ACME WIDGET

                                6650D22S    12/03/85

          H & S SURPLUS

                                6650D22S    12/14/85

                                6650D22S    12/15/85



         BIN TOTAL                                            *







         TOTAL INVENTORY                                      **

The NOREPEAT Option

The NOREPEAT option is only applicable on compound data sets created by a MULTIFIND command. In a compound data set, a particular value can occur more than once. This is because each value of the data item on the left side of the TO (of the JOIN command) is being paired with each occurrence of that value of the data item on the right side of the TO.

If the JOIN and MULTIFIND commands are as follows, each STOCK# value in STOCK-DETAIL will be paired with each occurrence of that same STOCK# value in SALES-DETAIL.

      >JOIN STOCK-DETAIL.STOCK# TO SALES-DETAIL.STOCK#

      >MU ALL

For example, given the following values in the data sets STOCK-DETAIL and SALES-DETAIL:

   

               STOCK-DETAIL                         SALES-DETAIL

      ------------------------------      ------------------------------

        STOCK#    DESCR    ON-HAND          ACCT#      STOCK#     QUAN

      ------------------------------      ------------------------------

         110        NUT      970            666          90       350

          60       BOLT     1200            222          60        25

          50       NAIL     1000            999          60       500

          50       NAIL      900            555          60        75

      ------------------------------        333          50        45

                                            111          50       100

                                          ------------------------------


the following compound data set entries are created:

   

      <------ (STOCK-DETAIL) --------><------- (SALES-DETAIL) -------->

      ------------------------------------------------------------------

        STOCK#    DESCR    ON-HAND          ACCT#      STOCK#     QUAN

      ------------------------------------------------------------------

          60       BOLT     1200            222          60        25

          60       BOLT     1200            999          60       500

          60       BOLT     1200            555          60        75

          50       NAIL     1000            333          50        45

          50       NAIL     1000            111          50       100

          50       NAIL      900            333          50        45

          50       NAIL      900            111          50       100

      ------------------------------------------------------------------

The one occurrence of STOCK# 60 in STOCK-DETAIL is paired with each occurrence of STOCK# 60 in SALES-DETAIL resulting in 3 entries in the compound data set. You can see by the ACCT# that each of these entries is separate and unique.

Now suppose you wanted to produce a report from this retrieval in which you wanted to count the number of STOCK# in the entries retrieved. The report might look like:

      >REPORT

      >>H1,"DIFFERENT STOCK# COUNT:",30

      >>TF,STOCK-DETAIL.STOCK#,50,COUNT

      >>END

This report would produce the following:

   DIFFERENT STOCK# COUNT: 7

This count is incorrect if you wanted a count of the unique STOCK# entries. You need to use the NOREPEAT option on the TF statement. This tells QUERY to count only the first occurrence of each retrieved entry from STOCK-DETAIL. The report and its output are shown below:

      >REPORT

      >>H1,"DIFFERENT STOCK# COUNT:",30

      >>TF,STOCK-DETAIL.STOCK#,50,COUNT,NOREPEAT

      >>END



      DIFFERENT STOCK# COUNT: 3

REPORT - REGISTER STATEMENTS

A register statement specifies an operation to be executed in one of 30 QUERY registers. The register statements are executed sequentially as they appear in the REPORT command, once for each data entry in the report (that is, once for each entry selected by the last retrieval command).

Syntax

   Rnumber, {L[OAD]

             A[DD]

             S[UBTRACT]

             M[ULTIPLY]

             D[IVIDE]} ,data element [,NOREPEAT]

For example:

   R3,ADD,PRICE

Where number = 3 and data element = PRICE

   R0,M,"25"

Where number = 0 and data element = "25"

   R5,DIV,R6

Where number = 5 and data element = R6

Parameters

number

is an integer from 0 to 29 which identifies the register you want to use.

data element

(1) is the name of a simple data item or a compound data item with an optional subscript parameter. Data items may be qualified with the data base and data set which they belong. The form is:

   [data base name:] [data set name.

                      dummy data set name.] data item name



   [(subscript)]

dummy data set name is a temporary data set name used in multiple data set access. (Refer to the JOIN command.)

subscript is a number indicating which sub-item to access. Subscript is entered in parenthesis and must be an integer >= 1, and <= the number of sub-items defined for the compound item. QUERY will default to the first sub-item if no subscript is specified.

(2) is the contents of a register (Rn).

(3) is a number enclosed in quotation marks (a numeric literal). You must specify the quotation marks, but QUERY will strip them and use the number in the operation.

LOAD

replaces the current contents of the register with the data element.

ADD

adds the data element to the contents of the register.

SUBTRACT

subtracts the data element from the contents of the register.

MULTIPLY

multiplies the contents of the register by the data element.

DIVIDE

divides the contents of the register by the data element.

NOREPEAT

can only be used if the REPORT command follows a MULTIFIND command. When NOREPEAT is used, the data element must be a data item name. The NOREPEAT option allows the total statement to be executed for a compound entry only if the simple entry has not been previously encountered in the statement. By default, the register statement is executed for all compound entries. The number of registers which use the NOREPEAT option, plus the number of sort levels for which the TOTAL statement uses NOREPEAT, must be less than or equal to 10. Refer to the JOIN command for information about compound data sets. For a more detailed explanation of this option refer to the section on REPORT Total Statements.

Discussion

After each operation is executed, the result is placed in the register specified at the beginning of the statement. For example, assume R2 contains 3 and R4 contains 2. After the statement below is executed:

   R2,MULTIPLY,R4

R2 will contain 6.

Using QUERY Registers

The register statements in a REPORT command describe a fixed sequence of operations to be performed each time a new data entry is processed for the report. If you are familiar with programming techniques, you can consider the Rn statements as a program "loop" which is executed once for each entry in the report.

Rn statement execution affects only the 30 QUERY registers. No output results from the statements, although you can print the content of any register by using other REPORT command statements (with the exception of sort and header statements).

All register operations except LOAD are cumulative. When each Rn statement is executed, the current contents of the register are operated on by the data element and the result is stored in the register again.

Initializing Registers

Each register is initialized to zero when the REPORT command begins execution. You can reset the register to zero in three ways:

  1. Load a zero into the register. For example:

       R3,L,"0"
  2. Use a total statement to reset the register to zero when a control break occurs. For example, the following statement sets Register 3 to zero when a control break occurs as a result of sort level 2.

       T2,R3
  3. Use an arithmetic operation that results in zero. For example:

       R4,SUBTRACT,QUANTITY  (where QUANTITY is equal to the contents of R4)

If you divide the contents of a register by zero, the result is zero. Results of integer division are truncated.

Register and Data Types

Only numeric type data can be used in register operations. The following IMAGE data item types are allowed:

  • whole numbers or integers (I1,I2,I4,J1,J2,J4,K1,K2,Zn, and Pn)

  • real numbers (R2)

  • extended precision real numbers (R4).

The maximum length of P and Z data types that a register statement can handle is 20.

You can mix data types in a register operation. For example, you can add an integer to a real number. QUERY determines the data type of the register content by assigning an order of precedence to the data types, as follows:

HIGHEST R4 (Extended precision type data) R2 (Real type data) LOWEST I1,I2,I4,J1,J2,J4,K1,K2,Zn,Pn (Integers and packed decimal numbers)

The new register content always has a data type which is the higher of the two operand types: the old register content or the data element. For example, if Register 2 is loaded with an integer and then multiplied by a real type data item, the content of R2 will be type real.

   R2,L,"3"
   R2,M,PERCENT     (where the value of PERCENT is 25.6)

All registers start with a default type of packed decimal. When you issue the REPORT command, QUERY cycles through all register statements (before executing the command) and assigns each register the highest type that the register will hold during the report. This ensures the correct typing of a register, in case its type changes during the report. For example:

R1,LOAD,DECITEM Register 1 is type packed decimal R2,LOAD,REALITEM Register 2 is type real (R2) R1,ADD,R2 Register 1 becomes type real (R2)

Because Register 1 is added with Register 2 later in the report, it is typed as real, instead of the initial default of packed decimal. When the first LOAD into Register 1 is performed, DECITEM will be converted into a real and loaded into Register 1. If Register 1 is printed with a detail statement, it will be displayed as a R2 data type.

You can convert a register to type R4 either by loading it (or by performing an arithmetic operation on it) with a data item of type R4. You can also convert a register to R4 by loading it with a real numeric literal that has more than 6 digits. Zeros preceding the decimal point or the most significant digit will be ignored, except in the case of all zeros. For example, all of the following convert Register 1 into an R4 data type:

R1,ADD,"000000.0" (produces 0.0) R1,LOAD,"0.000000" (produces 0.0) R1,MUL,"1.000000" (produces 1.0) R1,ADD,"500.0000" (produces 500.0) R1,LOAD,".0000100" (produces .00001)

The following will not perform the conversion since leading zeros will not affect the output.

R1,LOAD,"000005.0" (produces an R2 data type) R1,LOAD,"000000.5" (produces an R2 data type)

However, the following will perform the conversion.

R1,LOAD,"5.000000" (produces an R4 data type) R1,LOAD,".5000000" (produces an R4 data type)

The largest integer (including all IMAGE integer data types) which a register can contain is 19 digits.

Real and extended precision numbers have the same limits in registers as IMAGE R2 and R4 data items. R2 can have 6 to 7 significant digits and R4 can have 16 to 17 significant digits. If a register calculation results in overflow, a message is printed on the $STDLIST device.

When mixing data types in arithmetic register computations, you should think about the order of precedence and its effect on the calculations. For example, if you operate on a real register number with an integer having 12 significant digits, the result will have 6 to 7 significant digits.

Numeric Literals

To use a constant number in a register operation, you enter the number surrounded by quotation marks (for example, "325", ".0013", "-3E-6"). This type of number is called a numeric literal.

Integer numeric literals can have at most 19 digits. The length of real numeric literals is limited only by the line length (or input record length). Limits for real numeric literal values and significant digits are the R2 limits. Numeric literals can contain the following characters within the quotation marks.

  • the digits 0 through 9 (integer and real)

  • the plus (+) and minus (-) signs (integer and real)

  • the letter E, upper or lower case (real only)

  • the decimal point (real only).

Embedded blanks in numeric literals are not accepted in register statements.



   >REPORT

   >>H1,"AS OF:",6

   >>H1,DATE,15

   >>H1,PAGENO,71

   >>H1,"PAGE",69

   >>H2,"BOBO'S MERCANTILE",45

   >>H3,"ON HAND INVENTORY",45,SPACE A2

   >>H7,"BIN#",4

   >>H7,"SUPPLIER",14

   >>H7,"STOCK",33

   >>H7,"SHIP DATE",49

   >>H7,"INVENTORY",68

   >>H8,"AMOUNT",68

   >>D1,STOCK#,36

   >>D1,LASTSHIPDATE,48

   >>D1,R12,68,E1

   >>E2,"XX/XX/XX"

   >>E1,"$$$,$$$,$$$,$$$.99"

   >>S2,BINNUM

   >>S1,SUPPLIER

   >>S,LASTSHIPDATE

   >>R12,LOAD,ONHANDQTY

   >>R12,MULT,UNIT-COST

   >>R8,ADD,R12

   >>T2,R8,68,E1,SPACE B

   >>G2,BINNUM,3,SPACE B

   >>G1,SUPPLIER,20

   >>T2," *",70

   >>T2,R8

   >>T2,"BIN TOTAL",14,SPACE B,SPACE A

   >>TF,"TOTAL INVENTORY",20,SPACE B3

   >>TF," **",71

   >>TF,R9,68,E1,SKIP A

   >>R9,ADD,R12

   >>END

In the example above, a detail statement is added to print the content of Register 12 and edit with E1. Three register statements are added to load the value of ONHANDQTY into R12, multiply by UNIT-COST, and add the result to the contents of R8.

Three more total statements are added to print the content of Register 8 at each level 2 control break, to clear Register 8, and to print the content of Register 9 on the final total line. The last register statement adds R12 to R9 each time the data of another entry is printed in the report.

In this example, all register statements are executed every time a new entry is processed by the REPORT command.

    AS OF: 01/07/86                                                PAGE 1

                                BOBO'S MERCANTILE

                                ON HAND INVENTORY





    BIN#  SUPPLIER              STOCK       SHIP DATE          INVENTORY

                                                                  AMOUNT

                         ONHANDQTY multiplied by UNIT-COST ------

                                                                |

      0   H & S SURPLUS                                         v

                                7391Z22F     8/13/85           $5,012.50

                                5405T14F     9/11/85          $12,129.60

                                6650D22S    12/17/85          $14,985.00



         BIN TOTAL                                            $32,127.10

                                                                ^

                                 accumulated R12 values in R8   |

                                                  R8 set to 0 ---

      1   ACME WIDGET

                                2457A11C    12/01/85     $553,477,666.95

          BAY PAPER CO.

                                7391Z22F    12/01/85           $4,704.00

          CARDINAL MILLS

                                5405T14F    11/28/85           $1,396.00

          JAKE'S JUNK

                                3739A14F    12/15/85           $1,189.32



         BIN TOTAL                                       $553,485,956.27  *





      2   ACME WIDGET

                                4397D13P     3/02/85          $55,080.00

          CARDINAL MILLS

                                3586T14Y    11/20/85             $358.56



         BIN TOTAL                                            $55,438.56  *





      3   ACME WIDGET

                                6650D22S    12/03/85          $75,716.62

          H & S SURPLUS

                                6650D22S    12/17/85             $187.85

                                6650D22S    12/15/85             $153.45



         BIN TOTAL                                            $76,057.92





         TOTAL INVENTORY     accumulated R12 values--->$553,248,579.85 **

REPORT - OUTPUT CONTROL STATEMENTS

Output control statements can be included in a REPORT command to alter the standard parameters for report output. There are five output control statements.

FORMPURPOSE
LINES=integerSpecifies the number of lines per report page. integer can be between 10 and 32,767. If integer is 0, the page size is infinite.
NOPAGESuppresses page advancing at the beginning of each page (no margins are provided at the top and bottom of each page). All SKIP options are ignored, and all SPACE options are performed unconditionally.
[OUT=]LPSends the report output to the QSLIST device. Applies only to the current report. Refer to the OUTPUT= command for more information on QSLIST.
PAUSECauses the report output to pause after each page completes. Press RETURN to continue. PAUSE adds an extra line as RETURN is pressed. PAUSE is ignored in job mode or if output is sent to QSLIST.
UNIFYDETAILCauses page eject when a particular block of detail statements would split between two pages. A block is all the detail statements for each entry or compound entry.
NOPUNCHcauses negative values of type P, Z, I, J, and K to be printed without the overpunch characters. This statement only affects the output of header, detail, group, and total statements. This statement has no effect when used in the REPORT ALL command. Refer to the REPORT ALL command for a discussion of overpunch characters.

The standard parameters for report output are:

  • 60 lines per page.

  • Page advancing at the beginning of each report page. On the terminal, the page advancing appears as 6 line feeds.

  • Output printed on the $STDLIST device (the terminal in session mode and line printer in job mode).

  • No pauses while the report is being printed.

If you are using the REPORT ALL command, these statements must precede the keyword ALL.

Example

In the following example, entries are located with the FIND command. The REPORT ALL command prints entries without output control statements. The report is terminated with CONTROL Y. When the NOPAGE output control statement is used, QUERY does not skip lines for a top of page margin.

      >F ALL LAST-NAME

      USING SERIAL READ

      13  ENTRIES QUALIFIED

      >REPORT ALL





      ACCOUNT          =54283540

      LAST-NAME        =CORCORAN

      FIRST-NAME       =CLIFFORD

      INIT

      CONTROL Y

      < CONTROL Y >



      >REPORT NOPAGE;ALL

      ACCOUNT          =5428340

      LAST-NAME        =CORCORAN

      FIRST-NAME       =CLIFFORD

      INITIAL          =C

          .                .

          .                .

          .                .

In the example below, QUERY pauses after 10 lines and RETURN must be pressed to continue the listing:

      >REPORT

      >>D1,LAST-NAME,20,SPACE A2

      >>PAUSE

      >>LINES=10

      >>END

In the next example, the UNIFYDETAIL statement causes an entire block of detail lines to be printed together on one page.

      >REPORT

      >>UNIFYDETAIL

      >>D1,ITEM1,5

      >>D2,ITEM2,5

      >>D3,ITEM3,15

      >>S1,ITEM1

      >>G1,"GROUP TITLE",11

      >>END
Feedback to webmaster