RAMESH KRISHNA REDDY mainframe discussion forum - cobol, db2,cics,jcl,file-aid,changeman,interview questions
Online Tutorials   | PREV  | TOP  | NEXT



DRONA SERIES
COBOL STUDY MATERIAL


SEARCH .. WHEN.

Author : Vasanta T.



   
 

SEARCH.. WHEN..




SEARCH.. AT END The SEARCH statement is used to locate or search for an element in a one-dimensional Table. SEARCH Table – name [AT END imperative statements] WHEN condition 1[imperative statements] [END SEARCH] The following rules apply to the SEARCH statement. 1. The SEARCH statement can be applied to a Table only if it is indexed using INDEXED BY phrase. 2. Before using the SEARCH statement, the index must be initialized using a SET statement. 3. If the SEARCH statement terminates without finding the particular element in the Table, then the index has an unpredictable value. 4. The SEARCH statement cannot be used to find multiple matches. 5. The SEARCH statement does a sequential or serial search of the table. 6. If search reaches end of array then at end statement will be executed. SEARCH Example : 01 WT-FIELDS. 05 WT-CODE-CTRL OCCURS 100 TIMES INDEXED BY WT-CODE-CTRL-INDEX. 10 WT-CODE-VALUE PIC X(03). 10 WT-CODE-DESC PIC X(03). SET WT-CODE-CTRL-INDEX TO 1. SEARCH WT-CODE-CTRL AT END DISPLAY “SEARCH ELEMENET NOT FOUND IN TABLE WT-CODE-CTRL” WHEN WT-BILLER-CODE (WT-CODE-CTRL-INDEX) = “121” DISPLAY WT-CODE-DESC (WT-CODE-CTRL-INDEX) END-SEARCH.
    

NEXT CHAPTER TOPIC : COBOL SEARCH ALL


                                   



Previous chapter in COBOL tutorial Starting of COBOL tutorial Next chapter in COBOL tutorial


Visit COBOL books section in this site for good books




Home | Donations | Online Tutorials | Books | Entertainment | Contactme | privacy |  sql tutorial | jcl interview questions | JCL Tutorial | JCL Tutorial - chapter1 | JCL Tutorial - chapter2 | JCL Tutorial - chapter3 | JCL Tutorial - chapter4 | JCL Tutorial - chapter5 | JCL Tutorial - chapter6 | JCL Tutorial - chapter7 | JCL Tutorial - chapter8 | JCL Tutorial - chapter9 | JCL Tutorial - chapter10 | JCL Tutorial - chapter11