REPORT (continued) [ QUERY/V Reference Manual ] MPE/iX 5.0 Documentation
QUERY/V Reference Manual
REPORT (continued)
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
[ {ASC}]
S[level],data item name [,{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 set name. ]
[data base 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.
Discussion
The following sort statement sorts the entries into the order specified
by the value of L-NAME.
S1,L-NAME
-----------------------------------------------------------------------------------------------
| DATA ENTRIES AFTER FIND | DATA ENTRIES AFTER SORT EXECUTED |
-----------------------------------------------------------------------------------------------
| L-NAME F-NAME AGE | L-NAME F-NAME AGE |
| WHITE ROB 26 | BROWN JACK 32 |
| BROWN JACK 32 | BROWN CHRIS 17 |
| GREEN ROB 49 | BROWN DAN 39 |
| WHITE LARRY 81 | GREEN ROB 49 |
| BROWN CHRIS 17 | GREEN SAM 28 |
| GREEN SAM 28 | GREEN BILL 45 |
| GREEN BILL 45 | WHITE ROB 26 |
| BROWN DAN 39 | WHITE LARRY 81 |
| WHITE WILL 22 | 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 |
______________________________________________________________________________
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]
[ {A}] [ {number}]
[,SKIP {B}] [,E{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 set name. ]
[data base 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.
print position /
|
SPACE Anumber |
|
|
|
SPACE Bnumber |
| Refer to Table 3-6 at the beginning of the REPORT command
| for descriptions of these parameters.
|
|
|
{ A} |
SKIP { B} |
|
|
{ number} \
E{ Z }
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.
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,"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 |
_______________________________________________________________________________
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]]
[ {A}] [ {number}] [{,ADD } ]
[,SPACE B[number]] [,SKIP {B}] [,E{Z }] [{,AVERAGE} [,NOREPEAT]]
[{,COUNT } ]
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 set name. ]
[data base 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.
print position /
|
SPACE Anumber |
|
|
|
SPACE Bnumber |
| Refer to Table 3-6 at the beginning of the REPORT command
| for descriptions of these parameters.
|
|
|
{ A} |
SKIP { B} |
|
|
{ number} \
E{ Z }
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.
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.
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,"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
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
{L[OAD] }
{A[DD] }
Rnumber,{S[UBTRACT]} ,data element [,NOREPEAT]
{M[ULTIPLY]}
{D[IVIDE] }
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 set name. ]
[data base 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.
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
>>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 **|
| |
_______________________________________________________________________________
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.
---------------------------------------------------------------------------------------------
| | |
| FORM | PURPOSE |
| | |
---------------------------------------------------------------------------------------------
| | |
| LINES=integer | Specifies the number of lines per report page. integer can |
| | be between 10 and 32,767. If integer is 0, the page size is |
| | infinite. |
| | |
| NOPAGE | Suppresses 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=]LP | Sends the report output to the QSLIST device. Applies only |
| | to the current report. Refer to the OUTPUT= command for more |
| | information on QSLIST. |
| | |
| PAUSE | Causes 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. |
| | |
| UNIFYDETAIL | Causes 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. |
| | |
| NOPUNCH | causes 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
MPE/iX 5.0 Documentation