Rule variables
For COBOL code generation, you can use only certain types for rule variables.
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.
You can define rule variables in the definitions part of the rule if the variable is bound to an object.
The following variable types are compatible with COBOL code generation:
primitive
class
collector
String
The COBOL code generator generates default COBOL data definitions for primitive and String types. You can change these default settings on the rule project Properties page.
Primitive data types for rule variables
You can define rule variables as primitive data types. When you generate the COBOL code, the rule variable is generated as a COBOL data item. The following table lists the default mapping between primitive data types and COBOL data items:
Primitive data type | Default COBOL data item |
---|---|
boolean | PIC X. 88 BOOLVALUE VALUE ‘T’. |
byte | PIC S9(3). |
Date | DateGroup. 03 YEARVALUE PIC 9(4). 03 MONTHVALUE PIC 9(2). 03 DAYVALUE PIC 9(2). |
double | COMP-2. |
float | COMP-1. |
int | PIC S9(10). |
long | PIC S9(18). |
short | PIC S9(5). |
String | PIC X(20). or PIC N(20). |
If you want to change the default definition for a primitive type, you do so at project level, from the Project properties menu.
Class type rule variables
You can also define Class type rule variables. For example:
definitions set 'quot' to QUOT ; set 'zero quot' to quot where the quot value of quot is 0 ;
In this example, the QUOT class is a non-table item. The variable 'quot' represents the Class type QUOT, and 'zero quot' represents the QUOT Object, where the attribute 'quot-value' is 0.
In a Class type rule variable, the class to which the variable refers cannot be a table item. To define rule variables for table items, use the Collector type.
Collector type rule variables
You can use the IN collector type to define rule variables for table items. For example:
definitions set 'tblArrayVar' to all table items in 'the tables' where the type of this table item is "DOLLAR"'
In this example, 'the tables' refers to a COBOL table item, and 'tblArrayVar' is a collector type that refers to all table items of type DOLLAR.
String type rule variables
Rule variables of type String have a fixed data item definition, of fixed length. For example, the default data definition for a local variable of type String is PIC X(20). This means that whenever you define a rule variable, it is generated as PIC X(20) in the COBOL code.
You can change the default definition for a String type if required. You change definitions at project level from the Preferences menu.