File handling verbs are used to perform various operations on files. Following are the file handling verbs −. Open. Read. Write.
Rewrite. Delete. Start. CloseOpen VerbOpen is the first file operation that must be performed. If Open is successful, then only further operations are possible on a file. Only after opening a file, the variables in the file structure are available for processing. FILE STATUS variable is updated after each file operation.
DataAccess can read indexed Cobol data files produced by these Cobols: MF, FSC, RM, ACU, and sequential Cobol files produced by any Cobol program. Open' command to open the data file itself and Data-Viewer will guess the record layout for you. Edit Record Layout. You can edit record layout - move, split, merge fields. When you are done, click the Apply button and the new layout will be used to re-read the data file.
SyntaxOPEN 'mode' file-name.Here, file-name is string literal, which you will use to name your file. A file can be opened in the following modes − Sr.No.Mode & Description1InputInput mode is used for existing files. In this mode, we can only read the file, no other operations are allowed on the file.2OutputOutput mode is used to insert records in files.
If a sequential file is used and the file is holding some records, then the existing records will be deleted first and then new records will be inserted in the file. It will not happen so in case of an indexed file or a relative file.3ExtendExtend mode is used to append records in a sequential file. In this mode, records are inserted at the end. If file access mode is Random or Dynamic, then extend mode cannot be used.4I-OInput-Output mode is used to read and rewrite the records of a file.Read VerbRead verb is used to read the file records. The function of read is to fetch records from a file.
At each read verb, only one record can be read into the file structure. To perform a read operation, open the file in INPUT or I-O mode. At each read statement, the file pointer is incremented and hence the successive records are read. SyntaxFollowing is the syntax to read the records when the file access mode is sequential −READ file-name NEXT RECORD INTO ws-file-structureAT END DISPLAY 'End of File'NOT AT END DISPLAY 'Record Details:' ws-file-structureEND-READ.Following are the parameters used −.NEXT RECORD is optional and is specified when an indexed sequential file is being read sequentially.INTO clause is optional.
Ws-file-structure is defined in the WorkingStorage Section to get the values from the READ statement.AT END condition becomes True when the end of file is reached.Example − The following example reads an existing file using line sequential organization. Free pinoy teleserye. This program can be compiled and executed using Live Demo option where it will display all the records present in the file.IDENTIFICATION DIVISION.PROGRAM-ID.