The part of a Cobol program that actually does the things that go wrong. It is the fourth of the four divisions that, and contains all the procedures or statements; as opposed to the previous three divisions, which define files and variables.

The procedure division is divided into paragraphs, each with an alphanumeric name. Division, paragraph, and (see below) section names begin in Area A (columns 8-11) and end in a full stop. Here is the simplest possible correct Cobol program:

000100  IDENTIFICATION DIVISION.
000200  ENVIRONMENT DIVISION.
000300  DATA DIVISION.
000400  PROCEDURE DIVISION.
000500  A.
000600      STOP RUN.
It has only one paragraph (A) and only one command in it, the one that ends the program. (Falling off the edge of the program without hitting a STOP RUN crashes it, at least with the compiler I use.)

A more realistic example is this. I'll give it a name MYPROG, assign a file, and create two variables, a counter and an EOF flag. Cobol keywords are hardlinked.

000100  IDENTIFICATION DIVISION.
000110  PROGRAM-ID.  MYPROG.
000120
000200  ENVIRONMENT DIVISION.
000210  INPUT-OUTPUT SECTION.
000220  FILE-CONTROL.
000230      SELECT F   ASSIGN DISK.
000240
000300  DATA DIVISION.
000310  FILE SECTION.
000320  FD  F.
000330  01  F-RECORD  PIC X(80).
000340
000350  WORKING-STORAGE SECTION.
000360  01  REC-CT    PIC 9(6).
000370  01  AT-EOF    PIC 9.
000380
000400  PROCEDURE DIVISION.
000500  A.
000510      PERFORM INITIALIZE-IT.
000520      PERFORM MAIN-LOOP UNTIL AT-EOF = 1.
000530      PERFORM TERMINATE-IT.
000600      STOP RUN.
000610  INITIALIZE-IT.
000620      MOVE 0 TO AT-EOF.
000630      MOVE 0 TO REC-CT.
000640      OPEN INPUT F.
000650  MAIN-LOOP.
000660      READ F
000670          END MOVE 1 TO AT-EOF
000680          EXIT PERFORM.
000690      ADD 1 TO REC-CT.
000700  TERMINATE-IT.
000710      CLOSE F.
000720      DISPLAY "TOTAL RECORDS = " REC-CT.
Once you're inside the Procedure Division it's not really that different from a lot of other languages.

Paragraphs can be grouped into sections. If sections are used at all, they must be used throughout. You give them alphanumeric names just like paragraphs. A fragment of the above with sections is this:

000400  PROCEDURE DIVISION.
000500  CTRL SECTION.
000505  PARA-1.
000510      PERFORM INITIALIZE-IT.
000520      PERFORM MAIN-LOOP UNTIL AT-EOF = 1.
000530      PERFORM TERMINATE-IT.
000540  PARA-99.
000600      STOP RUN.
000605.
000610  INITIALIZE-IT SECTION.
000615  PARA-1.
000620      MOVE 0 TO AT-EOF.

Log in or register to write something here or to contact authors.