HP 3000 Manuals

Formulas [ HP ALLBASE/BRW Reference Manual ] MPE/iX 5.0 Documentation


HP ALLBASE/BRW Reference Manual

Formulas 

Formulas include:

   *   table calculated items

   *   layout calculated items

   *   table functions

   *   layout functions

Calculated Items 

Calculated items are items that are created from a formula that you
define.  Once created, calculated items can be used in a report just like
an item projected from a final access table, or an HP ALLBASE/BRW
standard item.  Calculated items are split into two categories, table
calculated items and layout calculated items, depending upon whether they
are to be created when the tables are built or when the report is
formatted.

Table Calculated Items 

Table calculated items are defined within a table .  They are created
when the table is constructed.  The Table Calc Item screen and the Table
Calc Item Formula screen are used to define the item and its formula.

Characteristics 

Table calculated items have these characteristics: 

   *   Outside the table in which they have been defined, they can be
       used like any other item projected from the table.  (See Chapter 6
        for details about projecting items).  For example, they can
       be:
              printed
              written to an output file
              used for selection
              used for sorting
              used in another calculation formula

   *   They can be any one of the HP ALLBASE/BRW item types:
              N - fixed-point numeric
              R - floating-point real
              I - integer
              S - string
              D - date
              T - time

   *   They can be calculated from source table items, from other
       calculated items or functions defined in the same table, or from
       parameters or constants.

Restrictions 

Restrictions on table calculated items are:

   *   They cannot be used on the Define Relation screen for the same
       table in which they are defined.

   *   They cannot use column calculation results (or certain standard
       items, such as PAGE) as arguments.  See "Standard Items" later in
       this chapter for a list of available standard items.

Example 

Here is an example of a table calculated item, BALANCE-DUE:

[]
This is the Table Calc Item screen for BALANCE-DUE. It is a numeric item.
[]
You define the formula for a table calculated item on the Table Calc Item Formula screen. This formula can use any of the arguments and operators allowed in the Calculation Language, and must obey its syntax rules. These are described in the "Arguments and Syntax" section of this chapter. When the table is constructed, every row of the table will have an item called BALANCE-DUE that you can use in the report. This item will behave exactly like any other Numeric item that you project from the table. Each value of BALANCE-DUE will be equal to the value of AMOUNT, minus the value of PAID-AMOUNT, on that row of the table. Layout Calculated Items Layout calculated items are very similar to table calculated items, but they are defined within the report layout. Layout calculated items are calculated when the report is formatted. The Layout Calc Item screen and the Layout Calc Item Formula screen are used to define the item and its formula. Characteristics The characteristics of layout calculated items are exactly the same as for table calculated items, except that: * Layout calculated items cannot be used in formulas for table calculated items, relation conditions, or table functions. * Layout calculated items can use column calculation results in their calculations; for example, a column total or an average value can be used in the calculation for a layout calculated item. * Layout calculated items can be calculated for each detail lineset, or, you can specify that they be calculated only for certain linesets. Restrictions Restrictions on layout calculated items are: * They cannot be used for selection or sorting.
NOTE For better performance: * Table calculated items are calculated as early as possible in the data access for a report. This means that they are only calculated when their arguments change. Table calculated items generally can improve performance if they replace the items from which they are calculated, so reducing the width of the table. * Layout calculated items are calculated, by default, once for each detail. They can improve performance if they do not replace (that is, are additional to) the items from which they are calculated, since layout calculated items are not part of any table. * If you use a layout calculated item only on a specific break, you can further improve performance if you specify that it is to be calculated only if that break occurs. * Calculated Item performance is further discussed in Chapter 19 , "Performance Considerations."
Examples Suppose you are defining BALANCE-DUE as a table calculated item. Doing that would be efficient if you did not want items AMOUNT and PAID-AMOUNT in your report. That is, you would calculate and project BALANCE-DUE, and not project AMOUNT and PAID-AMOUNT. This would save writing AMOUNT and PAID-AMOUNT on every row of the table, when you did not in fact need them. For more information, see the "Compile Listing" section in Chapter 19 . On the other hand, if you wanted items PAID-AMOUNT and AMOUNT in your report, as well as BALANCE-DUE, you should define BALANCE-DUE as a layout calculated item. It would be calculated once for each detail line, but would not add to the space on each row of the table. Suppose, however, that you wanted the BALANCE-DUE only for the break on CUSTOMER-NO. You would add item BALANCE DUE on the Define Lines screen for that lineset, and specify CALC in the ColCalc field for BALANCE-DUE. Then the item would only be calculated on that lineset.


MPE/iX 5.0 Documentation