Open topic with navigation
CALCULATION name TYPE type SIZE size [PRECISION dec_places] [IF conditional_spec] EXPRESSION "expression" [ALTERNATE "alt_expression"] [DESCRIPTION "description"] [JUST just] [FORMAT "format"] [AFTER_SORT]
The name of the temporary calculation field. It can have up to 15 characters and cannot contain spaces.
The data type of the calculation’s result. Valid values are ALPHANUMERIC, NUMERIC, DATE, TIME.
The length of the calculation’s result. When using date or time fields in your calculation, the length should match the storage length of the base value in the expression.
(optional) The number of characters to the right of the decimal in the implied‑decimal calculation field. If the data type is implied‑decimal, this attribute must be present, and it must be less than or equal to the size of the field. Otherwise, the field is ignored.
(optional) Specifies a condition or set of conditions in a report. The conditional_spec can have up to five conditions connected together. See Condition_spec definition.
(optional) The calculation’s expression. It can have up to 150 characters and must be enclosed in quotation marks. See Entering an expression for the syntax.
(optional) The calculation’s alternate expression. It can have up to 150 characters and must be enclosed in quotation marks. See Entering an expression for the syntax.
(optional) A description of the calculation field. It can have up to 40 characters.
(optional) The justification of the calculation field. Valid values are:
LEFT (default for alpha, date, time, and user type fields)
CENTER (valid only for alpha and user fields)
RIGHT (default for decimal and implied‑decimal fields)
(optional) The display format for the calculation field. It can have up to 40 characters.
(optional) Indicates that the calculation field will be evaluated after the sort. If the field is dependent on one or more subtotal access fields, it is automatically evaluated after the sort.
The CALCULATION statement describes a temporary calculation field to be created in a report.
A calculation field defines a mathematical expression. Calculation fields are temporary fields that are not found in the repository. To create this type of field, you must specify the field name, data type, data length, and calculation expression. You can also define an alternate expression based on a conditional.
The order in which you specify your calculation fields determines the order in which ReportWriter evaluates them. The maximum number of calculation fields that can be defined in a report is 99.
If a temporary calculation field does not have a unique name, it must be preceded by “TEMP.”. For example, if the temporary field is called AVERAGE and one of the selected files also contains a field called AVERAGE, you would specify the temporary field like this:
"ORDER.SHP_DATE - ORDER.ORD_DATE" CALCULATION TURNTIME TYPE NUMERIC SIZE 8 EXPRESSION "ORDER.SHP_DATE - ORDER.ORD_DATE"
CALCULATION TURNTIME TYPE NUMERIC SIZE 8 IF CUSTOMER.CUST_ID LT "100" AND CUSTOMER.CUST_ID GT "50" EXPRESSION "ORDER.SHP_DATE - ORDER.ORD_DATE"