Lesson 3: Identification Division and Environment Division
Learning goals
After studying this lesson, learners should be able to:
- Read instruction-format notation used in COBOL references.
- Write the basic syntax of the Identification Division.
- Explain the purpose of the Environment Division.
- Use
FILE-CONTROLandSELECT ... ASSIGN TOfor file assignments.
Reading COBOL syntax formats
COBOL references often use special formatting conventions:
| Convention | Meaning |
|---|---|
| Uppercase words | COBOL reserved words. |
| Lowercase or placeholder words | Programmer-supplied values. |
Brackets [ ] | Optional part. |
Braces { } | Placeholder or required choice, depending on reference style. |
Ellipsis ... | More entries of the same kind may follow. |
| Punctuation | If shown in the syntax, it must be typed. |
Example:
PROGRAM-ID. program-name.
This means PROGRAM-ID. is typed as shown, while program-name is replaced by the chosen program name.
Identification Division
The Identification Division names and identifies the program. In many beginner programs, the only required paragraph is PROGRAM-ID.
Basic form:
IDENTIFICATION DIVISION.
PROGRAM-ID. program-name.
Older examples may include documentation paragraphs such as AUTHOR, DATE-WRITTEN, or SECURITY, but student-facing study material should avoid personal or institutional identifiers.
Generic example:
IDENTIFICATION DIVISION.
PROGRAM-ID. SALES-REPORT.
Environment Division
The Environment Division describes external resources used by the program, especially files and machine-related details.
Common parts:
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. computer-name.
OBJECT-COMPUTER. computer-name.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT file-name ASSIGN TO "external-file-name".
In many simple modern learning examples, the CONFIGURATION SECTION may be omitted unless the compiler requires it. The INPUT-OUTPUT SECTION is important when the program reads or writes files.
Configuration Section
The Configuration Section may document the source and object computers:
SOURCE-COMPUTER- the machine used to compile the program.OBJECT-COMPUTER- the machine used to run the program.SPECIAL-NAMES- optional special device or symbolic-name definitions.
Generic example:
CONFIGURATION SECTION.
SOURCE-COMPUTER. GENERIC-PC.
OBJECT-COMPUTER. GENERIC-PC.
Input-Output Section
The Input-Output Section connects COBOL file names to external files or devices.
The most common paragraph is FILE-CONTROL.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT STUDENT-FILE
ASSIGN TO "STUDENT.DAT".
SELECT REPORT-FILE
ASSIGN TO "REPORT.TXT".
Internal file name vs. external file name
A COBOL program often uses two names for a file:
| Name type | Example | Purpose |
|---|---|---|
| Internal file name | STUDENT-FILE | Name used inside the COBOL program. |
| External file name | "STUDENT.DAT" | Actual file or device known to the operating system. |
Tips for file names
Use meaningful names that describe the file's role:
SALES-INPUTSALES-REPORTSTUDENT-FILEPAYROLL-OUTPUT
Avoid names that are too vague, personal, or unrelated to the program.