Assigning Final and Temporary Variables

Custom statements use only the Operand1 and Operand2 fields for the actual operation. The Operand3 field is reserved for assigning variable names to results.

For mathematical equations, the variable name that you assign to the final result must be the custom statement name. For group statements, the final result is always an implied yes or no, so you do not make an explicit final assignment.

You can also assign intermediate values to temporary variables. You might do this, for example, to set up complex clause groupings.

For mathematical equations (custom user statements and benefit formulas) you must explicitly assign the final answer to the custom statement. For group statements (Group Definitions, Plan Eligibility, Spouse Eligibility, and Status Code Definitions), the system takes care of this final assignment automatically.

You make a final assignment by entering the "assign to" operator (=) in the Op2 field and the custom statement name in the Operand3 field. For example, in a custom statement called KUH_BF_D1, the final clause includes the = operator in the Op2 field and KUH_BF_D1 in the Operand3 field:

This example illustrates final variable assignment in a custom statement.

Final variable assignment in a Custom Statement

You can make multiple assignments within a single custom statement, but you need to be extremely careful, as these assigned values will remain fixed throughout the rest of the calculation.

To make multiple final assignments, simply add the additional assignment clauses. For example, you can set up custom statement XYZ with the following parameters:

If      "A" equals   B
Then   "C" assign to   D
        "E" assign to   F

with the caveats that:

  • There must be aliases called D and F.

  • D and F cannot be referenced before custom statement XYZ in the jobstream.

    If they were, they would already have values, and this attempt to assign new values would fail.

  • Any references to D or F later in the calculation will use these values.

    You cannot reassign the values, even by processing the D and F custom statements.

Warning! You should generally avoid making multiple assignments within a custom statement. Results may be unpredictable if you have subsequent assignments to the same variable. If you do make multiple assignments, be sure to perform a thorough analysis of your calculation jobstream to look for previous and subsequent references to any secondary variables.

You can make temporary assignments in order to help you group your clauses when the default processing is not the desired method. There are predefined temporary variables that you can use in custom statements in order to reference intermediate results later in the same statement.

This example illustrates temporary variable assignment on the Benefit Formula page.

Temporary variable assignment on the Benefit Formula page

In the example shown, clause 30 references the temporary variable that you created in clause 20. You can assume that later clauses will reference the temporary variables you created in clauses 10 and 20, since that is the only reason to set them up in the first place.

Notice that the example uses the same temporary variable, TEMP02, in clauses 20 and 30. Once you reuse the name in clause 30, the value that it had in clause 20 can no longer be referenced.

When you set up a temporary assignment, assign one of the following predefined temporary variables:

  • For characters and dates, use TEMPC00 through TEMPC99.

  • For numbers, use TEMP00 through TEMP99.

If you select the Temp check box under the Operand3 field, you can press F4 to display a list of the temporary variables when your cursor is in the Operand3 field. You do not, however, have to select the Temp check box in order to use a temporary variable. You can just type it. Because this is just a data entry aid, the mark in the check box is not preserved when you close and open the page.

You can set up separate custom statements for each temporary variable. If you do this, however, the variable is no longer temporary. For example, if a benefit formula is the maximum of Benefit A and Benefit B, you can set up custom statements for each of the component formulas and then reference them from the Benefit Formula statement. This approach can help you shorten some custom statements. In addition, this is the most efficient way to set up aliases when you need the intermediate values for other purposes.

The intermediate results are not shown in the calculation worksheet, regardless of whether you use temporary variables or standalone custom statements. In order for the worksheet to display the values, you have to set up each component as a benefit formula function result.