When you need to perform processes based on a set of predefined conditions, you can code these conditions using a logical expression.
A logical expression consists of one or more elementary conditions. Each elementary condition can be connected by an AND or an OR connector to form compound conditions. Use parentheses to indicate the order in which conditions or compound conditions are to be evaluated. The AND connector cannot be used with the PERFORM command.
Code an elementary condition as follows:
►►─┬─────────┬─ operand-A ─ relop ─ operand-B ─┬─────────┬────────────────────►◄ ├─ WHERE ─┤ └─ logop ─┘ └─ WHEN ──┘
Separators between elementary conditions (used to improve statement readability). WHEN and WHERE can be used interchangeably and are never required operands.
The first operand of the logical expression. It must be the field name of a predefined field.
Relational operator used to specify the type of comparison to be performed between operand-A and operand-B. The following illustrates all possible relational operators for a logical expression:
Equal to
Greater than
Less than
Equal to
Not equal to
Greater than
Less than
Greater than or equal to
Less than or equal to
Any of these operators may be preceded by the logical NOT operator to cause inversion of the relation. For example, specifying the relation NOT LT (not less than) implies a comparison for greater than or equal to (GTE).
The comparator of the expression that is, the field name, constant, or mask to be compared with the value in the field specified by operand-A. Code the operand in any of the following formats:
If specifying a range test, you do not need to specify the equal sign (or its equivalent). Any other relational operator is flagged as an error. Precede the range of values with at least one scalar variable or one numeric literal; otherwise, the Reporting Facility returns error messages. Code range tests as follows:
►►─┬─ numeric literal ──┬─ (low-range ─┬─ —─┬─ high-range) ────────────►◄ └─ scalar variable. ─┘ ├─ THRU ────┤ └─ TO ──────┘
Logical connector specifying the relationship of the condition with previous conditions in the predicate set. Valid values are AND and OR. When you omit the logical operator and code multiple conditions, the system assumes OR.
Note the following:
If operand-B is not a literal or numeric, you cannot use the abbreviated form:
FIELDX EQ FIELDA or FIELDX EQ FIELDB
The following logical expressions yield the same results:
FIELDX EQ 1 OR FIELDX EQ 3 OR FIELDX (5-7) OR FIELDX GT 10 FIELDX EQ 1 3 (5-7) GT 10
The following table shows valid combinations of operands for condition tests:
X,alphanumeric literal
N,P,B,numeric constant
Bit mask
When you use field names in any of the operands of a logical expression, you can code any valid field name, including scalar variables, array elements, and field name qualifications.
Note: An equal (EQ) compare of two unequal length fields will result in the shorter field being padded with blanks before the compare.
|
Copyright © 2014 CA.
All rights reserved.
|
|