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

Module 10: File processing


FILE DEFINITION : Step 2 of File Handling

  • The structure of file and its characteristics are defined in FILE SECTION of DATA DIVISION
  • File Description(FD) entry is coded for files using its syntax shown below:-
    FD basic syntax:-

    FD file-name [RECORDING MODE IS {F/V}] [RECORD CONTAINS integer-1 [TO integer-2]] [BLOCK CONTAINS integer-3 [TO integer-4] {CHARACTERS/RECORDS}] [LABEL {RECORD IS/RECORDS ARE} {STANDARD/OMITTED}] [DATA {RECORD IS/RECORDS ARE} FILE-RECORD-1 [, FILE-RECORD-2]… ] 01 FILE-RECORD-1 PIC X(recordsize).

  • While coding, FD entry clause may appear in Margin A, all other clauses must appear in Margin B. All clauses are optional in FD entry and if coded can appear in any order.
  • Let’s understand each part of above give syntax:-
    • FD file-name:- This clause is used to specify that we are describing characteristics of “file-name” file. file-name is logical file-name.
    • RECORDING MODE IS
      • Specifies format of the physical records in PS/QSA, file. This clause is ignored for VSAM file.
      • It can be coded ‘F’ or ‘V’. ‘F’ is coded for fixed length record files and ‘V’ is coded for variable length record files
      • If Recording mode is not coded for PS/QSAM file for PS/QSAM file, then compiler itself determines recording mode on certain and certain conditions
    • RECORD CONTAINS
      • Optional block [TO integer-2] is coded only for variable-length record files
      • This clause is used to specify the length of record (Record size) in bytes. “RECORD CONTAINS 30 CHARACTERS” means the record size is 30
    • BLOCK CONTIANS
      • Optional block [TO integer-4] is coded only for variable-length record files
      • It is used to specify the physical record size (or block size).
      • We can specify BLOCK in terms of either ‘number of logical records’ OR ‘number of characters’.
      • It is suggested to code BLCOK CONTAINS 0 RECORDS so that system itself can decide the optimum size of file based on type of storage system
      • This clause is ignored for VSAM files
      • Benefits of blocking:-
        • Blocking saves input-output time as move number of records are read into main memory buffer and then processing done on those loaded records instead of direct read-write on disk for each record.
        • Blocking saves storage space as Inter Record Gap (IRG) is avoided and gap exist only between blocks
    • LABEL RECORD(S)
      • Specifies if standard header or trailer labels are present in files
      • STANDARD is coded mostly for disk and tape files
      • OMITTED is coded for printer files
      • It was mandatory to specify this clause in ANSI 74. It was made optional in COBOL 85
    • DATA RECORD(S)
      • It is used to specify the name of records associated with the file.
      • In our syntax, data record ‘FILE-RECORD-1’ is coded and declaration of ‘FILE-RECORD-1’ is done immediately after FD entry






© copyright mainframebug.com
Privacy Policy