1. Conditional Expressions
A conditional expression is used for the program to selectively modify the execution logic by determining the truth value. Conditional expressions can be used in EVALUATE, IF, PERFORM, and SEARCH statements.
A conditional expression can be specified in either of the following.
-
Simple conditions
-
Complex conditions
1.1. Simple Conditions
A simple condition has either a true or false value.
There are four kinds of simple conditions.
-
Class conditions
-
Condition-name conditions
-
Relation conditions
A relation condition compares two operands. A comparison is defined as follows:
-
Two alphabetic class operands
-
Two alphanumeric class operands
-
Two DBCS class operands
-
Two numeric class operands
-
An alphabetic class operand and an alphanumeric class operand
-
A numeric integer operand and an alphanumeric class operand
-
Comparison between indexes or index data items
-
Two data pointer operands
-
Two procedure pointer operands
-
Two function pointer operands
-
Alphanumeric groups, and operands with the DISPLAY or DISPLAY-1 usage
There are two kinds of relation conditions.
-
General relation conditions
-
Data pointer relation conditions
-
-
Sign conditions
-
Switch-status conditions
Class Conditions
The class condition determines if the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric, DBCS, KANJI, or includes the characters specified in the CLASS clause that is defined in the SPECIAL-NAMES paragraph of the environment division.

-
identifier-1
-
A data item with one of the following usages must be referenced.
-
When NUMERIC is specified: DISPLAY, COMPUTATIONAL-3, or PACKED-DECIMAL
-
When DBCS is specified: DISPLAY-1
-
When ALPHABETIC, ALPHABETIC-UPPER, or ALPHABETIC-LOWER is specified: DISPLAY
-
When class-name is specified: DISPLAY
-
-
If identifier-1 is a function-identifier, referencing the alphanumeric function is required.
-
One of the following must be set.
Item Description NOT
Negates a truth value.
For instance, the result of NOT NUMERIC becomes true if the test of NUMERIC class is false.
NUMERIC
identifier-1 all consists of the numbers from 0 to 9.
ALPHABETIC
identifier-1 consists of lowercase or uppercase alphabetical characters from A to Z, and space characters.
ALPHABETIC-LOWER
identifier-1 consists of lowercase alphabetical characters from a to z, and space characters.
ALPHABETIC-UPPER
identifier-1 consists of uppercase alphabetical characters from A to Z, and space characters.
class-name
identifier-1 consists of the characters defined in the SPECIAL-NAMES paragraph class-name.
DBCS
identifier-1 consists of DBCS characters.
-
The following table shows the relationship between available data item types and the class condition.
Type of Data Item Referenced by identifier-1 | Valid Forms of the Class Condition | |
---|---|---|
Alphabetic |
ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER class-name |
NOT ALPHABETIC NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER NOT class-name |
Alphabetic, Alphabetic-edited, Numeric-edited |
ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER NUMERIC class-name |
NOT ALPHABETIC NOT ALPHABETIC-LOWER NOT ALPHABETIC-UPPER NOT NUMERIC NOT class-name |
External-decimal, Internal-decimal |
NUMERIC |
NOT NUMERIC |
DBCS |
DBCS |
NOT DBCS |
Numeric |
NUMERIC class name |
NOT NUMERIC NOT class name |
Condition-name Conditions
A condition-name tests a conditional variable, and determines which value of condition-name is equal to its value.

Item | Description |
---|---|
condition-name-1 |
Used as an abbreviation for the relation condition. The rules of comparison between a conditional variable and a condition-name value are the same as those of relation conditions. If condition-name-1 is a range of values, the conditional variable is tested to see whether its value is included in the range. If the value of the conditional variable is the same as one of the values of condition-name, the result will be true. |
The following example shows how to use conditional variables and condition-names.
01 AGE-GROUP PIC 99. 88 INFANT VALUE 0. 88 BABY VALUE 1, 2. 88 CHILD VALUE 3 THRU 12. 88 TEENAGER VALUE 13 THRU 19.
AGE-GROUP is the conditional variable. INFANT, BABY, CHILD, and TEENAGER are condition-names.
The following IF statement determines the age group with the values of AGE-GROUP.
IF INFANT... (Tests for value 0) IF BABY... (Tests for values 1, 2) IF CHILD... (Tests for values 3 through 12) IF TEENAGER... (Tests for values 13 through 19)
General Relation Conditions
A general relation condition compares two operands. The operands can be an identifier, literal, arithmetic expression, or index-name.

Item | Description |
---|---|
operand-1 |
The subject of the relation condition. Can be an identifier, literal, function-identifier, arithmetic expression, or index-name. |
operand-2 |
The object of the relation condition. Can be an identifier, literal, function-identifier, arithmetic expression, or index-name. |
In a general relation condition, data items, literals, and figurative constants can be compared using the following comparison types.
Comparison type | Description |
---|---|
Alphanumeric |
Comparison between alphanumeric characters of two operands. |
DBCS |
Comparison between DBCS characters of two operands. |
Numeric |
Comparison between the algebraic values of two operands. |
GROUP |
Comparison between alphanumeric characters of two operands, when one of the operands is an alphanumeric group item. |
(Int) |
Comparison only between integer items (co-used with Alph, Num, or Group). |
Blank |
Comparison is unavailable. |
The following tables show pairs of comparison between different operand types.


-
Alphanumeric comparisons
-
Compares the single-byte characters of two operands using the collating sequence.
-
If an operand is not alphanumeric or alphabetic, the following is performed.
-
A zoned decimal integer operand is treated as a zoned decimal alphanumeric item with the same size.
-
A display floating-point item is treated as an alphanumeric item, not a numeric value.
-
-
If both operands have the same size, they are compared from the leftmost character to the rightmost character. When the first difference is encountered, the priority is determined by comparing each character’s position in the collating sequence.
-
If the operands have different sizes, spaces are added to the shorter operand to make them the same size before comparing them.
-
-
DBCS comparisons
Performs the same comparison as alphanumeric comparison by using the binary hexadecimal collating sequence.
-
Numeric comparisons
Performs algebraic comparison of two operands.
-
Group comparisons
Performs an alphanumeric character comparison of two operands. This is the same as the alphanumeric elementary data item comparison.
-
Index comparisons
Compares occurrence numbers of two index items. If an index is compared with a data item or literal, its occurrence number is compared with the data or literal value.
Data Pointer Relation Conditions
For pointer data items, only the 'equal' and 'not equal' comparisons are available. Pointer data items are items defined as USAGE POINTER, or are ADDRESS OF special registers.
The relation condition can be used in IF, PERFORM, EVALUATE, and SEARCH (format-1) statements. It cannot be used in SEARCH format-2(SEARCH ALL) statements.

Item | Description |
---|---|
identifier-1, identifier-3 |
Any data items except level-66 and level-88 can be used. |
identifier-2, identifier-4 |
Data item defined as USAGE POINTER. |
NULL, NULLS |
NULL pointer. |
Procedure-pointer and Function-pointer Relation Conditions
The procedure-pointer and function-pointer relation condition only determines whether the items are equal or not.

Item | Description |
---|---|
identifier-1, identifier-3 |
Either USAGE PROCEDURE-POINTER or FUNCTION-POINTER. |
NULL, NULLS |
NULL pointer. |
Sign Conditions
The sign condition determines whether the value of a numeric operand is larger than, smaller than, or equal to zero.

Item | Description |
---|---|
operand-1 |
Numeric identifier or an arithmetic expression. It is POSITIVE if its value is larger than zero, NEGATIVE if it is smaller than zero, and ZERO if it is equal to zero. An operand without a sign can be either POSITIVE or ZERO. |
NOT |
Negatives a true or false value. For instance, NOT ZERO is determined as true when the operand is a positive or negative value which is not zero. |
Switch-status Conditions
The switch-status condition determines the On or Off status of an UPSI switch. The result is determined according to the status value of the UPSI switch.

Item | Description |
---|---|
condition-name |
UPSI switch defined in the special-names paragraph. |
1.2. Complex Conditions
A complex condition is composed of a combination of simple conditions and combined conditions with logical operators, or negations of conditions with logical negation. Space characters are needed before and after each logical operator.
Unless parentheses are used, the following priority order applies.
-
Arithmetic operator
-
Simple conditions
-
NOT
-
AND
-
OR
The truth value of a complex condition is determined by the mutual relationship between the truth value of each simple condition and the logical operator.
A complex condition is either of the following.
-
Negated simple condition
-
Combined condition (which can be negated)
Negated Simple Conditions
A simple condition can change the true or false value by using the logical operator NOT.

Item | Description |
---|---|
conditions-1 |
Gives the opposite result to the true or false value of condition-1. If condition-1 is true, the result will be false. If condition-1 is false, the result will be true. |
Even if condition-1 is enclosed with parentheses, the result does not change. For example, the following two sentences are equivalent.
NOT A IS EQUAL TO B NOT ( A IS EQUAL TO B )
Combined Conditions
A combined condition consists of two or more conditions connected by a logical operator.

condition-1 or condition-2 can be any of the following.
-
Simple condition
-
Negated simple condition
-
Combined condition
-
Negated combined condition (when a combined condition enclosed within parentheses appears after the logical operator NOT)
The following table shows a relationship between the logical operator, condition C1, and C2.
C1 | C2 | C1 AND C2 | C1 OR C2 | NOT (C1 AND C2) | NOT C1 AND C2 | NOT (C1 OR C2) | NOT C1 OR C2 |
---|---|---|---|---|---|---|---|
True |
True |
True |
True |
False |
False |
False |
True |
False |
True |
False |
True |
True |
True |
False |
True |
True |
False |
False |
True |
True |
False |
False |
False |
False |
False |
False |
False |
True |
False |
True |
True |
Abbreviated Combined Relation Conditions
If relation conditions are consecutively written, a relation condition after the first relation condition can be abbreviated in either of the following ways.
-
Omitting the subject
-
Omitting the subject and relation operator

In associated relation conditions, both kinds of abbreviation can be applied. The abbreviated condition can be determined as follows:
-
The last described subject is the omitted subject.
-
The last described relation operator is the omitted operator.
The following table shows examples of abbreviated conditions.
Abbreviated Combined Relation Condition | Equivalent |
---|---|
A = B AND NOT < C OR D |
((A = B) AND (A NOT < C)) OR (A NOT < D) |
A NOT > B OR C |
(A NOT > B) OR (A NOT > C) |
NOT A = B OR C |
(NOT (A = B)) OR (A = C) |
NOT (A = B OR < C) |
NOT ((A = B) OR (A < C)) |
NOT (A NOT = B AND C AND NOT D) |
NOT ((((A NOT = B) AND (A NOT = C)) AND (NOT (A NOT = D)))) |