SEARCH statement in COBOL most popularly use to search an internal table. You can give in WHEN statement conditions such as =, > and < in SEARCH. About SEARCH and its real use I have explained in my previous post differences of SEARCH and SEARCH ALL.
TIP: SEARCH in COBOL is serial search. So sorting of internal table is not required
At the same time, you can also give IF condition to filter input fields further. The below is sample code in COBOL shows how to give IF condition:
SET IX TO 1. SEARCH TABLE-ENTRY AT END MOVE 1 TO ORG-SUB WHEN ORD-RECIPIENT = TABLE-CODE (IX) SET ORG-SUB TO IX. MOVE ORD_CITY (IX) TO WS_CITY IF WS_CITY = '840' MOVE 'USA' TO INP_REC (1:3) END-IF END-SEARCH