Chapter 2. The IDENTIFICATION and ENVIRONMENT DIVISIONs
To familiarize you with
The basic structure of a COBOL program.
General coding and format rules.
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
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 2–4, 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 ...