Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

6.2.26.3 OPEN Statement Notes



  1. The successful execution of an OPEN statement determines the availability of the file and results in that file being in open mode. A file is available if it is physically present and is recognized by the input-output control system. Table 44 shows the results of opening available and unavailable files. For more information regarding file availability, see the IBM COBOL Programming Guide for your platform.
    
    
    
    
     Table 44. Availability of a File                                   
     OPENed As   File is Available   File is Unavailable                
     INPUT       Normal open         Open is unsuccessful               
     INPUT     
     (optional 
     file)     
     Normal open       
                       
                       
     Normal open; the first read causes 
     the at end condition or the        
     invalid key condition              
     I-O         Normal open         Open is unsuccessful               
     I-O       
     (optional 
     file)     
     Normal open       
                       
                       
     Open causes the file to be created 
                                        
                                        
     OUTPUT    
               
               
     Normal open; the  
     file contains no  
     records           
     Open causes the file to be created 
                                        
                                        
     EXTEND      Normal open         Open is unsuccessful               
     EXTEND    
     (optional 
     file)     
     Normal open       
                       
                       
     Open causes the file to be created 
                                        
                                        
    
    

    
    
  2. The successful execution of the OPEN statement makes the associated record area available to the program; it does not obtain or release the first data record.
    
    
  3. An OPEN statement must be successfully executed prior to the execution of any of the permissible input-output statements, except a SORT or MERGE statement with the USING or GIVING phrase. Table 45 shows the permissible input-output statements for sequential files. An 'X' indicates that the specified statement can be used with the open mode given at the top of the column.
    
    
    
    
     Table 45. Permissible Statements for Sequential Files                     
                
      Statement 
                
                               Open Mode                          
         Input           Output           I-O           Extend    
        READ            X                 X         
        WRITE             X                 X      
       REWRITE              X         
    
    

    
           Table 46 shows the permissible statements for indexed and relative
           files.  An 'X' indicates that the specified statement, used in the
           access mode given for that row, can be used with the OPEN mode given
           at the top of the column.
    

    
    
     Table 46. Permissible Statements for Indexed and Relative Files           
        File    
       Access   
        Mode    
                
      Statement 
                
                        Open Mode                    
       Input       Output         I-O        Extend  
     Sequential 
                
                
                
                
                
                
                
                
     READ             X              X       
     WRITE               X             X     
     REWRITE               X       
     START            X              X       
     DELETE                X       
     Random     
                
                
                
                
                
                
                
                
     READ             X              X       
     WRITE               X            X       
     REWRITE               X       
     START              
     DELETE                X       
     Dynamic    
                
                
                
                
                
                
                
                
     READ             X              X       
     WRITE               X            X       
     REWRITE               X       
     START            X              X       
     DELETE                X       
    
    

    
    
    X Table 47 shows the permissible input-output statements for line
    X sequential files. An 'X' indicates that the specified statement can
    X be used with the open mode given at the top of the column.

    
    
    RevisionX  Table 47. Permissible Statements for Line Sequential Files (Workstation   
    RevisionX            Only)                                                           
    RevisionX             
    RevisionX   Statement 
    RevisionX             
    RevisionX                            Open Mode                          
    RevisionX ‘
    RevisionX      Input     
    RevisionX ‘
    RevisionX      Output    
    RevisionX ‘
    RevisionX       I-O      
    RevisionX ‘
    RevisionX     Extend    
    RevisionX     READ     RevisionX        X        RevisionX                 RevisionX                 RevisionX               
    RevisionX     WRITE    RevisionX                 RevisionX        X        RevisionX                 RevisionX        X      
    RevisionX    REWRITE   RevisionX                 RevisionX                 RevisionX                 RevisionX               
    
    

    
    
  4. X A file can be opened for INPUT, OUTPUT, I-O, or EXTEND (sequential and
    X line sequential files only) in the same program. After the first OPEN statement execution for a given file, each subsequent OPEN statement execution must be preceded by a successful CLOSE file statement execution without the REEL or UNIT phrase (for QSAM files only), or the LOCK phrase.
    
    
  5. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the associated status key is updated when the OPEN statement is executed.
    
    
  6. If an OPEN statement is issued for a file already in the open status, the EXCEPTION/ERROR procedure (if specified) for this file is executed.


Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.