Binary Search

The Format 2 SEARCH ALL statement executes a binary search. The search index need not be initialized by SET statements, because its setting is varied during the search operation so that its value is at no time less than the value of the first table element, nor ever greater than the value of the last table element. The index used is always that associated with the first index-name specified in the OCCURS clause.
identifier-1
Can be a data item subordinate to a data item that contains an OCCURS clause; that is, it can be a part of a two- to seven-dimensional table. In this case, the data description entry must specify an INDEXED BY phrase for each dimension of the table.

Before the search takes place, the values of all indexes should be set for higher dimensions of the table to define a specific table of identifier-1 elements.

Identifier-1 must refer to all occurrences within the table element; that is, it must not be subscripted or indexed.

Identifier-1 cannot be a pointer data item or a procedure-pointer data item.

IBM Extension

Identifier-1 cannot be a floating-point data item.

End of IBM Extension
IBM Extension

Identifier-1 can be a DBCS data item if the ASCENDING/DESCENDING KEY is defined as a DBCS data item.

End of IBM Extension
IBM Extension

Identifier-1 can be a date-time data item if the ASCENDING/DESCENDING KEY is defined as a date-time data item.

End of IBM Extension

The Data Division description of identifier-1 must contain an OCCURS clause with the INDEXED BY option. For Format-2, the Data Division description must also contain the KEY IS phrase in its OCCURS clause.