IF
logical-condition |
|||||
[THEN ]
statement
|
|||||
[ELSE
statement
]
|
|||||
END-IF
|
IF
logical-condition |
|||||
[THEN ] |
statement | ||||
DO
statement
DOEND
|
|||||
ELSE
|
statement | ||||
DO statement
DOEND
|
This document covers the following topics:
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
Related Statements: DECIDE
FOR
| DECIDE
ON
| IF
SELECTION
| ON
ERROR
Belongs to Function Group: Processing of Logical Conditions
The IF
statement is used to control execution of a
statement or group of statements based on a logical condition.
Note:
If no action is to be performed in case the condition is met,
you must specify the statement IGNORE
in the THEN
clause.
Syntax Element | Description |
---|---|
IF
logical-condition
|
Logical Condition Criterion:
The logical condition which is used to determine whether
the statement or statements specified with the Examples: IF #A = #B IF LEAVE-TAKEN GT 30 IF #SALARY(1) * 1.15 GT 5000 IF SALARY (4) = 5000 THRU 6000 IF DEPT = 'A10' OR = 'A20' OR = 'A30' For further information, see the section Logical Condition Criteria (in the Programming Guide). |
THEN
statement
|
THEN Clause:
In the |
ELSE
statement
|
ELSE Clause:
In the |
END-IF
|
END of IF Statement:
In structured mode, the Natural reserved word
In reporting mode, use the |
** Example 'IFEX1S': IF (structured mode) ************************************************************************ DEFINE DATA LOCAL 1 EMPLOY-VIEW VIEW OF EMPLOYEES 2 PERSONNEL-ID 2 NAME 2 FIRST-NAME 2 SALARY (1) 2 BIRTH 1 VEHIC-VIEW VIEW OF VEHICLES 2 PERSONNEL-ID 2 MAKE * 1 #BIRTH (D) END-DEFINE * MOVE EDITED '19450101' TO #BIRTH (EM=YYYYMMDD) SUSPEND IDENTICAL SUPPRESS LIMIT 20 * FND. FIND EMPLOY-VIEW WITH CITY = 'FRANKFURT' SORTED BY NAME BIRTH IF SALARY (1) LT 40000 WRITE NOTITLE '*****' NAME 30X 'SALARY LT 40000' ELSE IF BIRTH GT #BIRTH FIND VEHIC-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (FND.) DISPLAY (IS=ON) NAME BIRTH (EM=YYYY-MM-DD) SALARY (1) MAKE (AL=8) END-FIND END-IF END-IF END-FIND END
NAME DATE ANNUAL MAKE OF SALARY BIRTH -------------------- ---------- ---------- -------- BAECKER 1956-01-05 74400 BMW ***** BECKER SALARY LT 40000 BLOEMER 1979-11-07 45200 FIAT FALTER 1954-05-23 70800 FORD ***** FALTER SALARY LT 40000 ***** GROTHE SALARY LT 40000 ***** HEILBROCK SALARY LT 40000 ***** HESCHMANN SALARY LT 40000 HUCH 1952-09-12 67200 MERCEDES ***** KICKSTEIN SALARY LT 40000 ***** KLEENE SALARY LT 40000 ***** KRAMER SALARY LT 40000
Equivalent reporting-mode example: IFEX1R.