Previous Topic: Step 6: Select Columns for Temporary Result CalculationNext Topic: Step 8: Sort Data for the Report


Step 7: Calculate Temporary Result

DQHB0

=> Press <PF1> for help with writing the arithmetic expression --------------------------------------------------------------------------DQHB0 DATAQUERY: DEFINE THE ARITHMETIC EXPRESSION QUERY NAME: USER-SAMPLE ------------------------------------------------------------------------------- Write an arithmetic expression to be used in calculating the value of the temporary result. SHIP-PRICE with precision (13.2) Use the column numbers F01, F02, etc., numeric literals, or a combination of both and arithmetic operators. The default calculation appears below. You may type over it to change it. => F01 + F02 ------------------------------------------------------------------------------- NUMBER| TABLE NAME/COLUMN NAME | DESCRIPTION ------------------------------------------------------------------------------- | CAI-DETAIL-TBL | F01 | SHIP-QTY | F02 | UNIT-PRICE | | | | | | | | | - LAST PAGE ------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> NOT USED <PF4> CONTINUE <PF5> EXTEND COLUMN <PF6> DISPLAY QUERY <PF7> BACKWARD <PF8> FORWARD

Purpose

The DEFINE THE ARITHMETIC EXPRESSION panel is required only if you named a temporary result. One panel appears for each temporary result you named. With it, you type an algebraic equation that can be simple or complex, and can contain column names and/or literal values.

Concepts

These are the major concepts related to this panel:

Arithmetic Expression
You have a 75-character line upon which you can enter any valid equation whose result will provide the value for your temporary result column for each row. You can add, multiply, divide, subtract, and use parenthetical expressions.

User-Defined Functions
You can even include in an arithmetic expression those special calculations that are created at your site and numbered for inclusion in arithmetic expressions. Your CA Dataquery Administrator can provide you a list of user-defined functions if they are used at your site.

Note: For more information about user-defined and other possible functions, see the CA Dataquery Reference Guide.

Column Number
CA Dataquery allows you to use shorthand to identify any columns that were selected for use in your calculation with a number assigned on the list. Using this shorthand provides you more room to write complex expressions.

Default Calculation
As a default calculation, CA Dataquery always sequentially adds the columns you selected. You can change the expression by writing over it, inserting, or deleting characters. The result will be your final calculation. It must conform to the rules for calculations detailed in the CA Dataquery Reference Guide.

Panel Operation

On this panel, you use the Tab key to move the cursor from one field to another, type entries, and press <PF4> CONTINUE to display the next panel.

Completed Example

The following completed panel shows how the completed DEFINE ARITHMETIC EXPRESSION panel defines the calculation.

=> Press <PF1> for help with writing the arithmetic expression --------------------------------------------------------------------------DQHB0 DATAQUERY: DEFINE THE ARITHMETIC EXPRESSION QUERY NAME: USER-SAMPLE ------------------------------------------------------------------------------- Write an arithmetic expression to be used in calculating the value of the temporary result SHIP-PRICE with precision (13.2) Use the column numbers, F01, F02, etc., numeric literals, or a combination of both and arithmetic operators. The default calculation appears below. You may type over it to change it. => F01 * F02 ------------------------------------------------------------------------------- NUMBER| TABLE NAME/COLUMN NAME | DESCRIPTION ------------------------------------------------------------------------------- | CAI-DETAIL-TBL | F01 | SHIP-QTY | F02 | UNIT-PRICE | | | | | | | | | - LAST PAGE ------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> NOT USED <PF4> CONTINUE <PF5> EXTEND COLUMN <PF6> DISPLAY QUERY <PF7> BACKWARD <PF8> FORWARD

This chart explains the reason for the entries.

Field or Item

Sample Entry

Reason

Calculation

F01 * F02

To multiply the number of items shipped by the price.

Options

You could create a very simple calculation, like:

F01 * .10

Or, with more columns defining your calculation, you could create a very complex calculation, like:

(F01 * 3.3) + (F02 / F05) / (F03 + F04)

Hierarchical rules for mathematical expressions in CA Dataquery are found in the CA Dataquery Reference Guide.

To Go to the Next Step

After defining the temporary result calculation for this query, the next panel, after pressing <PF4> CONTINUE, tells how to sort the data.

Before you go on, take a look at how the query looks in DQL so far.

=> --------------------------------------------------------------------------DQHN0 DATAQUERY: GUIDED QUERY DISPLAY QUERY NAME: USER-SAMPLE ------------------------------------------------------------------------------- ================================ T O P ====================================== FIND ALL CAI-DETAIL-TBL WITH SHIP-QTY GT 0 SET SHIP-PRICE(13.2) = CAI-DETAIL-TBL SHIP-QTY * CAI-DETAIL-TBL UNIT-PRICE ============================== B O T T O M ================================== ------------------------------------------------------------------------------- <PF1> HELP <PF2> RETURN <PF3> NOT USED <PF4> NOT USED <PF5> NOT USED <PF6> NOT USED <PF7> BACKWARD <PF8> FORWARD

So far, the query reads (FIND) all CAI-DETAIL-TBL table rows in the search for data that have (WITH) a SHIP-QTY greater than 0. It also calculates for each row (SET) the result of SHIP-QTY multiplied by UNIT-PRICE and place the result into SHIP-PRICE.