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

Module 5: Data Division


FILE SECTION

  • The FILE SECTION is used to describe record structure of files used in program. The FILE SECTION contains the declaration of files and its fields. Each fields are described as data items using PIC clause. For example, if program is using EMPLOYEE file, then FILE SECTION must have been described with EMPLOYEE file and its fields (as data items) like EMP-ID, EMP-NAME, and EMP-SALARY etc.
  • This section is mandatory to specify for any program that uses files, typically batch programs
  • We must add an entry in FILE SECTION for each files used by program.
  • The basic structure of FILE SECTION is given below:-

    DATA DIVISION. FILE SECTION. [FD/SD-entries…]

  • The FILE SECTION must contain a level-indicator for each input and output file:-
    • FD entry:- Used for all files except sort/merge files
    • SD entry:- Used for sort or merge files
  • DATA DIVISION, FILE SECTION, FD/SD entry must start in Margin A of coding sheet. Other clauses under FD entry should start at Margin B of coding sheet
  • Detail description of FILE SECTION and FD is provided in Module 10: FILE PROCESSING <LINK>
  • At this point of time let’s just understand how the relation is established between FILE SECTION declaration, FILE-CONTROL paragraph and JCL file
    • Example:-
      JCL Code showing the program call and input file declaration:
      //DEPTJOB JOB A123,’STEVE’ //STEP1 EXEC PGM=MFPROG1 //INPUTFL DD DSN=DEPT1.EMP1.DATA1, // DISP=SHR
      COBOL Code showing use of FILE SECTION:-
      IDENTIFICATION DIVISION. PROGRAM-ID. MFPROG1. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT INPFILE ASSIGN TO INPUTFL ORGANIZATION IS SEQUENTIAL ACCESS IS SEQUENTIAL. DATA DIVISION. FILE SECTION. FD INPFILE RECORD CONTAINS 40 CHARACTERS. BLOCK CONTAINS 400 CHARACTERS. DATA RECORD IS EMP-REC. RECORDING MODE IS F. 01 EMP-REC. 02 EMP-ID PIC X(10). 02 EMP-NAME PIC X(20). 02 EMP-SALARY PIC 9(8)V99.
      Explanation:- As shown in JCL code we are calling COBOL program MFPROG1 and specified input file with DDNAME as ’INPUTFL‘. In COBOL code, since we are going to use the file INPUTFL, it is mandatory to specify file using SELECT statement. If you observe SELECT statement, the ‘INPFILE’ is logical name of file which will be used in COBOL program and ASSGIN TO clause associates the ‘INPFILE’ to JCL declared DDNAME ‘INPUTFL’. In FILE SECTION declaration we have to use the logical name i.e. ‘INPFILE’. FD entry is specified to describe the file ‘INPFILE’. ‘RECORD CONTAINS 40 CHARACTERS’ indicates that the file is 40 characters long. ‘DATA RECORD IS EMP-REC’ is used to specify that the record description is declared in EMP-REC data item. ‘RECORDING MODE IS F’ indicates the file is of fixed length
  • Note:- Detail description of FILE SECTION, FD clause will be provided in Module 10: FILE PROCESSING < LINK >






© copyright mainframebug.com
Privacy Policy