Most of this is in the IBM Z/OS variety, but I assume most of it is pretty agnostic to the exact implementation hardware. Plus the manuals are all over the internet, so shouldn't be too hard to grab what you need.
'Characters' are lowest in the hierarchy and they cannot be divided further. The COBOL Character Set includes 78 characters which are shown below.
|1||Alphabets (Upper Case)||
|2||Alphabets (Lower Case)||
|6||Minus Sign or Hyphen||
|12||Decimal Point or Period||
The source program of COBOL must be written in a format acceptable to the compilers. COBOL programs are written on COBOL coding sheets. There are 80 character positions on each line of a coding sheet.
Character positions are grouped into the following five fields:
|1-6||Column Numbers||Reserved for line numbers.|
|7||Indicator||It can have Asterisk (
|8-11||Area A||All COBOL divisions, sections, paragraphs and some special entries must begin in Area A.|
|12-72||Area B||All COBOL statements must begin in area B.|
|73-80||Identification Area||It can be used as needed by the programmer.|
The following example shows a COBOL coding sheet:
000100 IDENTIFICATION DIVISION. 000100 000200 PROGRAM-ID. HELLO. 000101 000250* THIS IS A COMMENT LINE 000102 000300 PROCEDURE DIVISION. 000103 000350 A000-FIRST-PARA. 000104 000400 DISPLAY “Coding Sheet”. 000105 000500 STOP RUN. 000106
JCL to execute the above COBOL program:
//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C //STEP1 EXEC PGM = HELLO
When you compile and execute the above program, it produces the following result:
Character strings are formed by combining individual characters. A character string can be a
- Literal, or
- COBOL word
All character strings must be ended with separators. A separator is used to separate character strings.
Frequently used separators:
- Left/Right Parenthesis
- Quotation mark
A comment is a character string that does not affect the execution of a program. It can be any combination of characters.
There are two types of comments:
|Comment Line||Any line with an asterisk (
|Comment Entry||Comment entries are those that are included in the optional paragraphs of an Identification Division. They are written in Area B and programmers use it for reference.||TODO|
Literal is a constant that is directly hard-coded in a program. In the following example, "Hello World" is a literal.
PROCEDURE DIVISION. DISPLAY 'Hello World'.
There are two types of literals, alphanumeric and numeric.
Alphanumeric Literals are enclosed in single or double quotes. Length can be up to 160 characters.
A Numeric Literal is a combination of digits from
–, or decimal point. Length can be up to 18 characters. Sign cannot be the rightmost character. Decimal point should not appear at the end. Valid examples are
-1.9; invalid examples are
COBOL Word is a character string that can be a reserved word or a user-defined word. Length can be up to 30 characters.
User-defined words are used for naming files, data, records, paragraph names, and sections. Alphabets, digits, and hyphens are allowed while forming userdefined words. You cannot use COBOL reserved words.
Reserved Words[7, p. 12]
Reserved words are predefined words in COBOL. Different types of reserved words that we use frequently are as follows:
- Special characters
- Figurative constants
|1||HIGH-VALUES||One or more characters which will be at the highest position in descending order.|
|2||LOW-VALUES||One or more characters have zeros in binary representation.|
|3||ZERO/ZEROES||One or more zero depending on the size of the variable.|
|4||SPACES||One or more spaces.|
|5||QUOTES||Single or double quotes.|
|6||ALL "literal"||Fills the data-item with "literal".|
Variables (PICTURE Clause)
These are only the common ones that I've found. There are LOTS.
|A||A character position that can contain only a letter of the Latin alphabet or a space.||Each ’A’ is counted as one character position in the size of the data item.|
|S||An indicator of the presence (but not the representation, and not necessarily the position) of an operational sign. An operational sign indicates whether the value of an item involved in an operation is positive or negative.||Not counted in the size of the elementary item, unless an associated SIGN clause specifies the SEPARATE CHARACTER phrase (which would be counted as one character position).|
|V||An indicator of the location of the assumed decimal point. Does not represent a character position.
When the assumed decimal point is to the right of the rightmost symbol in the string, the V is redundant.
|Not counted in the size of the elementary item.|
|X||A character position that can contain any allowable character from the alphanumeric character set of the computer.||Each ’X’ is counted as one character position in the size of the data item.|
|Z||A leading numeric character position. When that position contains a zero, a space character replaces the zero.||Each ’Z’ is counted as one character position in the size of the data item.|
|9||A character position that contains a numeral.||Each nine specifies one decimal digit in the value of the item. For usages DISPLAY and NATIONAL, each nine is counted as one character position in the size of the data item.|
|0||A character position into which the numeral zero is inserted.||Each zero is counted as one character position in the size of the data item.|
- Learning COBOL Programming with VSCode
- IBM ZXplore
Books on COBOL
- Fundamentals of Structured COBOL by Carl Feingold
- Mainframe COBOL from Murach
- Advanced COBOL for Structured and Object-Oriented Programming by Gary DeWard Brown
- Any IBM COBOL manual
- Debugging COBOL
Last modified: 202205151826