Parameters [ HP ALLBASE/BRW Reference Manual ] MPE/iX 5.0 Documentation
HP ALLBASE/BRW Reference Manual
Parameters
Parameters are arguments which get their values when the report is run
(for example, you can supply values for parameters on the Request Report
screen).
Characteristics
Parameters have these characteristics:
* They can be of any HP ALLBASE/BRW type: Real, Integer, Numeric,
String, Date, or Time.
* You supply a value or values of that type when you run the report.
See the "Request Report screen" section of Chapter 16 for
details about assigning parameter values when the report is run.
* Parameters must be specified on the Define Selection screen so
that the user can enter values when requesting the report. See
Chapter 16, for the screen description.
* Parameters can be used in a Selection Condition, Relation
Condition, or Relation to select data when a report is run.
* Parameters are referenced by the parameter name preceded by a
question mark, for example:
?month
* Parameter names cannot exceed 19 characters, may start with a
letter, $, # or @, and can then be followed by up to 18 letters or
numbers, and cannot be the same as a reserved word. A list of
reserved words is given later in this chapter.
* Parameters can be used anywhere within the report.
* You can set default values for parameters on the Define Selection
screen.
* You can specify that a value MUST be given for a parameter, and
that strings will be shifted to upper-case.
* To use a parameter, you must compile the report with a Selection
Set.
* Parameters can be one of three different categories: Comparison
Predicate, Single Value, and List of Values.
NOTE Real number parameters have special syntax, described under Real
number syntax in the "Numbers" section.
Example
You can use a parameter to obtain different results from the same
compiled report. For example, you could define a calculated item that
calculates the amount of sales tax to be added to an order. The
calculation might appear:
((PRICE * QUANTITY) * 10) / 100)
for a 10 percent sales tax. However, if you define a parameter TAX-RATE,
and change the formula to:
((PRICE * QUANTITY) * ?TAX-RATE) / 100
You could run the report many times, supplying a different value for
TAX-RATE each time. Parameters can be used in HP ALLBASE/BRW to do the
following:
* Perform calculations.
* Control report format, for example, using suppress line
conditions.
* Control reported data, using a parameter to restrict data written
to a table.
* Optimize data selection, using a parameter to supply values for
keyed access to a table.
Single Value Parameters
Single value parameters are parameters that can be substituted by a
single value only. For example:
FOREIGN-AMOUNT * ?EXCHANGE-RATE
At run-time, the single-value parameter EXCHANGE-RATE will be substituted
by whatever value you supply for the parameter when running the report.
EXCHANGE-RATE can have only one value.
Characteristics
Single value parameters have these characteristics:
* They have only one value.
* They can be used in calculations with these operators:
( <, >, <>, =, <=, >= ), and with all logical operators.
* You can use a single-value parameter like a normal item in
calculations or printing. See Chapter 8, "Report Layout" for
details about printing items.
NOTE You should specify single value parameters as required parameters
when you define them. Otherwise, a missing value will set the
parameter to NO_VALUE. See Exception Handling later in this
chapter.
List-of-Values Parameters
List-of-values parameters can be substituted by a list of one or more
items of the same type.
Characteristics
List-of-values parameters have these characteristics:
* The values you substitute for the parameter must be of the same
type. You cannot have both Real and String values in the same
list.
* A list of values can have any number of values.
* You cannot use values in a list-of-values parameter as items.
* Each value in the list must be stated correctly (strings in double
quote marks, and so on) and separated by commas. See the
description of each type in the "Constants as Arguments" and the
"Numbers" sections of this chapter for a description of how to
state each type.
* A list-of-values parameter can only be used with the operator IN.
This operator returns a Boolean value depending upon whether one
item is in a list of other items.
Example
Suppose you want to use a list-of-values parameter to return a value for
CODE when that value is included in your list-of-values for the
?CODE-LIST parameter. You define the operation like this:
CODE IN ?CODE-LIST
The value returned is true if CODE is equal to any of the list of values
in the parameter ?CODE-LIST. Note that if you do not supply a value for
?CODE-LIST, CODE can never be equal to it.
Comparison Predicate
Comparison predicate parameters can be substituted by a value and an
operator, for example > 50.
Characteristics
Comparison predicate parameters have these characteristics
* They must be used only with the operator SATISFIES.
* They allow the operator and value to be specified at execution
time providing selection of the following:
* one or more explicit values
* all except one or more explicit values
* values which match specific patterns
* all values out of a range of values
* values less than a specific value
* values less than or equal to a specific value
* values greater than a specific value
* values greater than or equal to a specific value
* all values (when parameter value is missing)
* They allow the use of the following masks in parameter values:
@ zero or more occurrences of any character
? one occurrence of any character
The following table shows how comparison predicate parameters work with
operators.
Comparison Predicate
Execution Time Values
-----------------------------------------------------------------------------------------------
| | | |
| Operator | Value | Items Selected |
| | | |
-----------------------------------------------------------------------------------------------
| | | |
| ( Blank ) | ( Blank ) | Unrestricted |
| | | |
| ( Blank ) | List of Values | Item must match values/masks |
| | | |
| = | List of Values | Items must match values/masks |
| | | |
| < > | List of Values | Item may not match values/masks |
| | | |
| > | Single Value | Item must be greater than value |
| | | |
| < | Single Value | Item must be less than value |
| | | |
| >= | Single Value | Item may not be less than value |
| | | |
| <= | Single Value | Item may not be greater than value |
| | | |
| R | Two Single Values | Item in the range of values |
| | | (inclusive) |
| | | |
-----------------------------------------------------------------------------------------------
Examples
Comparison Predicate Value Results
COMPANY =0010 Reports only Company # 0010
ACCOUNT =41@ Reports all accounts starting with 41
DUE-DATE <03/22/82 Reports all Due-Dates earlier than 03/22/82
Operator SATISFIES
Comparison Predicate parameters must be used with the operator SATISFIES.
A comparison predicate returns a Boolean result if the left-hand argument
satisfies the comparison predicate parameter. The following example
shows a comparison predicate parameter used in a report selection
condition:
CUSTOMER-NO SATISFIES ?CUSTOMER
CUSTOMER-NO is an item (the left-hand argument in the condition);
SATISFIES is the operator, and ?CUSTOMER is the comparison predicate
parameter. If you substitute > 1000 for parameter ?CUSTOMER when you run
the report, the report would only select those customers whose
CUSTOMER-NO was greater than 1000. That is, the result of the condition
would be true whenever CUSTOMER-NO was less than 1000.
Special Cases When Using Parameters
You can use parameters in a selection condition to select data for a
report.
You can also use single-value and list-of-values parameters to allow
keyed access to the first source table. See Chapter 6, Defining Data
Access, under the section Keyed Access to First Source Table for an
example of using parameters in this way.
Chapter 19, "Performance Considerations", includes further examples of
access methods and tuning access to source tables.
Default Values For Parameters
You can create a calculated item which provides a default value if a
single-value parameter has no value. For example, the calculated item
MONTH uses the current month as default value if the parameter ?MONTH has
no value.
IF ?month = NO_VALUE
THEN
month_of (date) <<current month>>
ELSE
?month
MPE/iX 5.0 Documentation