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 OPEN Statement



The OPEN statement initiates the processing of files. It also checks and/or writes labels.


    ___ Format 1--Sequential Files _________________________________________ 
   |                                                                        |
   | >>__OPEN_____________________________________________________________> |
   |                                                                        |
   |    <________________________________________________________           |
   |               <_________________________________________    |          |
   | >____ _INPUT____file-name-1__ ________________________ _|_ _|_______>< |
   |      |                       |          (1)           |   |            |
   |      |                       |_REVERSED_______________|   |            |
   |      |                       |                     (1)|   |            |
   |      |                       |_ ______ __NO REWIND____|   |            |
   |      |                         |_WITH_|                   |            |
   |      |         <______________________________________    |            |
   |      |_OUTPUT____file-name-2__ _____________________ _|___|            |
   |      |                        |_ ______ __NO REWIND_|     |            |
   |      |                          |_WITH_|                  |            |
   |      |      <_____________                                |            |
   |      |_I-O____file-name-3_|_______________________________|            |
   |      |         <_____________                             |            |
   |      |_EXTEND____file-name-4_|____________________________|            |
   |                                                                        |
   | Note:                                                                  |
   | (1)  Under OS/390, the REVERSED and WITH NO REWIND phrases are not     |
   |      valid for VSAM files.  Under AIX, OS/2, and Windows, the REVERSED |
   |      and WITH NO REWIND phases are treated as a comment.               |
   |                                                                        |
   |________________________________________________________________________|


    ___ Format 2--Indexed and Relative Files _______________________________ 
   |                                                                        |
   |           <_____________________________                               |
   |                      <_____________     |                              |
   | >>__OPEN____ _INPUT____file-name-1_|__ _|___________________________>< |
   |             |         <_____________  |                                |
   |             |_OUTPUT____file-name-2_|_|                                |
   |             |      <_____________     |                                |
   |             |_I-O____file-name-3_|____|                                |
   |             |         <_____________  |                                |
   |             |_EXTEND____file-name-4_|_|                                |
   |                                                                        |
   |________________________________________________________________________|

 X  ___ Format 3--Line Sequential Files (Workstation Only) _________________ 
 X |                                                                        |
 X |           <_____________________________                               |
 X |                      <_____________     |                              |
 X | >>__OPEN____ _INPUT____file-name-1_|__ _|___________________________>< |
 X |             |         <_____________  |                                |
 X |             |_OUTPUT____file-name-2_|_|                                |
 X |             |         <_____________  |                                |
 X |             |_EXTEND____file-name-4_|_|                                |
   |                                                                        |
   |________________________________________________________________________|
At least one of the phrases, INPUT, OUTPUT, I-O, or EXTEND, must be specified with the OPEN key word. The INPUT, OUTPUT, I-O, and EXTEND phrases can appear in any order.

INPUT
Permits opening the file for input operations.

OUTPUT
Permits opening the file for output operations. This phrase can be specified when the file is being created.

Note: Do not specify OUTPUT for files that:

  • Contain records. The file will be replaced by new data. If the OUTPUT phrase is specified for a file that already contains records, the data set must be defined as reusable and cannot have an alternate index. The records in the file will be replaced by the new data and any ALTERNATE RECORD KEY clause in the SELECT statement will be ignored.
    
    
  • Under OS/390, are defined with a DD dummy card. Unpredictable results can occur.
    
    

I-O
Permits opening the file for both input and output operations. The I-O phrase can be specified only for files assigned to direct access devices.


X >_Workstation_> Under AIX, OS/2, and Windows, the I-O phrase is not
X valid for line sequential files. <_Workstation_<

EXTEND
Permits opening the file for output operations.

The EXTEND phrase is only allowed for sequential access files if the
X new data is written in ascending sequence. As an IBM extension, the
X EXTEND phrase is allowed for files that specify the LINAGE clause.

Under OS/390, for QSAM files, do not specify the EXTEND phrase for a multiple file reel.

If you want to append to a file, but are unsure if the file exists, use the SELECT OPTIONAL clause before OPENing the file in EXTEND mode. The file will be created or appended to, depending on whether the file exists.

file-name-1, file-name-2, file-name-3, file-name-4
Designates a file upon which the OPEN statement is to operate. If more than one file is specified, the files need not have the same organization or access. Each file-name must be defined in an FD entry in the Data Division, and must not name a sort or merge file. The FD entry must be equivalent to the information supplied when the file was defined.

REVERSED
>_Host_> Under OS/390 and VM, the REVERSED phrase is only valid for sequential single reel files. It is not valid for VSAM files.

If the concept of reels has no meaning for the storage medium (for example, a direct access device), the REVERSED and NO REWIND phrases do not apply. <_Host_<

>_Workstation_> Under AIX, OS/2, and Windows, the REVERSED phrase is treated as a comment. <_Workstation_<

NO REWIND
>_Host_> Under OS/390 and VM, the NO REWIND phrase is only valid for sequential single reel files. It is not valid for VSAM files. <_Host_<

>_Workstation_> Under AIX, OS/2, and Windows, the NO REWIND phrase is treated as a comment. <_Workstation_<

Subtopics:



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.