COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
If, when execution of the SEARCH statement begins, the value of the index-name corresponds
to an occurrence number greater than the one that identifies the last element of the table, the
at-end condition exists and the search operation terminates immediately; otherwise, the search
operation proceeds:
1. Each condition is evaluated, in the order in which they appear in the statement, until one
of them evaluates to TRUE or all of them evaluate to FALSE. For each operand of a
condition, the process of operand identification occurs just prior to its use each time the
operand participates in the determination of that condition’s value. For details, see
Condition Evaluation Rules (page 276).
2. When a condition evaluates to TRUE, the search operation terminates immediately. If that
condition is followed by the NEXT SENTENCE phrase, control passes to the next executable
sentence; otherwise, the associated imperative-stmt-2 is executed and control passes
to the end of the SEARCH statement (unless the imperative-stmt-2 explicitly transfers
control elsewhere using a GO TO statement).
3. When all conditions evaluate to FALSE, the index-name value is incremented to correspond
to the next occurrence number.
4. When the new value of the search index-name corresponds to an occurrence number
greater than the one that identifies the last element of the table, the at-end condition exists
and the search operation terminates immediately; otherwise, the search operation repeats
from Step 1.
When the search operation terminates due to the at-end condition, imperative-stmt-1
is executed, if the AT END phrase is specified. Control then passes to the end of the SEARCH
statement (unless imperative-stmt-1 explicitly transfers control elsewhere using a GO
TO statement).
• Multidimensional Tables
If table is an element of another table, you have a multidimensional table. Each dimension
of the multidimensional table must be declared with an INDEXED phrase. A SEARCH statement
uses only the first index of each dimension. To search an entire multidimensional table, you
must execute several SEARCH statements. Before each execution of a SEARCH statement, you
must execute a SET statement to adjust index-names to appropriate settings. The index-names
must be used in the SEARCH statement’s condition.
430 Procedure Division Verbs










