Search

Sunday, March 3, 2013

Search Option of COBOL


Here is how to use search option in COBOL

COBOL Declaration:


01  A1-TABLE.                                               
    03   FILLER                     PIC 9(02) VALUE  01.    
    03   FILLER                     PIC 9(02) VALUE  02.    
    03   FILLER                     PIC 9(02) VALUE  03.    
    03   FILLER                     PIC 9(02) VALUE  40.    
    03   FILLER                     PIC 9(02) VALUE  50.    
                                                               
01 AE-TABLE REDEFINES A1-TABLE.                            
    03  IE-CODE        PIC 9(02)  OCCURS 5 TIMES           
                           INDEXED BY P1.                     

Code in procedure division : 

      SET P1 TO 1.                                
      SEARCH IE-CODE                            
          AT END SET NOT-IE-CODE TO TRUE        
      WHEN AE-CODE IS EQUAL TO IE-CODE (P1)   
          SET IE-CODE1 TO TRUE

No comments:

Post a Comment