Chapter 2. The IDENTIFICATION and ENVIRONMENT DIVISIONs

OBJECTIVES

To familiarize you with

  1. The basic structure of a COBOL program.

  2. General coding and format rules.

  3. IDENTIFICATION and ENVIRONMENT DIVISION entries.

BASIC STRUCTURE OF A COBOL PROGRAM

Coding a Source Program

Recall that COBOL programs consist of three or four divisions:

IDENTIFICATION DIVISION.
   ENVIRONMENT DIVISION (for file processing).
   DATA DIVISION.
   PROCEDURE DIVISION.

Only programs that process files must have an ENVIRONMENT DIVISION to name each file and assign it to a device. Batch programs always have an ENVIRONMENT DIVISION. Fully interactive programs, which ACCEPT input and DISPLAY output only, do not have an ENVIRONMENT DIVISION. Hybrid programs, which use ACCEPT and/or DISPLAYs for interactivity but also process files, have ENVIRONMENT DIVISION entries to define the files. Programs, then, consist of either three or four divisions, depending on whether they are batch or interactive.

In the next few chapters, we discuss each division in detail. After reading Chapters 24, you will be able to write elementary programs, both batch and interactive, using all the divisions of a COBOL program. We begin with some basic rules for coding programs.

Each COBOL instruction is coded on a single line using 80 characters per line, where specific entries must appear in designated columns or positions. Originally, each COBOL line was keypunched into a single 80-column punched card. Today, each COBOL line is typed or keyed using a keyboard ...

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.