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

Module 10: File processing


FILE HANDLING

Steps for file handling in COBOL:-

  • Step 1: File allocation
    • Files which we want to use in our program should be declared in FILE-CONTROL paragraph of NPUT-OUTPUT SECTION under ENVIRONMENT DIVISION.
    • Here, we do mapping of file to JCL DDNAME
    • “File allocation” step is explained in detail here
  • Step 2: File Definition
    • The structure of file and its characteristics are defined in the FILE SECTION of DATA DIVISION
    • “File Definition” step is explained in detail here
  • Step 3: OPEN file
    • Once file allocation and its structure is defined, we are good to use file. But before we begin any processing, file should be opened and connection is established using OPEN statement.
    • The “mode” used in OPEN statements decides what kind of processing can be done on file and from which point of file, processing can be started.
    • We will study “mode” later in this module
    • “OPEN file” step is explained in detail here
  • Step 4: Processing of file
    • Once file is opened, files can be processed as per our requirement, using the I-O statement provided by COBOL (READ, WRITE, REWRITE, DELETE, START)
    • “Processing of file” step is explained in detail here
  • Step 5: CLOSE file
    • Once all required processing is done, we can close file to disconnect it from program
    • “CLOSE file” step is explained in detail here

Each of them is explained in detail in upcoming section





© copyright mainframebug.com
Privacy Policy