An arithmetic expression in a Reporting Facility program allows you to specify one or more arithmetic operations to be performed on specified data elements.
The terms involved in the expression can be numeric fields or numeric constants connected by arithmetic operators. Evaluation of the expression is carried out according to a specified order to yield a single numeric result.
Define numeric fields in the expression as either packed decimal, zoned decimal, binary or unsigned binary. The Reporting Facility automatically converts all components of the expression to packed decimal format, performs the calculation, and converts the final result to the specified format of the result field.
The types of arithmetic that are valid in an arithmetic expression are:
(addition)
(subtraction)
(multiplication)
(division)
When using the subtraction operator (-), code a space on each side of the operator so the Reporting Facility compiler can distinguish between an arithmetic operator and a dash in a data name. Code any other operators contiguously in the expression.
You can also use parentheses to indicate the hierarchy of operation within an arithmetic expression. When the order is not completely specified, the Reporting Facility assumes that the order of operation is:
Coding parentheses in an expression, helps define the hierarchy of operation and improve readability of the expression. Each method of coding the expression yields the same result:
COMPUTE resultfield = A+B/C - D/C*F+G*C/H+I COMPUTE resultfield = A+(B/C)-(D/C*F)+(G*C)/H+I
|
Copyright © 2014 CA.
All rights reserved.
|
|