Back to first page...

ELEMENTS OF THE COBOL LANGUAGE

The Character Set

The set of character set used in the language is either the ANSI set or the EBCDIC set. EBCDIC set is generally used in IBM mainframe computers. MS-DOS based operating systems and UNIX use the ANSI character set. In either case, the COBOL language elements use the

Decimal digits (0 - 9)
A, B ,..., Z
a,b,...,z
+, -, *, /, = , $, ,, ;, ., (, ), <, >, : and space

as the alphabet.

Special characters, such as the letters that appear only in the Turkish alphabet can only appear in literal strings. For example

COMPUTE ÖRNEK1 = K + 2.

is not a valid COBOL statement; but

ORNEK1 = "ÖRNEK1"

is a valid statement.

Using the ANSI or EBCDIC character sets, one builds Programmer-Supplied names. Or simply the variable names, statement labels, procedure names etc.

Programmer-Supplied names

These are simply the variable names, procedure names, array and structure names and labels that the programmers would use. Programmer-Supplied names must confirm certain rules which can be summarized as

Reserved Words

The programmer should be careful in setting up Programmer-Supplied names, because COBOL has some RESERVED WORDS. Reserved words cannot be used in any context that might cause a misinterpretation by the compiler.

For example

NEWVALUE = COMPUTE + 1

is not allowed! because COMPUTE is a reserved word. A typical programmer need not to memorize all the reserved words but it is wise to have list reserved words available while you are writing code, or even better, to avoid any words that might have a special meaning in COBOL. If you cannot be sure, just add a few extra characters to the word that you suspect can be reserved and then use it as a variable name.

Layout of the Source Code

The programmer is NOT free in using "colums" of lines that he/she is going to code COBOL statements into. COBOL, expects certain language elements at certain column positions in program sources. For this reason, the layout of the source code is divided into "ZONES".

ColumnsZONEUsage
1-6-Optional statement sequence numbers
7-Comment or Continuation Indicator
8-11ADivision Headers, section headers, paragraph names, FD statements and 01 level declarations start here.
12-72BAll remaining language elements should be typed in this zone.
73-80-Ignored by the compiler

Please refer to the sample COBOL program to see which statements start in which zones.

In the PC environment, you can use ANY text editor to type in COBOL source. Please note that you should avoid word processors since they insert special control commands into the text to mark special actions such as justification, soft spaces, bold text, italic text etc.

Having introduced you to the elementary aspects of the language, now we can go into details of the DIVISIONS.


Next Section