Branch Wiring property detail and syntax
Cobol branch wiring Instructions allow one to declare how redefines unions are to be treated.
Cobol redefines unions allow alternate definitions of the same data bytes.
For a specific record, the value of various fields can generally be used to determine which branch of the redefines is valid for a specific record.
Cobol Branch Wiring Instructions allow one to apply logic to discriminate between branches of redefines unions, setting the values of invalid branches to database null.
Cobol branch wiring Instructions for an entity are set at the entity-level property:
cobol.branch.wiring.instructions
When a group item is determined to be invalid through cobol.branch.wiring.instructions then the values of all children of the group item will be set to database null.
When an elementary item is determined to be invalid through cobol.branch.wiring.instructions then the value will be set to database null.
<group-or-elementary-item-name> valid <validWhenCondition>;
<booleanExpression> can be constructed using standard expression operators and references to PIC X and integer PIC 9 elementary items in the copybook.
Examples of branch wiring syntax:
- FOO valid when RECORD-TYPE == 'foo'
- FOO.BAR valid when BIZ.BAZ is numeric
- FOO.BAR valid when BIZ.BAZ is not numeric;
- FOO valid always;
- BAR valid never;
- HOME-LOAN valid when LOAN-TYPE=='HOME';
- LOAN-DETAIL-AREA valid never;
The following table displays syntax for branch control statements:
Supported Query Operator |
Means |
Criteria/Return |
---|---|---|
> |
greater than |
- |
< |
less than |
- |
>= |
greater than or equal to |
- |
<= |
Less than or equal to |
- |
== |
equal to |
- |
!= |
not equal to |
- |
+ |
addition |
- |
- |
subtraction/ negation |
- |
* |
multiplication |
- |
/ |
division |
- |
% |
modulo |
returns the modulo (remainder after division) of two numbers (e.g.,'9%4'will return 1) |
=~ |
regex |
returns values that match specified pattern |
; |
semicolon |
terminates expressions, lets the compiler know that the line as finished |
() |
parentheses |
grouping for operator precedence |
ID |
ID |
field name |
IS NULL IS NOT NULL |
IS NULL |
tests if the value is a database NULL |
IS NUMERIC IS NOT NUMERIC |
a number |
tests if value is a valid NUMERIC value |
true |
Boolean (true) literal |
returns records that satisfy criteria |
false |
Boolean (false) literal |
returns records that do not satisfy criteria |
'string' |
string literal |
returns a constant-value syntactic string (chararray) expression |
Supported Query Operator |
Means |
Criteria/Return |
---|---|---|
|| (double pipe) OR |
or |
returned items match either value |
AND & |
and |
returned items must match both values |
! NOT |
not |
returned items must not match the following value |
Note the following specifications around cobol.record.filter.string:
<FIELD-NAME> can be of types:
PIC X
PIC 9 (unsigned DISPLAY integer)
PIC 9 COMP (unsigned BINARY integer)
PIC S9 COMP (signed BINARY integer)
PIC 9 COMP-3 (unsigned PACKED-DECIMAL integer)
PIC S9 COMP-3 (signed PACKED-DECIMAL integer)
Note that the expression evaluation engine must deal with NULL values. For, example, the value of a numeric field may not be valid for a specific record because of redefines. Therefore, the expression engine continues processing when presented with NULL values. In most case, an operator which receives a NULL argument will return a NULL result. Exceptions are the IS (NOT) NULL and OR operators which behave as expected when presented with a NULL argument.
<constant-value> can be either an integer numeric item or a (single or double) quoted string item. In the case of PIC X comparison with a quoted <constant-value>, care should be taken to ensure that the number of characters in the quoted <constant-value> matches the declared number of characters in the PIC X elementary item.