Conditional Statements 
You create conditional statements using an IF statement. Further conditional statements can follow an IF statement in an ELSEIF statement. The ELSE statement is for dealing with the remaining cases within a chain of conditional statements. The schema is as shown in the following example.
Example
IF <Expression1>.
<Statement1>.
ELSEIF <Expression2>.
<Statement2>.
ELSE.
<Statement3>.
ENDIF.
Expressions in the IF statement consist of operands, variables and constants, relational operators and logical operators (see Operators and Functions).
Note
Note that constants can only be positioned to the right of a comparison operator.
Example
To check the special case of whether an operand <oper1> has the initial value, you can write:
IF <oper1> IS INITIAL. or IF <oper1> = '#'.
Example
Example of a construction with logical operators: IF NOT <oper1> < <oper2> AND <oper3> = <oper4> OR <oper5> > <oper2>.
You can use the following operators when working with character-type operands.
Operator |
Meaning in Expression |
|---|---|
CP (Contains Pattern) |
The whole of string c1 matches pattern c2. Wildcards can also be contained in pattern c2 where '*' stands for a string and '+' for a symbol. |
CO (Contains Only) |
c1 only contains characters from character set c2 . If c1 or c2 is of internal type C, the complete length of the field is included in the comparison, meaning that means blanks at the end are also taken into account. If c1 is of type STRING and is empty, the result of the comparison is always positive. If c2 is of type STRING and is empty, the result of the comparison is always negative unless c1 is also an empty string. |
CA (Contains Any) |
c1 contains at least one character from character set c2. If c1 or c2 is of internal type C, the complete length of the field is included in the comparison, meaning blanks at the end are also taken into account. If c1 or c2 is of type STRING and is empty, the result of the comparison is always negative. |
CS (Contains String) |
c1 contains character string c2. If the relevant field is of type C, the final blanks in c1 and c2 are ignored. An empty c2 string (only blanks for type C or an empty string for type STRING) is contained in any c1 string and in the string itself. Otherwise there is no non-empty character set c2 in an empty character string c1. |