Before you can read from or write to a file that is stored on a diskette device, you must first open the file. You use the Format 1 OPEN statement to open the file. To read from a file stored on a diskette device, you must open it in INPUT mode. To write to a file stored on a diskette device, you must open it in OUTPUT or EXTEND mode. A file stored on a diskette device cannot be opened in I-O mode. The following are examples of the OPEN statement.
OPEN INPUT sequential-file-name. OPEN OUTPUT sequential-file-name. OPEN EXTEND sequential-file-name.
You use the Format 1 READ statement to read a record from a sequential file stored on a diskette device. The READ statement makes the next logical record from the file available to your ILE COBOL program.
When reading records from the input file, the record length you specify in your COBOL program should be the same as the record length found on the data file label of the diskette. If the record length specified in your COBOL program is not equal to the length of the records in the data file, the records are padded or truncated to the length specified in the program.
For a sequential multivolume file, if the end of volume is recognized during processing of the READ statement and the logical end of file has not been reached, the following actions are taken in the order listed:
Your ILE COBOL program will receive no indication that the above actions have occurred during the read operation.
You use the Format 1 WRITE statement to write a record to a sequential file stored on a diskette device.
When writing records to the output file, you must specify the record length in your COBOL program. When the record length specified in the program exceeds that for which the diskette is formatted, a diagnostic message is sent to your program, and the records are truncated. The maximum record lengths supported for diskette devices, by exchange type, are as follows:
For a sequential multivolume file, if the end of volume is recognized during processing of the WRITE statement, the following actions are taken in the order listed:
No indication that an end of volume condition has occurred is returned to your COBOL program.
When you have finished using a file stored on a diskette device, you must close it. Use the Format 1 CLOSE statement to close the file. Once you close the file, it cannot be processed again until it is opened again.
CLOSE sequential-file-name.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.