SEARCH Statement - Format 2 - Binary Search

Read syntax diagramSkip visual syntax diagram
SEARCH Statement - Format 2 - Binary Search

>>-SEARCH ALL--identifier-1------------------------------------->

>--+-------------------------------------+---------------------->
   '-+----+--END--imperative-statement-1-'   
     '-AT-'                                  

>--WHEN--+-| equal phrase 1 |-+--------------------------------->
         '-condition-name-1---'   

   .---------------------------------.   
   V                                 |   
>----+-----------------------------+-+-------------------------->
     '-AND--+-| equal phrase 2 |-+-'     
            '-condition-name-2---'       

>--+-imperative-statement-2-+--+------------+------------------><
   '-+---------------+------'  '-END-SEARCH-'   
     '-NEXT SENTENCE-'                          

equal phrase 1

|--data-name-1--+----+--+-EQUAL--+----+-+----------------------->
                '-IS-'  |        '-TO-' |   
                        '-=-------------'   

>--+-identifier-3------------+----------------------------------|
   +-literal-1---------------+   
   '-arithmetic-expression-1-'   

equal phrase 2

|--data-name-2--+----+--+-EQUAL--+----+-+----------------------->
                '-IS-'  |        '-TO-' |   
                        '-=-------------'   

>--+-identifier-4------------+----------------------------------|
   +-literal-2---------------+   
   '-arithmetic-expression-2-'   

Related Information:
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 multi-dimensional table. In this case, the data description entry must specify an INDEXED BY phrase for each dimension of the table.
IBM Extension

Identifier-1 can specify a table containing floating-point data items, a table containing DBCS items, or a table containing date-time items.

End of IBM Extension

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

The Data Division description of identifier-1 must contain an OCCURS clause with the INDEXED BY phrase.

SEARCH statement execution modifies only the value in the index-name associated with identifier-1 and, if present, of index-name-1 or identifier-2 (see VARYING Phrase). Therefore, to search an entire two- to seven-dimensional table, it is necessary to execute a SEARCH statement for each dimension. Before each execution, SET statements must be executed to reinitialize the associated index-names.