Purpose
Evaluates one or more conditional expressions and specifies actions based on the outcome of the evaluation.
Syntax
►►─── IF conditional-expression ──────────────────────────────────────────────► ►─── then ──────┬─ command-statement. ────────────────────┬──────────────────► │ ┌───────────────────────┐ │ └─ DO. ─▼─ command-statement. ──┴─ END. ──┘ ►─┬─────────────────────────────────────────────────────────┬────────────────►◄ └─ ELSE ──────┬─ command-statement. ────────────────────┬─┘ │ ┌───────────────────────┐ │ └─ DO. ─▼─ command-statement. ──┴─ END. ──┘
Parameters
Specifies the conditional expression to be evaluated. The outcome of the evaluation determines the processing that occurs.
Conditional-expression contains one or more conditions to be evaluated and is specified according to the rules presented in Conditional Expressions.
Specifies the commands to be executed if the condition is true.
Multiple command statements must be preceded by DO and followed by END.
Command-statement can be any valid CA ADS process command, including another conditional command.
Specifies the commands to be executed if the condition is false.
Multiple command statements must be preceded by DO and followed by END.
Usage
Considerations
Indentation should be used wherever possible to make statements more readable and to ensure that the required clauses are properly matched.
Example 1: Using a simple IF command
In this example, a simple IF command tests the status of a map field and executes a DISPLAY command if the condition is true:
IF FIELD PROD-NUM IS NOT CHANGED
THEN
DISPLAY MSG TEXT IS 'ENTER PRODUCT NUMBER'.
Example 2: Using an IF command with an ELSE clause
This example includes an ELSE clause to display an alternative message if the field ERROR-FIELD contains 0:
IF ERROR-FIELD NE '0'
THEN
DISPLAY MSG CODE IS 171075 PARM=(MSG-NUM).
ELSE
DISPLAY MSG TEXT IS 'ENTER NEXT PRODUCT NUMBER'.
Example 3: Using a nested IF command
This example illustrates a nested IF command that tests for CA-INDX if DB-END-OF-SET is reached:
IF DB-END-OF-SET
THEN
IF CA-INDX EQ 1
THEN
DO.
MOVE 'NO CUSTOMERS QUALIFY' TO MSG-FIELD.
MOVE '1' TO ERROR-FIELD.
RETURN.
END.
ELSE
DISPLAY MSG TEXT IS 'CUSTOMER NUMBER LIST COMPLETE'.
ELSE
DISPLAY MSG TEXT IS 'ADDITIONAL CUSTOMERS MAY QUALIFY'.
|
Copyright © 2014 CA.
All rights reserved.
|
|