COBOL Introduction
COBOL stands for COmmon Business Oriented Language.
Note. These notes were accumulated over 25 years on a variety of COBOL versions and hardware. Check your manual to see what will work on your system.
Divisions
COBOL programs can have up to 4 parts or divisions, in the following order:
- the Identification Division - to identify the program,
- the Environment Division - to describe the computer & hardware,
- the Data Division - to describe the formats of the data,
- the Procedure Division - containing the program instructions.
Character set
The COBOL character set includes the following:
0 to 9, A to Z, a to z, +, - (hyphen and minus), * (multiplication sign), / (slash, division), =, $ (currency sign), comma, semicolon, full stop (period), " (quotation mark), (, ), >, <, colon and space.
Program sheet
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
| Seq.No | - | A | B | Ident | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
where '-' stands for the continuation column.
COBOL was written on program sheets back in the days of 80-character punched cards, and it matters which column an element of a COBOL statement begins in. Columns 1 to 6 are reserved for the optional sequence numbers. If they are present, then the compiler will check that they are in sequence. They are of little use in post-punch card days! Column 7 is called the indicator area and is used to denote if this card is a continuation card from the previous card (shown by presence of a hyphen). Alternatively, an asterisk can be used to turn the rest of the card into a comment area. Columns 8 to 11 are called the 'A' area. Division headings, section headings, paragraph names should begin in here. They should be terminated by a full stop (period). Some other items also go in this area. Columns 12 to 72 are called the 'B' area. All sentences within the Procedure Division should be confined to this area. Columns 73 to 80 are used to identify the program. This is not necessary in post-punched card days.
