Operands

Operands form the backbone of an Production Reporting expression. Operands do not have to be the same type. You can combine string, numeric and array field operands to form a valid expression. Production Reporting performs a sequence of automatic operand conversions as it evaluates expressions that contain dissimilar operand types. As the expression is evaluated, operands of lower precision are converted to match the operand of higher precision. Consider the following example:

let  #answer = #float * #decimal  / #integer

Since the multiply and divide operators are equal in precedence, the expression is evaluated as (#float * #decimal) / #integer. Working from the inside out, the #float variable is converted to a decimal type where a multiply is performed yielding the simplified expression, (#decimal)/#integer. Production Reporting now converts the #integer operand to a decimal type before performing the final divide. When finished with the expression evaluation, Production Reporting converts the result to match the type of the #answer variable.

Converting operands of lower precision to operands of higher precision preserves the number of significant digits. The number of significant digits is not lost when an integer is converted to float or decimal. In a similar manner, the number of significant digits is preserved when floating point operands are converted to the decimal type. The number of significant digits is only sacrificed when the final result is converted to match the type of the #answer variable and this variable is less precise than the highest of the operands being evaluated. In the example, precision is not lost if the #answer is declared as a decimal type. Production Reporting considers integer variables as the lowest in the precision hierarchy, followed by float and then decimal.

Here are a few simple expression examples:

let #discount=round (&price * #rate / 100, 2)
let $name=$first_name || ' ' || $last_name
let customer.total (#customer_id) = 
  customer.total (#customer_id) + #invoice_total
  if not range(upper($code), 'A', 'G')
  ...processing when out of range...
let store.total (#store_id, #qtr) =	
  store.total (#store_id, #qtr) + #invoice_total
let $date1 = strtodate ('Apr 10 1996', 'MON DD YYYY')