IDENTIFICATION and ENVIRONMENT

The first two divisions are the ones a reader skips and a compiler mostly ignores: a name, a few paragraphs about who wrote the program and on what it was meant to run, and the one paragraph that can change the meaning of a line of source. This lesson takes them in order.

PROGRAM-ID

PROGRAM-ID is the paragraph that names the program, and it is the reason the identification division is required. The name is a COBOL word: letters, digits and hyphens, at least one letter, no spaces, and it ends with a period. Older compilers stop at 30 characters, and cobc accepts far more, so a short name is the safe one.

The name is not the file name. The compiler takes the source from the file it was given and the program name from the paragraph, and the two need not agree:

IDENTIFICATION DIVISION. PROGRAM-ID. SOMETHING-ELSE. PROCEDURE DIVISION. DISPLAY "program name differs from file name". STOP RUN.

cobc -x -free -Wall -o mm mm.cob
./mm

program name differs from file name

A name that is nothing but digits is not a name: in that position the compiler expects a word or a quoted literal, so it reads a number and stops.

IDENTIFICATION DIVISION. PROGRAM-ID. 123. PROCEDURE DIVISION. DISPLAY "one". STOP RUN.

cobc -x -free -Wall -o pid pid.cob

pid.cob:2: error: syntax error, unexpected Identifier, expecting Literal or program name
1 | IDENTIFICATION DIVISION.
2 > PROGRAM-ID. 123.
3 | PROCEDURE DIVISION.
4 | DISPLAY "one".

The program name is also the name a CALL uses to reach the program, which is why it has to be a word and not a sentence: a caller writes it, and a linker looks it up. The lesson on paragraphs and scope and the one on subprograms both come back to it.

The documentation paragraphs

Under PROGRAM-ID a program may carry a handful of paragraphs that describe the source itself: AUTHOR, DATE-WRITTEN, DATE-COMPILED, INSTALLATION and SECURITY. They hold text, they change nothing in the object program, and GnuCOBOL calls them obsolete:

IDENTIFICATION DIVISION. PROGRAM-ID. DOC. AUTHOR. Arthur Isaev. DATE-WRITTEN. 2026-11-18. DATE-COMPILED. today. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-370. OBJECT-COMPUTER. IBM-370. PROCEDURE DIVISION. DISPLAY "documented". STOP RUN.

cobc -x -free -Wall -o doc doc.cob
./doc

doc.cob:2: warning: AUTHOR is obsolete in GnuCOBOL [-Wobsolete]
1 | IDENTIFICATION DIVISION.
2 > PROGRAM-ID. DOC.
3 | AUTHOR. Arthur Isaev.
4 | DATE-WRITTEN. 2026-11-18.
doc.cob:3: warning: DATE-WRITTEN is obsolete in GnuCOBOL [-Wobsolete]
1 | IDENTIFICATION DIVISION.
2 | PROGRAM-ID. DOC.
3 > AUTHOR. Arthur Isaev.
4 | DATE-WRITTEN. 2026-11-18.
5 | DATE-COMPILED. today.
doc.cob:4: warning: DATE-COMPILED is obsolete in GnuCOBOL [-Wobsolete]
2 | PROGRAM-ID. DOC.
3 | AUTHOR. Arthur Isaev.
4 > DATE-WRITTEN. 2026-11-18.
5 | DATE-COMPILED. today.
6 |
documented

Each warning points one line above the paragraph it names, which is worth knowing before you look for a mistake in the line the snippet marks. The program itself builds and runs: obsolete means the standard has retired the paragraph, not that the compiler refuses it.

The advice that follows is the same for the other documentation paragraphs: a name, a date and an author belong in the file header of your version control, where they can be updated, and not in a paragraph that every build has to warn about.

SOURCE-COMPUTER and OBJECT-COMPUTER

The configuration section opens with two paragraphs that used to matter a great deal on a mainframe and matter not at all here: SOURCE-COMPUTER names the machine the program was written on and OBJECT-COMPUTER the machine it is meant for. A 1970s compiler read the second one to choose its character set, its collating order and its word size; a modern one compiles for the machine it is running on and treats both as comments.

They are still written in old sources, so read them as history: an OBJECT-COMPUTER. IBM-370. above a program that runs on x86-64 is a record of where the program came from, not a claim about where it runs.

SPECIAL-NAMES

The third paragraph of the configuration section is the one the compiler acts on. SPECIAL-NAMES renames things the language fixes: the decimal point, the currency sign, the collating alphabet, the switches a job control language sets. The decimal point is the smallest example with a visible effect, and it is a real one in European shops.

Without the paragraph, a picture uses a period for the decimal point and so does a numeric literal:

IDENTIFICATION DIVISION. PROGRAM-ID. DOT. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9.99 VALUE 0. PROCEDURE DIVISION. MOVE 1.25 TO AMOUNT. DISPLAY AMOUNT. STOP RUN.

cobc -x -free -Wall -o dot dot.cob
./dot

1.25

With DECIMAL-POINT IS COMMA the two characters swap roles: the picture is written with a comma and so is the literal, and the output follows.

IDENTIFICATION DIVISION. PROGRAM-ID. COMMA. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9,99 VALUE 0. PROCEDURE DIVISION. MOVE 1,25 TO AMOUNT. DISPLAY AMOUNT. STOP RUN.

cobc -x -free -Wall -o comma comma.cob
./comma

1,25

The setting is global to the program, so a literal written the old way is not read as a number any more. The period ends the sentence, and the words after it have nowhere to go:

IDENTIFICATION DIVISION. PROGRAM-ID. WRONGDOT. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9,99 VALUE 0. PROCEDURE DIVISION. MOVE 1.25 TO AMOUNT. DISPLAY AMOUNT. STOP RUN.

cobc -x -free -Wall -o wrongdot wrongdot.cob

wrongdot.cob:12: error: syntax error, unexpected ., expecting TO
10 |
11 | PROCEDURE DIVISION.
12 > MOVE 1.25 TO AMOUNT.
13 | DISPLAY AMOUNT.
14 | STOP RUN.

The lesson on ASCII, EBCDIC and UTF-8 comes back to this paragraph for the alphabet and the code page; the lesson on edited numeric output uses the currency sign for printed amounts.

Exercises

  1. Build the documented program with and without -Wall. Which of the three warnings disappear, and why does the program still print its line?
  2. Change PROGRAM-ID. COMMA. to PROGRAM-ID. DECIMAL-POINT. and build. Which paragraph does the compiler read the name as, and what does it say?
  3. Add DECIMAL-POINT IS COMMA to the dot program and correct every line it breaks. How many lines change, and what does the program print afterwards?

Questions

A new set of questions in a new order every time. Choose one answer for each, then check.

  1. Which paragraph names a COBOL program?

    Answer

    PROGRAM-ID

    PROGRAM-ID is the only paragraph the identification division needs, and a source without it is refused at its first line.

  2. What does SOURCE-COMPUTER do in a GnuCOBOL build?

    Answer

    Nothing: it is documentation about the machine the program came from

    Modern compilers build for the machine they run on; on a mainframe the paragraph picked a character set, which is why old sources still carry it.

  3. In which section is SPECIAL-NAMES written?

    Answer

    CONFIGURATION SECTION of the ENVIRONMENT DIVISION

    The configuration section holds the three paragraphs about the machine: SOURCE-COMPUTER, OBJECT-COMPUTER and SPECIAL-NAMES.

  4. What does DECIMAL-POINT IS COMMA change?

    Answer

    The character that acts as the decimal point in pictures and literals

    It swaps the roles of the comma and the period, so pictures and numeric literals are written with a comma and print with one.

  5. What does this program print? IDENTIFICATION DIVISION. PROGRAM-ID. Q1. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9.99 VALUE 0. PROCEDURE DIVISION. MOVE 1.25 TO AMOUNT. DISPLAY AMOUNT. STOP RUN.

    Answer

    1.25

    The period in PIC 9.99 is the decimal point, so the field holds one digit, a point and two digits, and DISPLAY prints them as stored.

  6. What does this program print? IDENTIFICATION DIVISION. PROGRAM-ID. Q2. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9,99 VALUE 0. PROCEDURE DIVISION. MOVE 1,25 TO AMOUNT. DISPLAY AMOUNT. STOP RUN.

    Answer

    1,25

    With the comma as the decimal point the picture and the literal are written with a comma, and the two digits after it are printed.

  7. What is the first line of the compiler output for this program? IDENTIFICATION DIVISION. PROGRAM-ID. Q3. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. DATA DIVISION. WORKING-STORAGE SECTION. 01 AMOUNT PIC 9,99 VALUE 0. PROCEDURE DIVISION. MOVE 1.25 TO AMOUNT. DISPLAY AMOUNT. STOP RUN.

    Answer

    error: syntax error, unexpected ., expecting TO

    With the comma as the decimal point, 1.25 is the literal 1, then a period that ends the sentence, so the compiler never reaches the TO.

  8. What is the first line of the compiler output for this program? IDENTIFICATION DIVISION. PROGRAM-ID. 123. PROCEDURE DIVISION. DISPLAY "one". STOP RUN.

    Answer

    error: syntax error, unexpected Identifier, expecting Literal or program name

    A number in the position of the program name is read as a literal, and the compiler names the word it found instead of a literal or a program name.

  9. What does this program print? IDENTIFICATION DIVISION. PROGRAM-ID. SOMETHING-ELSE. PROCEDURE DIVISION. DISPLAY "a name of its own". STOP RUN.

    Answer

    a name of its own

    The source is taken from the file and the program name from the paragraph, and cobc does not check that the two agree.

  10. A program carries AUTHOR and DATE-WRITTEN and is built with -Wall. What happens?

    Answer

    It builds, prints one obsolete warning per paragraph, and runs

    GnuCOBOL marks the paragraphs obsolete with [-Wobsolete], which -Wall shows; obsolete is a warning about the standard, not a refusal to build.

The code on this page was built with cobc (GnuCOBOL) 3.2.0 and run on Alpine Linux 3.24.3 (x86_64) in a Docker container.

Article author: Arthur Isaev