COBOL by Example: Divisions
Exploring the detailed purpose and organization of each COBOL division including sections within divisions, understanding CONFIGURATION SECTION and INPUT-OUTPUT SECTION in the ENVIRONMENT DIVISION, working with WORKING-STORAGE SECTION and FILE SECTION in the DATA DIVISION, and learning how data must be defined before procedural code execution.
Code
IDENTIFICATION DIVISION.
PROGRAM-ID. DIVISIONS-DEMO.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 MESSAGE-VAR PIC X(20) VALUE "Divisions Explained".
PROCEDURE DIVISION.
DISPLAY MESSAGE-VAR.
STOP RUN.Explanation
Each division in COBOL is further organized into sections and paragraphs. The ENVIRONMENT DIVISION often contains the CONFIGURATION SECTION (describing the computer) and the INPUT-OUTPUT SECTION (mapping files). This separation allows the same COBOL program to be ported to different hardware simply by changing the Environment Division settings.
The DATA DIVISION is the heart of COBOL's data processing capabilities. It typically includes the FILE SECTION (describing file layouts) and the WORKING-STORAGE SECTION. The Working-Storage Section is used for variables that are internal to the program—counters, flags, and temporary storage—as opposed to data read directly from a file.
In this example, we define a variable MESSAGE-VAR in the Working-Storage Section. Unlike modern languages where variables can be declared anywhere, COBOL requires all data to be defined before any procedural code is written. This makes the data structure of the program immediately visible and easy to audit.

