Exercise 4:Defining the Selection Sets [ HP ALLBASE/BRW Tutorial ] MPE/iX 5.0 Documentation
HP ALLBASE/BRW Tutorial
Exercise 4:Defining the Selection Sets
This exercise shows you how to define parameters, and describes the three
types of parameters. This exercise also describes the operator
SATISFIES, shows you how to define selection sets, and selection
conditions. This exercise takes 40 minutes.
Overview
You need to restrict the report so that:
* sales managers can only obtain information concerning one sales
area
* You can select the customers to be included in the report at run
time.
You can restrict data using selection sets, and provide a means of
selecting a subset of data at run time using parameters.
What is a Parameter?.
A parameter is a placeholder for which you provide a value at run time.
Whenever you run a report containing a parameter, you can supply a value
for that parameter.
Parameters must be preceded by a question mark when used in report
calculations or on the Define Lines screen. Parameters are fully
described in the HP ALLBASE/BRW Reference Manual.
This lesson gives you an example exercise for using parameters.
What is a Selection Set?.
A selection set is a set of default information that can be used every
time you run the report. Such default information includes: parameter
values, number of copies, print device, input and output priorities, and
so on. A report can have multiple selection sets so it can be tailored
for many users by compiling the report with different selection sets.
Each combination of selection set and report is compiled to form a
separate execution file. In this way, one report can be tailored for
many different users by compiling it with different selection sets.
A selection set can have a selection condition that acts as a filter for
data used in the report.
This lesson has an exercise that shows you how selection sets and
selection conditions are used.
Selection Conditions and Relation Conditions.
You could specify a condition as a relation condition instead of a
selection condition. However, a selection condition applies only to
reports compiled with a particular selection set. A relation condition
applies to all compilations of the report, regardless of the selection
set, or even if no selection set is used.
Your Task
You want two reports, one for directors that allows access to all sales
areas, and one for sales managers, which is restricted to one sales area
only. Additionally, you want to be able to choose either all customers
or a subset of customers.
You can use parameters to select a subset of customers and a sales area,
and use two selection sets to provide two execution files, one for
directors, and one for sales managers.
Define the selection set for directors
1. Choose Define Select'n.
BRW displays the Define Selection screen.
_________________________________________________________________
NOTE This screen look likes the Request Report screen. The
selection set for directors uses a parameter to select
either all customers or a subset of customers in the report.
_________________________________________________________________
2. Type DIRECTORS in the Selection Set field.
3. Press Add Select'n.
BRW tells you the selection set was added.
Define the selection of customers
1. Choose Select'n Condit'n to define a selection condition that
will select a subset of customers.
This is the Selection Condition screen. You want a condition that
will select only those customers that are requested by the user at
run time, that is, only those customers specified in a parameter.
2. Type the following text:
CUSTOMER-NO SATISFIES ?CUSTOMER-NO
<< This selection condition selects only those customers whose
customer number matches the parameter CUSTOMER-NO. >>
3. Press Enter.
The prompt tells you that the parameter CUSTOMER-NO does not
exist. A new function key, Exit Save is now available.
4. Choose Exit/Save to return to the Define Selection screen and
save your selection condition.
The Exit Save key lets you leave an incomplete formula and correct it
later. (If you just choose Exit on an incomplete formula, the formula
would be erased).
When you define the parameter, this formula will be correct.
Define a parameter
1. Choose Define Parms to define the parameters.
BRW displays the Parameter screen.
2. Type CUSTOMER-NO in the Parameter field.
3. Type 6 for the Value Length.
4. Type S for the Result Type.
Notice the other result types available. The parameter we use in
this report is a string (S).
5. Type P for Type.
CUSTOMER-NO is a comparison predicate parameter (P).
There are three types of parameter:
Comparison Predicate can be substituted by an operator and a
value
Single Value can be substituted by a single value only
List of Values can be substituted by a list of values
Comparison predicate parameters are used in formulas only with the
operator SATISFIES, as in the selection condition you just
defined. Operators for comparison predicates are fully described
in the HP ALLBASE/BRW Reference Manual.
6. Type X in the Upshift field.
At run time the parameter will be converted to uppercase.
7. Choose Add Parm.
BRW adds the parameter.
NOTE A parameter and an item can have the same name; you differentiate
between them in formulas and in the report layout by specifying a ?
before the parameter name.
Finish defining the CUSTOMER-NO parameter
1. Choose Exit to return to the Define Selection screen.
2. Type CUSTOMER-NO (without a preceding "?") in the Parameter field.
3. Press Enter.
Now, if the report is run when compiled with this selection set,
the parameter CUSTOMER-NO will be displayed on the Request Report
screen so the user will know that they can supply a value for the
parameter. (If no parameter value is entered, the condition will
be ignored and all records will be selected. )
4. Choose Select'n Condit'n.
The Selection Condition screen appears.
Because you have defined the parameter CUSTOMER-NO, the formula is
now correct. No error is indicated and the Exit Save key is not
displayed.
5. Choose Exit to return to the Define Selection screen.
You have now defined the selection set for directors. A director running
this report, when compiled with selection set DIRECTORS, can select a
subset of, or all of, the customers.
Defining the Selection Set for Sales Managers
The selection set for sales managers is much the same as that for
directors, except that sales managers must only be allowed to report data
on one sales area. So you need one more parameter that selects one, and
only one, sales area.
Define the selection set
1. Choose Define Parms.
BRW displays the screen for parameter CUSTOMER-NO. The parameter
that selects one, and only one, area must be a single value
parameter.
2. Type AREA in the Parameter field.
3. Space over the remainder of CUSTOMER-NO
4. Type 16 in the Value Length field.
5. Type S in the Result Type field.
6. Type S in the Type field.
This is a single value parameter since you want to select one, and
only one sales area for the report.
7. Type X in the Value Required field.
When the report is compiled with this selection set, BRW will
require a value for this parameter.
8. Type X in the Upshift Value field
The value will be converted to all uppercase.
9. Choose Add Parm. (Do not press Enter, as then BRW will assume
you want to rename the old parameter.)
BRW adds the new parameter.
Your screen should look like the next example:
10. Choose Exit to return to the Define Selection screen.
Define the selection set for sales managers
1. Type SALES-MANAGERS in the Selection Set field.
2. Type AREA in the parameter field below CUSTOMER-NO.
3. Choose Add Select'n.
BRW tells you the selection was added.
Define the selection condition for the selection set
1. Choose Select'n Condit'n.
2. Type the following text:
(SALES-AREA = ?AREA) AND (CUSTOMER-NO SATISFIES ?CUSTOMER-NO)
<< This selection condition selects a subset of customers in
one, and only one, sales area. >>
3. Press Enter.
Your screen should look like the following example:
When the report is compiled with selection set SALES-MANAGERS,
only those records that are in the sales area specified, and that
satisfy the comparison predicate parameter CUSTOMER-NO, will be
used in the report.
4. Choose Exit to return to the Define Selection screen.
Anyone running the report, when compiled with selection set
SALES-MANAGERS, must enter a value for the required parameter
AREA. This parameter is used in the selection condition that
restricts records in the report to those records with the same
sales area.
5. Choose Exit again to return to the Define Report screen.
NOTE There is no restriction on which sales area is reported. If you
wanted to restrict the report to one sales area you can define a
further selection set, with the following selection condition:
(SALES-AREA = "EASTERN") AND (CUSTOMER-NO SATISFIES ?CUSTOMER-NO)
You could define four such selection sets, each with a selection
condition restricting the sales area to one of the four areas. In
that case, you would not need the parameter AREA.
However, other exercises in this lesson assume you are using the
parameter AREA.
MPE/iX 5.0 Documentation