Defining variable sets and ruleset variables

For COBOL code generation, you can use only certain types for ruleset variables.

About this task

Note:
Deprecation icon
Deprecated feature: The COBOL code generation feature is deprecated in V8.5. This feature will be removed in a future release of the product. Use the COBOL Generation Project Migration wizard to migrate your Rules for COBOL project to a zRule Execution Server for z/OS® compatible rule project. See Deprecated features for migration details.

Ruleset variables are data internal to the ruleset that can be referenced by any part of the rule project. For COBOL code generation, you can use only the following types for ruleset variables.

  • Java™ primitive types

  • String

  • Date

Class type ruleset variables are not supported.

You group ruleset variables into variable sets. Before you can use a ruleset variable, you must define a variable set for it. When you generate the COBOL code for rule execution, all the items defined in a variable set are declared in the WORKING-STORAGE SECTION, so you do not have to define them in the original or a separate copybook.

Procedure

To define a variable set and ruleset variable:

  1. In the Rule Explorer, right-click any rule element, then select New > Variable Set.
  2. In the New Variable Set dialog, in the Name field, type CobVariables.

    This entry in the Name field provides the interface for defining the COBOL variables required for this rule project.

  3. Click Finish.

    The Variable Set Editor opens.

  4. In the Variable Set Editor, click Add and then enter the new ruleset variable name and values.

    The following example shows the entries for a new ruleset variable named local, of type String.

    Ruleset variable name Type Verbalization Initial Value
    local java.lang.String local: This is the text that will be displayed in the rule editors. DataItem.stringItem("C0")
  5. Save your work.

Results

You can now use the new variable in your rules.

The following example demonstrates using a variable named local in the variable set validation.LocationCheck.

if
   the location of 'the borrower' is not local and
   the location of 'the borrower' is one of { "C1" , "C2" , "C3" }
then
   add message "These rules may not be effected in " + the location of 'the borrower'  ;