Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 10: File processing


File processing in COBOL

  • In mainframe, files are different as compared to other systems and they are referred to as a dataset
  • COBOL allows us to process mainframe files These file can be QSAM/PS(Physical sequential) or any VSAM file
  • VSAM stands for Virtual Storage Access Methods and it can be of type: KSDS, ESDS or RRDS. For more details please refer VSAM tutorials <link to VSAM Tutorial> here <LINK>
  • Before going further into file handling concepts, first let’s understand few basic terminologies used in file handling:-
    • Field
    • Record
      • Logical record
      • Physical record (or block)
    • Record size
    • Block size
    • File
  • Let’s assume, there is one PS(Physical sequential) file ‘EMPDATA’ with below content
    File structure of same details in FILE SECTION as follow:-

    01 EMPDATA-RECORD. 05 EMP-ID PIC 9(04). 05 EMP-NAME PIC X(10). 05EMP-GRADE PIC A(01). 05EMP-SALARY PIC 9(05).

  • Field:- Field is smallest logically meaningful unit of information in a file. Each field contains a single data value. For example:- EMP-ID, EMP-NAME etc.
    • Key:- A subset of that fields in a record used to uniquely identify the record
      • Primary key (RECORD KEY): A key that uniquely identify a record. Example: EMP-ID which is unique in EMPDATA file.
      • Secondary key (ALTERNATE RECORD KEY): Other keys that may be used for search. Example: EMP-NAME, EMP-NAME + EMO-GRADE etc.
  • Record:- A record is collection of fields, Each line in file corresponds to a record. In EMPDATA file, (EMP-ID, EMP-NAME, EMP-GRADE, EMP-SALARY) forms a record.
    • Logical record:- At any point of time, COBOL program deals with a single record of a file which is referred to as logical record.
    • Physical record:- While reading from storage device, normally a single record is not read or written. Instead, it usually groups a number of consecutive records to form what is known as Physical record or block . The whole block is read into buffer from a disk and after required operation on this block is completed, it is written back to disk. This reduces input-output time required to handle file
  • Record size:- As mentioned above, record is a collection of fields and sum of all field size gives us Record size. For example, In EMPDATA file, record size if 20.
  • Block size:- A size of physical record is referred to as block size.
  • File:- A file is collection of records having same structure. For example, the ‘EMPDATA’ file consists of multiple employee records which are having same structure






© copyright mainframebug.com
Privacy Policy