FILE is a logical representation data stored in memory location.
FILEs used to store the data permanently in a structured way.
FILE contains RECORDs which are logically dividing the FILE data.
Each RECORD contains the FIELDs which is typically data items or identifier in the RECORD layout.
FILEs are usually stored in DISKS/TAPES in mainframe environment.
Maximum 255 files used in COBOL program.
ORGANIZATION Clause is used to define a file.
Hierarchy of file:
In the hierarchical manner, file can be defined as a set of records which are stored as a instances/ occurrences.
Records can be defined as a combination of fields which are defined a sequence.
Fields can be defined as a collection of information which needs to be stored.
Types of Files:
FILEs divided into three types based on how the data stored and how the data accessed from memory.
The three types are
- Sequential files (data is entered in sequential order)
- Indexed files (data is entered based on key sequential order)
- Relative files ( data is entered based on RRN - Relative Record Number)
- Sequential file records are read from top to bottom but bottom to top is not possible.
- Specific record reading is not possible in sequential files.
- Sequential files are also called as flat files, QSAM files, non-VSAM files.
- Retrieving of data is faster in indexed files.
- Random accessing of data is done in indexed files based on key ( ex: bank a/c no).
- Data accessing is faster in indexed files.
- Data arranged in sorted order based on key.
- Duplicate records are not allowed in indexed files.
- Specific record reading is possible in indexed files.
- Indexed file are cannot be store on tape. They are store in disk.
- Key columns are cannot be updated since key is identifier.
- Specific record deletion and reading is possible in indexed files.
- Indexed files are also called as VSAM files, KSDS files.
- Based on relative record number (RRN) data can be stored in relative files.
- RRN is not used defined. That is system defined key.
- Retrieving of data is very difficult in relative files.
- Relative files are also called as RRDS (relative record data set files).
Disadvantages of relative files:
- Retrieving of RRN is practically impossible.
- Whenever we delete any data in a relative files unused storage space is created. Memory storage space is wasted.
COBOL Perform Varying COBOL File Processing Cycle