COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Usage Considerations:
• CONTINUE is Recommended Over NEXT SENTENCE
NEXT SENTENCE transfers control to the next period (.), while CONTINUE transfers control
to END-SEARCH. Either imperative-stmt-1, imperative-stmt-2, or both can be
CONTINUE statements.
• Binary Search
HP COBOL performs a binary search when these conditions are met:
◦ Each condition-name referenced in the WHEN clause must be defined as having a single
value.
◦ The data-name associated with a condition-name must appear in the KEY phrase in the
OCCURS clause of the data definition of table.
◦ Each identifier-1 must be subscripted by the first index-name associated with table,
along with other subscripts as required, and must be referenced in the KEY phrase in the
OCCURS clause of the data definition of table.
◦ The identifiers mentioned in the operands must not be referenced in the KEY phrase in
the OCCURS clause associated with table, and must not be subscripted by the first
index-name associated with table.
◦ When a data-name in the KEY phrase of the OCCURS clause associated with table is
referenced, or when a condition-name associated with such a data-name is referenced,
all preceding data-names (or the associated condition-names) in the KEY phrase of that
OCCURS clause must also be referenced.
When a SEARCH ALL statement does not meet these conditions, the compiler issues a warning
and does a linear search.
• Additional Syntactic Constraints
If the WHEN phrase mentions either a data-name in the KEY phrase of the OCCURS clause
of the definition of table or a condition-name associated with a data-name in that KEY
phrase, all preceding data-names in the KEY phrase must also be mentioned in the WHEN
phrase. To illustrate, suppose you have this OCCURS clause:
05 DEPT-TABLE OCCURS 500 TIMES
ASCENDING KEY IS DIV
SEC
DEPARTMENT
INDEXED BY NDEX, MDEX.
07 DIV PIC 9(4).
07 SEC PIC 9(3).
07 DEPARTMENT PIC 9(3).
88 R-AND-D VALUE 555.
You can search on DIV, or DIV and SEC, or all three keys. You cannot search on SEC without
searching on DIV, and you cannot search on DEPARTMENT without searching on DIV and
SEC.
• Order of Table Elements
Verify that the table is ordered as specified in the ASCENDING or DESCENDING phrase of
the OCCURS clause of the table’s definition. If it is not, the result of the search is undefined.
434 Procedure Division Verbs










