The SEARCH statement searches for a table element that satisfies a condition. It sets the value of the associated index to point to the table element.
1 – 1format_serial
The SEARCH statement searches for a table element that satisfies a condition. It sets the value of the associated index to point to the table element. Format 1 - SEARCH src-table [ VARYING pointr ] [ AT END stment ] { {WHEN cond stment} ... END-SEARCH } { } { {WHEN cond { stment } } } { { { NEXT SENTENCE } } ... }
1.1 – src-table
is a table identifier.
1.2 – pointr
is an index-name or the identifier of a data item described as USAGE INDEX, or an elementary numeric data item with no positions to the right of the assumed decimal point.
1.3 – cond
is any conditional expression.
1.4 – stment
is an imperative statement.
2 – 2format_binary
The SEARCH statement searches for a table element that satisfies a condition. It sets the value of the associated index to point to the table element. Format 2 - SEARCH ALL src-table [ AT END stment ] WHEN { elemnt { IS EQUAL TO } arg } { { IS = } } { cond-name } [ AND { elemnt { IS EQUAL TO } arg } ] ... [ { { IS = } } ] [ { cond-name } ] { stment [ END-SEARCH ] } { NEXT SENTENCE }
2.1 – src-table
is a table identifier.
2.2 – stment
is an imperative statement.
2.3 – elemnt
is an indexed data-name. It refers to the table element against which the argument is compared.
2.4 – arg
is the argument tested against each element (elemnt) in the search. It is an identifier, a literal, or an arithmetic expression.
2.5 – cond-name
is a condition-name.