The OPEN statement initiates the processing of files. It also checks or writes labels, or both.
Format 1: OPEN statement for sequential files >>-OPEN---------------------------------------------------------> .---------------------------------------------------------. | .------------------------------------------. | V V | | >----+-INPUT----file-name-1--+-------------------------+-+-+-+->< | | (1) | | | +-REVERSED----------------+ | | | (1) | | | '-+------+--NO REWIND-----' | | '-WITH-' | | .--------------------------------------. | | V | | +-OUTPUT----file-name-2--+---------------------+-+----+ | '-+------+--NO REWIND-' | | '-WITH-' | | .-------------. | | V | | +-I-O----file-name-3-+--------------------------------+ | .-------------. | | V | | '-EXTEND----file-name-4-+-----------------------------'
Format 2: OPEN statement for indexed and relative files .-----------------------------. | .-------------. | V V | | >>-OPEN----+-INPUT----file-name-1-+--+-+----------------------->< | .-------------. | | V | | +-OUTPUT----file-name-2-+-+ | .-------------. | | V | | +-I-O----file-name-3-+----+ | .-------------. | | V | | '-EXTEND----file-name-4-+-'
Format 3: OPEN statement for line-sequential files .-----------------------------. | .-------------. | V V | | >>-OPEN----+-INPUT----file-name-1-+--+-+----------------------->< | .-------------. | | V | | +-OUTPUT----file-name-2-+-+ | .-------------. | | V | | '-EXTEND----file-name-4-+-'
The phrases INPUT, OUTPUT, I-O, and EXTEND specify the mode to be used for opening the file. At least one of the phrases INPUT, OUTPUT, I-O, or EXTEND must be specified with the OPEN keyword. The INPUT, OUTPUT, I-O, and EXTEND phrases can appear in any order.
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 and either the SdU or SFS file system is used, the file will be deleted and recreated.
The I-O phrase is not valid for line-sequential files.
The EXTEND phrase is allowed for sequential access files only if the new data is written in ascending sequence. The EXTEND phrase is allowed for files that specify the LINAGE clause.
For information on file sizes, see Compiler limits.