Purpose
Evaluates an arithmetic expression. The result of the evaluation is placed in a variable data field.
Syntax
►►─── COMPUTE variable ── options ──┬─ ─ = ─ arithmetic-expression ───┬───► └─ ALLOWING assignment-condition ─┘
Expansion of options
►───┬─────────────────────────────────┬──────────────────────────────────►◄ ├─ ROUNDED ───────────────────────┤ └─ TRUNCATED ─────────────────────┘
Parameters
Specifies the name of a variable data field that contains the result of the COMPUTE operation.
Rounds the result of the computation to the number of decimal positions found in variable.
Truncates the result of the computation to the number of decimal positions found in variable.
The default specification is ROUNDED if COBOL moves are enabled is not selected and TRUNCATED if the option is selected.
Specifies which error conditions would normally abend and should cause control to be returned to the dialog for error handling. The list of allowable assignment-condition names can be found in the section entitled "Arithmetic and Assignment Command Status Condition."
Specifies the arithmetic expression being evaluated for the value contained in variable.
More information:
For information on arithmetic-expression, see Chapter 6, Arithmetic Expressions.
Example
The following example uses the COMPUTE command to calculate commission as a percentage of sales plus a percentage of sales above quota. The result is truncated.
COMPUTE COMMISSION TRUNCATED =
0.10 * SALES + 0.03 * (SALES - QUOTA).
|
Copyright © 2014 CA.
All rights reserved.
|
|