Chapter 4. Coding Complete COBOL Programs: The PROCEDURE DIVISION

OBJECTIVES

To familiarize you with the methods used to

  1. Access input and output files.

  2. Read data from an input file.

  3. Perform simple move operations.

  4. Write information onto an output file.

  5. Accomplish end-of-job operations.

  6. Execute paragraphs from a main module and then return control to that main module.

A REVIEW OF THE FIRST THREE DIVISIONS

Thus far, three of the four divisions of a COBOL program have been discussed in detail. The PROCEDURE DIVISION, the last to be studied, is unquestionably the most significant. The PROCEDURE DIVISION contains all the instructions that the computer will execute.

The IDENTIFICATION DIVISION supplies information about the nature of the program. The ENVIRONMENT DIVISION, used with batch programs that process files, supplies information on the specific equipment and file types that will be used. The FILE SECTION of the DATA DIVISION defines, in detail, the input and output records for batch programs operating on files. The WORKING-STORAGE SECTION of the DATA DIVISION is utilized to store data used in interactive processing—keyed input and displayed output. It is also used for defining any areas not part of input and output files but nonetheless required for processing; these include work areas such as counters and end-of-file indicators. The instructions in the PROCEDURE DIVISION, however, actually read and process the data and produce the output information. Since all instructions are written ...

Get COBOL for the 21st Century now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.