Files and Types of Files

Files are logical representation of large volumes of data in the form of database objects that are stored in a structured way permanently in a memory location. The maximum number files that can be used in a COBOL Program are 255 files. There are three types of files in COBOL :

  • Sequential Files
  • Indexed Files
  • Relative Files

Hierarchy of a File

  • Files contain Records that logical divide the File Data
  • Records contain a set of information which are further divided into Fields.
  • Each Field is further subdivided into characters
  • Finally , a set of characters combined together constitutes an information 

The Files , Records and Fields are identified by File Name , Record Name and Field Name respectively. These are user defined names and must be formed between 1-30 alphanumeric characters.

Working with Files

In order to work with Files , we need to first declare the File and only then we can head onto processing of the File.

Declaration of a File

For declaring a File , File Name and Device name is specified. The Data Structure is also specified as a requirement. The Declaration of Files is done in the Environment or Data Division.

Processing of a File

Entering of records , reading of the records , deletion of records , updating of the records , retrieving of records all fall under the Processing of a File. The Processing of File is done under Procedure Division. 

File Handling in COBOL

File Handling is an important feature in COBOL Language. Only structured data in the form of files are handled. Files consist of Records and Fields, which contain information.

Similar Reads

Field

A field can be defined as a collection of information that is required to be given a structure. Each field stores data about an element. A single element represents a particular field. For example, each of the elements –  Employee ID, Name, Grade, and Salary represents a particular field....

Record

Record can be defined as a collection of fields. One or more fields together form a Record. The Records may be of fixed or variable length. For example , Employee ID , Name , Grade and Salary together form one record....

Files and Types of Files

Files are logical representation of large volumes of data in the form of database objects that are stored in a structured way permanently in a memory location. The maximum number files that can be used in a COBOL Program are 255 files. There are three types of files in COBOL :...

Sample COBOL Code for Declaration of a File

Let us take an Employee Dataset as an example. The dataset is as follows :...

Sample COBOL Code for Processing of a File

...

Contact Us