Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

COBOL notation

1. Definition of a format

The specific arrangement of the elements within a clause or statement is referred to as a "general format". A clause or statement may be composed of various element types.

When more than one specific arrangement is permitted in a clause or statement, the general format is subdivided into numbered formats. Note that clauses must be written in the same sequence in which they are specified in the general format. In certain exceptional cases, departures from this rule are allowed. These cases, however, are identified as such.

The proper use of formats, the necessary application prerequisites, and the restrictions on their use are expressed in the form of rules.

2. Elements

Clauses or statements may be constructed from the following element types:

  • uppercase words

  • lowercase words

  • uppercase and lowercase words

  • level-numbers

  • brackets

  • braces

  • connectives

  • special characters

3. Words

Notation

Meaning

Uppercase

A word specially reserved for COBOL.

Uppercase, underlined

This word must be specified by the programmer as it is given in the format. It is a COBOL keyword.

Uppercase, not underlined

This word may be specified by the programmer at the location given in the format or it may be omitted. It is an optional COBOL word.

Lowercase

Generic term used to represent COBOL words, literals, picture-strings, comments, or a complete syntactical unit. It must be entered by the programmer at the location given in the format. If more than one generic term of the same kind occurs in the same format, an appended number or letter is used to uniquely qualify that term for the descriptions.

Table 1: Notation used for COBOL words


An entry consisting of one or more words in uppercase followed by the words "clause" or "statement" designates a clause or statement described elsewhere in this manual. In programs, all COBOL words can appear in uppercase and lowercase as well as in lowercase only.

4. Separators

The separators listed in the following table must be used as specified in the format.

Character

Meaning

Character

Meaning

'BLANK'

Space

"

Quotation marks *)

,

Comma

Apostrophe

;

Semicolon

(

Open parentheses

.

Period

)

Close parentheses

:

Colon

==

Pseudo-text delimiter

Table 2: Separators


The rules governing the use of separators are described in section "Separators"

5. Level indicators and level numbers

Level indicators and level numbers which occur in the format must be supplied at the appropriate point in the COBOL compilation unit. This manual uses the form 01, 02, ..., 09 to indicate level numbers 1, 2, ..., 9.

6. Brackets [ ]

A format specification placed in square brackets may be supplied or omitted at the option of the user. If two or more items are stacked within brackets, one or none of them may be specified.

7. Braces { }

If two or more items are stacked within braces, one of the enclosed items is required. If there is only one item, the braces perform only a combining function for a subsequent ellipsis (repetition symbol).

8. Vertical bars | |

The vertical bars are enclosed in either brackets or braces and have the following meaning:

  1. Vertical bars within braces enclose optional entries. Here at least one entry must be selected, but it is also possible to select more than one. The order of the entries selected is freely definable. However, each alternative may only be used once.

  2. Vertical bars within brackets enclose optional entries. Here the specification can be omitted, or more than one of the specified values can be selected. The order of the entries selected is freely definable. However, each alternative may only be used once.

9. Parentheses ( )

Format items appearing within parentheses refer to table item numbers (indices) which must be specified in order to differentiate the various items in a table.

10. Ellipsis ...

An ellipsis appearing in the text indicates the omission of one or more words when such an omission does not impair comprehension.

An ellipsis appearing in the format indicates that the immediately preceding unit may, if desired, be repeated any number of times after it has been specified once. A repeatable unit is either a single word or a group of words combined by brackets or braces. In the latter case, the ellipsis immediately follows the closing bracket or brace; the related opening bracket or brace determines the beginning of the unit to be repeated.

11. Space 'BLANK'

When used in examples and tables, this character stands for a space.

12. Special characters in formats

If the characters +, -, >, <, =, >= and <= appear in a format, they must be entered whenever the format is used. This applies even if these special characters are not underlined.

Example 2-1

ADD (1)   { (2) identifier-1 | literal-1 }(2)...(3)
          TO {identifier-2(4) [(5) ROUNDED ](5) }...
    [ON(6) SIZE ERROR imperative(7) statement-1]
    [NOT ON SIZE ERROR imperative statement-2]
    [END-ADD]


(1)

COBOL keyword: the indicated form is mandatory.

(2)

Braces: one of these options must be chosen.

(3)

Ellipsis: the preceding entry may be repeated any number of times.

(4)

Qualification: an appended number or letter is used to create a unique identification for an element.

(5)

Brackets: one or more of these options may be chosen.

(6)

Optional word: the word may be omitted, or specified for the sake of clarity.

(7)

Lowercase words: these must be entered by the programmer.

The following language elements are valid ADD statements derived from the above format; commas and semicolons are included for better readability.

ADD I TO J
ADD I-1, I-2, I-3 TO I-4 ROUNDED
ADD 1 TO I-1, I-2 ROUNDED, I-3
ADD I-1 TO I-2; SIZE ERROR PERFORM ADD-ERR END ADD