PreviousIntroduction to the COBOL Language Concepts of a Compilation GroupNext"

Chapter 2: Concepts of the COBOL Language

2.1 Character Set

The most basic and indivisible unit of the language is the character. The set of characters used to form COBOL character-strings and separators includes the letters of the alphabet, digits and special characters, and is defined below:

Character
Meaning
0 to 9 Digits
A to Z Uppercase letters
a to z Lowercase letters
  Space
+ Plus sign
- Minus sign or hyphen
* Asterisk
/ Oblique stroke/slash
= Equal sign
$ Dollar sign
. Period or decimal point
, Comma or decimal point
; Semicolon
" Quotation mark
' Apostrophe
( Left parenthesis
) Right par enthesis
> Greater Than symbol
< Less Than symbol
: Colon
& Ampersand
_ Underscore

Lowercase letters can be used in character strings and text words; except when used in nonnumeric literals and except for some picture symbols, each lowercase letter is equivalent to the corresponding uppercase letter.

This COBOL implementation is restricted to the above character set, but the content of nonnumeric literals, comment lines, comment entries and data can include any of the characters available under the character encoding scheme used for the COBOL compilation group. (See the appendix Character Sets and Collating Sequences.)

2.2 Language Structure

The individual characters of the language are concatenated to form character-strings and separators. A separator can be concatenated with another separator or with a character-string. A character-string can be concatenated only with a separator. The concatenation of character-strings and separators forms the text of a compilation group.

2.2.1 Separators

A separator is a string of one or more punctuation characters. The rules for formation of separators are:

  1. The punctuation character space is a separator. Wherever a space is used as a separator or as part of a separator, more than one space can be used. All spaces immediately following the separators comma, semicolon, or period are considered part of that separator and are not considered to be the separator space.

  2. Except when the comma is used in a PICTURE character-string, the punctuation characters comma and semicolon, immediately followed by a space, are separators that can be used anywhere the separator space is used.

  3. The punctuation character period, when followed by a space, is a separator. It must be used only to indicate the end of a sentence, or as shown in formats.

  4. The punctuation characters right and left parenthesis are separators. Except in pseudo-text, parentheses can appear only in balanced pairs of left and right parentheses delimiting subscripts,

    a list of function arguments, reference modifiers,

    arithmetic expressions, or conditions.

  5. The two contiguous characters 'G"', 'H"', 'N"' and 'X"' and

    the punctuation character quotation mark are separators. These separators must be immediately preceded by a space, left parenthesis or opening pseudo-text delimiter. The closing quotation mark paired with these separators must be immediately followed by one of the separators space, comma, semicolon, period, right parenthesis or closing pseudo-text delimiter. Separators immediately preceding the opening separator are not part of the opening separator. Separators immediately following the closing quotation mark are not part of the closing separator quotation mark.

  6. The punctuation character apostrophe is a separator which can be used throughout a compilation group in place of the quotation mark character.

    Both the quotation mark and the apostrophe can appear within the same source element. If they do, they must be in balanced pairs.

  7. Pseudo-text delimiters are separators. An opening pseudo-text delimiter must be immediately preceded by a space; a closing pseudo-text delimiter must be immediately followed by one of the separators space, comma, semicolon, or period.

    The space immediately preceding the opening pseudo-text delimiter can be omitted.

    Pseudo-text delimiters can appear only in balanced pairs delimiting pseudo-text

    and verb-signatures

    . (See the chapters Compiler-Directing Statements and ect COBOL Language Extensions.)

  8. The separator space can immediately precede all separators except the following:

    1. As specified by reference format (see the section Reference Format in the chapter Concepts of a COBOL Compilation Group).

    2. The separator closing quotation mark. In this case, a preceding space is considered as part of the nonnumeric literal and not as a separator.

    3. The opening pseudo-text delimiter, where the preceding space is required.

  9. The separator space can optionally immediately follow any separator except the opening quotation mark. In this case, a following space is considered as part of the nonnumeric literal and not as a separator.

Any punctuation character which appears as part of the specification of a PICTURE character-string (see the chapter Data Division - Data Description) or numeric literal is not considered to be a punctuation character, but rather a symbol. PICTURE character-strings are delimited only by the separators space, comma, semicolon, or period.

The rules established for the formation of separators do not apply to the characters which comprise the contents of nonnumeric literals, comment-entries, or comment lines.

2.2.2 Character-strings

A character-string is a character or a sequence of contiguous characters forming a COBOL word, a literal, a PICTURE character-string, or a comment-entry. A character-string is delimited by separators.

2.2.2.1 COBOL Words

A COBOL word is a character-string of not more than 30 characters which forms a compiler-directive word, a context-sensitive word,user-defined word, a system-name, a reserved word, or a function-name. Each character of a COBOL word that is not a special character word is selected from the set of letters, digits, the hyphen
and the underscore.
The hyphen
or the underscore
may not appear as the first or last character in such words. Each lowercase letter is considered to be equivalent to its corresponding uppercase letter.

The character-string may contain 31 characters.

Within a source element the following apply:

  1. For all COBOL words excluding the words LENGTH, RANDOM, and SUM:
    1. Reserved words form disjoint sets with user-defined words, system-names and function-names.

    2. User-defined words, system-names and function-names form intersecting sets. The same COBOL word may be used as a user-defined word, a system-name and a function-name. The classification of a specific occurrence of such COBOL words is determined by the context of the clause or phrase in which it occurs.

User-Defined Words: A user-defined word is a COBOL word that must be supplied by the user to satisfy the format of a clause or statement.

The types of user-defined words are:

Within a given source element the following user-defined words are grouped into the following disjoint sets:

All user-defined words, except segment-numbers and level-numbers, can belong to one and only one of these disjoint sets. Furthermore, all user-defined words within a given disjoint set must be unique, except as specified in the section Uniqueness Of Reference of this chapter.

With the exception of paragraph-name, section-name, level-number and segment-number, all user-defined words must contain at least one alphabetic character

or one occurrence of the hyphen character .

Segment-numbers and level-numbers need not be unique; a given specification of a segment-number or level-number can be identical to any other segment-number or level-number and can even be identical to a paragraph-name or section-name.

The following user-defined words are externalized to the operating environment:

  1. program-names of programs that are not contained in other programs,
    class-names,
    interface-names, and
    method-names

  2. data-names, file-names, and record-names of items described with the
    EXTERNAL attribute.

If a literal is specified in place of or in addition to one of these names, the content of the literal is the name that is externalized to the operating environment in a case-sensitive manner. If no literal is specified, the externalized name is created by folding the name to upper case. The Compiler directive FOLD-CALL-NAME can be used to control the case of externalized class-names, interface-names and program-names. The F and U options of the Compiler directive OOCTRL can be used to control the case of externalized method-names. +F and -U cause method-names to be folded to lower case, which is the default.

Condition-Name: A condition-name is a name which is assigned to a specific value, set of values, or range of values, within a complete set of values that a data item can assume. The data item itself is called a conditional variable. Condition-names can be defined in the Data Division or in the SPECIAL-NAMES paragraph within the Environment Division where a condition-name must be assigned to one or both of the ON STATUS or OFF STATUS of the run-time switches.

A condition-name is used only as follows:

  1. in the RERUN clause;

  2. in conditions as an abbreviation for a relation condition. This relation condition posits that the associated conditional variable is equal to one of the set of values to which that condition-name is assigned.

  3. in a SET statement indicating that the associated value is to be moved to the conditional variable.

Constant-Name: A constant-name is a name which is assigned as the name of a fixed value.
Mnemonic-Name: A mnemonic-name assigns a user-defined word to an implementor-name. These associations are established in the SPECIAL-NAMES paragraph of the Environment Division. (See the section The SPECIAL-NAMES Paragraph in the chapter Environment Division.)
Paragraph-Name: A paragraph-name is a word that names a paragraph in the Procedure Division. Paragraph-names are equivalent if, and only if, they are composed of the same sequence of the same number of characters.
Section-Name: A section-name is a word that names a section in the Procedure Division. Section-names are equivalent if, and only if, they are composed of the same sequence of the same number of characters.
Other User-Defined Words: See The Glossary for definitions of all other types of user-defined words.

System-Names: A system-name is a COBOL word that is used to communicate with the operating environment.

System-names must contain at least one alphabetic character

or one occurrence of the hyphen character.

There are three types of system-names:

  1. computer-name
  2. implementor-name
  3. language-name.

Within a given implementation these three types of system-names form disjoint sets; a given system-name can belong to one and only one of them.

The system-names listed above are individually defined in The Glossary.

Function-Names: A function-name is a word that is one of a specified list of words which can be used in COBOL source elements. The same word, with the exception of LENGTH, RANDOM and SUM, in a different context, can appear in a source element as a user-defined word or a system-name. (See the section Definitions of Functions in the chapter Procedure Division - Intrinsic Functions.)

Reserved Words: A reserved word is a COBOL word that is one of a specified list of words which can be used in COBOL compilation groups, but which must not appear in the compilation groups as user-defined words or system-names. Reserved words can be used only as specified in the general formats. (See the appendix Reserved Words.)

The types of reserved words are:

  1. key words
  2. optional words
  3. special registers
  4. figurative constants
  5. special-character words
  6. predefined object identifiers.

Key Words: A key word is a word whose presence is required when the format in which it appears is used in a compilation group. Within each format, such words are uppercase and underlined.

Key words are of three types:

  1. verbs such as ADD, READ, and ENTER

  2. required words, which appear instatement and entry formats

  3. words which have a specific functional meaning, such as NEGATIVE, SECTION, and so on.

Optional Words: Within each format, uppercase words that are not underlined are called optional words and can appear at the user's discretion. The presence or absence of an optional word does not alter the semantics of the COBOL source element in which it appears.
Special Registers: Certain words are used to name and reference special registers: special registers are certain storage areas created by your COBOL system, whose primary use is to store information produced in conjunction with the use of specific COBOL features. These special registers include LINAGE-COUNTER (see the chapter Data Division - Data Description) and DEBUG-ITEM (see the chapter Debug Module in your Language Reference - Additional Topics). They are specified in the section Special Registers later in this chapter.
Figurative Constants: Certain reserved words are used to name and reference specific constant values. These reserved words are specified in the section Figurative Constant Values later in this chapter.
Special Character Words: The arithmetic operators and relation characters are reserved words.
Predefined Object Identifiers: Certain reserved words are used as predefined object identifiers. The predefined object identifiers are:
  1. SELF
  2. SUPER
  3. SELFCLASS

Context-sensitive Words: A context-sensitive word is a COBOL word that is reserved only in the general formats in which it is specified. The same word may also be used as a function-name, a user-defined word or a system-name. Context-sensitive words and the contexts in which they are reserved are specified in the appendix Context-sensitive Words.

2.2.3 Scope of Names

When source elements are directly or indirectly contained within other source elements, each source element can use identical user-defined words to name items independent of the use of these user-defined words by other elements. (See the section User-defined words earlier in this chapter.) When identically named items exist, a source elements's reference to such a name, even when it is a different type of user-defined word, is to the item which that source element describes rather than to the item possessing the same name, described in another source element.

The following types of user-defined words can be referenced only by statements and entries in the source element in which the user-defined word is declared:

The following types of user-defined words can be referenced by any COBOL source element:

The following types of user-defined words, when declared in a Communication Section, can be referenced only by statements and entries in the program that contains that section:

The following types of names, when declared in a Configuration Section, can be referenced only by statements and entries either in the source element that contains that Configuration Section or in any source element contained within that source element:

Specific conventions, for declarations and references, apply to the following types of user-defined words when the conditions listed above do not apply:

2.2.3.1 Conventions for Program-names

The program-name of a program is declared in the Program-ID paragraph of the program`s Identification Division. A program-name can be referenced only by the CALL statement,
the CHAIN statement,
the CANCEL statement,
the SET statement
and the END PROGRAM header. If two programs in a run unit are identically named, at least one of those two programs must be directly or indirectly contained within a separate program which does not contain the other of those two programs.

The following rules regulate the scope of a program-name:

  1. If the program-name is that of a program which does not possess the common attribute and which is directly contained within another program, that program-name can be referenced only by statements included in that containing program.

  2. If the program-name is that of a program which does possess the common attribute and which is directly contained within another program, that program-name can be referenced only by statements included in that containing program and any programs directly or indirectly contained within that containing program, except that program possessing the common attribute and any programs contained within it.

  3. If the program-name is that of a program that is not contained in another program, it can be referenced by statements included in any other program in the run unit, except those it directly or indirectly contains.

2.2.3.2 Conventions for Condition-names, Data-names, File-names, Record-names, Report-names and
Typedef-names

When condition-names, data-names, file-names, record-names, report-names and
typedef-names
are declared in a source element, they can be referenced only by that source element unless one or more of the names is global and the source element contains other source elements.

The requirements governing the uniqueness of the names declared by a single source element to be condition-names, data-names, file-names, record-names, report-names and
typedef-names
are explained in the section User-Defined Words earlier in this chapter.

A source element cannot reference any condition-name, data-name, file-name, record-name, report-name, or
typedef-name
declared in any source element it contains.

A global name can be referenced in the source element in which it is declared or in any source elements which are directly or indirectly contained within that source element.

When a source element, source element B, is directly contained within another source element, source element A, both source elements can define a condition-name, a data-name, a file-name, a record-name, a report-name or a
typedef-name
using the same user-defined word. When such a duplicate-name is referenced in source element B, the following rules are used to determine the referenced item:

  1. The set of names to be used for determination of a referenced item consists of all names that are defined in source element B and all global names that are defined in source element A and in any source elements which directly or indirectly contain source element A. Using this set of names, the normal rules for qualification and any other rules for uniqueness of reference are applied until one or more item is identified.

  2. If only one item is identified, it is the referenced item.

  3. If more than one item is identified, no more than one of them can have a name local to source element B. If zero or one of the items has a name local to source element B, the following rules apply:

    1. If the name is declared in source element B, the item in source element B is the referenced item.

    2. Otherwise, if source element A is contained within another source, the referenced item is:

      1. The item in source element A if the name is declared in source element A.

      2. The item in the containing source element if the name is not declared in source element A and is declared in the source element containing source element A. This rule is applied to further containing source elements until a single valid name has been found.

2.2.3.3 Conventions for Index-names

If a data item possessing the global attribute includes a table described with an index-name, that index-name also possesses the global attribute. Therefore, the scope of an index-name is identical to that of the data-name which names the table whose index is named by that index-name and the scope of name rules for data-names apply.

Index-names cannot be qualified.

Index-names can be qualified.

2.2.3.4 Conventions for
Class-names (for Object Orientation) and
Interface-names

The class-name of a class referenced within a source element must be either the name of the containing class definition or declared in the
REPOSITORY paragraph or the
CLASS-CONTROL paragraph
of that or a containing source element.

Within a compilation group, there must be at most one Class Definition for a given class-name.

The interface-name of an interface referenced within a source element must be either the name of the containing interface definition or declared in the REPOSITORY paragraph of that or a containing source element.

Within a compilation group, there must be at most one interface definition for a given interface-name.

A class-name or interface-name declared in the CLASS-CONTROL paragraph or the REPOSITORY paragraph of a source element may be used in that source element and any nested source element.

2.2.3.5 Conventions for Method-names

A method-name of a method is declared in the METHOD-ID paragraph. A method-name must be referenced only by the INVOKE statement and the end method header.

The methods declared in a Class Definition shall have unique method-names within that Class Definition. The methods declared in a child class may have the same name as a method in the parent class, subject to the conditions for the METHOD-ID paragraph.

The methods declared in an interface definition must have unique method-names within that interface definition. The methods declared in an inheriting interface can have the same name as a method in the inherited interface, subject to the conditions stated for the METHOD-ID paragraph.

2.2.4 Literals

A lite ral is either:

Every literal belongs to one of two types; nonnumeric or numeric.

2.2.4.1 Nonnumeric Literals

A nonnumeric literal is a character-string delimited at both ends by quotation marks

or apostrophes

and consisting of any allowable character in the computer's character set. Nonnumeric literals may be of 1 to 160 characters in length. Whether quotation marks

or apostrophes

are used as delimiters, the presence of that delimiter within a nonnumeric literal can be represented by two contiguous occurrences. The presence of the character that is not serving as the delimiter is represented by a single occurrence. The value of a nonnumeric literal in the runtime element is the string of characters itself, except:

All other punctuation characters are part of the value of the nonnumeric literal rather than separators; all nonnumeric literals are category alphanumeric. (See the section The PICTURE Clause in the chapter Data Division - Data Description.)

In addition, hexadecimal binary values can be attributed to nonnumeric literals by expressing literals as: X"nn", where each n is a hexadecimal digit in the set 0-9 A-F; nn can be repeated up to 160 times, but the number of hexadecimal digits must be even.

The number of hexadecimal digits may be odd.

2.2.4.2 Numeric Literals

Numeric literals can be either fixed-point or floating-point numbers.

2.2.4.2.1 Fixed-Point Numeric Literals

A numeric literal is a character-string whose characters are selected from the digits "0" through "9" , the plus sign, the minus sign, and the decimal point. This implementation allows for numeric literals of 1 to 18 digits in length. The rules for the formation of numeric literals are as follows:

If a literal conforms to the rules for the formation of numeric literals, but is enclosed in quotation marks, it is a nonnumeric literal and is treated as such by your COBOL system.

The size of a numeric literal in standard data format characters is equal to the number of digits specified by the user.

In addition, hexadecimal binary values can be attributed to numeric literals by expressing literals as: H"nn", where each n is a hexadecimal digit in the set 0-9 A-F; nn can be repeated up to 8 times, but the number of hexadecimal digits must be even.

2.2.4.2.2 Floating-Point Numeric Literals

A floating-point literal is written in the form:

The sign is optional before the mantissa and the exponent: if you omit the sign, the system assumes a positive number.

The mantissa can contain between 1 and 16 digits. A decimal point must be included in the mantissa.

The exponent is represented by an E followed by an optional sign and one or two digits.

The magnitude of a floating-point literal value must fall between 0.54E-78 and 0.72E+76. For values outside this range, a diagnostic will be produced and the value will be replaced by 0 or 0.72E+76 respectively. You must not use a floating-point literal when an integer literal is required.

2.2.4.3 Figurative Constant Values

Figurative constant values are generated by your COBOL system and referenced through the use of the reserved words given below. These words must not be bounded by quotation marks when used as figurative constants. The singular and plural forms of figurative constants are equivalent and can be used interchangeably.

The figurative constant values and the reserved words used to reference them are shown in Table  2-1.

Table  2-1: Figurative Constants and Their Reserved Words

Constant Representation
ZERO
ZEROS
ZEROES
Represents the value "0", or one or more of the character "0" depending on the context.
SPACE
SPACES
Represents one or more of the character space from the computer's character set.
HIGH-VALUE
HIGH-VALUES
Represents one or more of the character that has the highest ordinal position in the program collating sequence. (x"FF" for the extended ASCII character set.)
LOW-VALUE
LOW-VALUES
Represents one or more of the character that has the lowest ordinal position in the program collating sequence. (x"00" for the ASCII character set.)
QUOTE
QUOTES
Represents one or more of the character """. The word QUOTE or QUOTES cannot be used in place of a quotation mark in a source program to bound a nonnumeric literal. Thus QUOTE ABD QUOTE is incorrect as a way of stating "ABD".
ALL literal Represents one or more characters of the string of characters comprising the literal. The literal must be either a nonnumeric literal or a figurative constant other than ALL literal. When a figurative constant is used, the word ALL is redundant and is used for readability only.
NULL
NULLS
Represents one or more unset pointer

or procedure-pointer

values. A data item with USAGE POINTER

or PROCEDURE-POINTER

and with a value of NULL is guaranteed not to represent the address of any data item

or procedure.

The NULL value varies between environments and is generally consistent with the equivalent value used in non-COBOL languages for each environment.

When a figurative constant represents a string of one or more characters, the length of the string is determined by your COBOL system from context according to the following rules:

  1. When a figurative constant is either specified in a VALUE clause, or associated with another data item, (for example, when the figurative constant is moved to or compared with another data item), the string of characters specified is repeated character by character on the right until the size of the resultant string is greater than or equal to the number of character positions in the associated data item. This resultant string is then truncated from the right until the number of character positions remaining is equal either to 1 or to the number of character positions in the associated data item, whichever is greater. This is done prior to and independent of the application of any JUSTIFIED clause that can be associated with the data item.

  2. When a figurative constant, other than ALL literal, is not associated with another data item (for example, when the figurative constant appears in a DISPLAY, STRING, STOP or UNSTRING statement) the length of the string is one character.

  3. When the figurative constant ALL literal is not associated with another data item, the length of the string is the length of the literal.

    Use of figurative constants in Format 3 DISPLAY statements has specific effects, described in the General Rules for that statement.

A figurative constant can be used wherever a literal appears in a format, except that whenever the literal is restricted to having only numeric characters in it, the only figurative constant permitted is ZERO (ZEROS, ZEROES).

When the figurative constants HIGH-VALUE(S) or LOW-VALUE(S) are used , the actual character associated with each figurative constant depends upon the program collating sequence specified. (See the sections The OBJECT-COMPUTER Paragraph and The SPECIAL-NAMES Paragraph in the chapter Environment Division.)

Each reserved word that is used to reference a figurative constant value is a distinct character-string, with the exception of the construction "ALL literal" which is composed of two distinct character-strings.

The value associated with the QUOTE/QUOTES figurative constant is sensitive to the APOST and QUOTE directives.

The figurative constant ALL literal, when associated with a numeric or numeric edited item, and when its length is greater than one, is classed as an obsolete element in the ANSI'85 standard and is scheduled to be deleted from the next full revision of the ANSI Standard.

All dialects within this COBOL implementation fully support this obsolete ALL literal syntax. The FLAGSTD directive can be used to detect all occurrences of this syntax.

Although this obsolete ALL literal syntax is a part of the standard COBOL definition, this syntax is explicitly excluded from the X/Open COBOL language definitions and should not be used in a conforming X/Open COBOL source program.

2.2.4.4 Constant-Names

Constant-names are user-defined words described in the DATA DIVISION in level-78 data description entries. A constant-name may be used wherever a literal appears in a format. Its effect is as if the literal in the VALUE clause of its data description had been written instead. A constant-name with an integer value can also be used wherever a format requires an integer; for example, as a level number or segment number, or in a PICTURE character-string.

A constant-name can only be used after it has been described; that is, it cannot be the object of a forward reference.

2.2.4.5 Concatenation Expressions

A concatenation expression consists of two operands separated by the concatenation operator.

General Format

Syntax Rules

  1. Both operands shall be of the same class, except that a figurative constant may be specified as one or both operands. Neither operand shall be numeric. Neither literal-1 nor literal-2 shall be a figurative constant that begins with the word ALL.

General Rules

  1. The class of the concatenation expression resulting from the concatenation operation shall be:

    1. when one of the operands is a figurative constant, the class of the literal or concatenation expression that constitutes the other operand, or

    2. when both of the operands are figurative constants, the class alphanumeric, or

    3. the same class as the operands.

  2. The value of a concatenation expression shall be the concatenation of values of the literals, figurative constants and concatenation expressions of which it is composed.

  3. A concatenation expression shall be equivalent to a literal of the same class and value, and may be used anywhere a literal of that class may be used.

2.2.4.6 Special Registers

Special registers are data items or transient values generated by your COBOL system and referred through the use of their associated names or expressions (see Table 2-2). These special registers are subject to special rules of reference and have implicit data descriptions (PICTUREs), as individually described. See the section COBOL Words earlier in this chapter.

Table 2-2 : Special Registers

Special Register name or expression Implicit Data Description Picture Usage
ADDRESS OF data-name-1 USAGE IS POINTER The expression generates a pointer value representing the address of data-name-1. The expression is explicitly shown in the general format for statements in which it can be used. Data-name-1 shall be a data item declared in the Linkage Section with a level number or 01 or 77

or shall be declared anywhere in the Data Division and with any level number.

CURRENT-DATE1 X(8) The CURRENT-DATE special register contains the value of the current date (as supplied by the COBOL execution environment), in the form:
MM/DD/YY
where MM is the month number, DD is the day of the month, and YY is the year number (from 1900). CURRENT-DATE is valid only as the sending area of a MOVE statement.
LENGTH OF data-name-22 9(9) The expression generates a value representing the current number
of bytes of storage used by data-name-2. The expression can be used wherever a numeric data item can be used except as a subscript or a reference modifier.

It can also be used to set the value of a level 78 item.

RETURN-CODE3 S9(4) COMP


S9(9) COMP

The RETURN-CODE special register can:
  • be set by a program, prior to the execution of a STOP RUN, EXIT PROGRAM or GOBACK statement, to pass a value to the
    calling runtime element (or the execution environment)

  • be read, subsequent to a CALL to another COBOL program, to obtain the RETURN-CODE set by that CALLed program.

A program's RETURN-CODE is set to zero when that program is first entered. The RETURN-CODE is valid as a data-name in a Procedure Division statement wherever an elementary data item can be referenced.

SHIFT-IN X(1) Used to switch the character representation from double byte characters (DBCS) back to single byte characters (SBCS) in environments where this is applicable.
SHIFT-OUT X(1) Used to switch the character representation from single byte characters (SBCS) to double byte characters (DBCS) in environments where this is applicable.
SORT-CONTROL

SORT-CORE-SIZE
SORT-FILE-SIZE
SORT-MESSAGE
SORT-MODE-SIZE


X(8)

S9(8) COMP
S9(8) COMP
X(8)
S9(5) COMP

These items can be referenced in the Procedure Division but will contain either zeros (for numeric registers) or spaces (for alphanumeric registers).
SORT-RETURN S9(4) COMP SORT-RETURN can be used to cause an abnormal termination of a SORT procedure. If a value of 16 is moved into this field, the SORT operation will be terminated after the next RELEASE or RETURN.
TALLY 9(5) COMP The TALLY special register contains information produced by the EXAMINE...TALLYING statement. It is valid as a data-name in a Procedure Division statement wherever an elementary data item can be referenced.
TIME-OF-DAY 9(6) DISPLAY The TIME-OF-DAY special register contains the value of the current time of day (24-hour clock) (as supplied by the COBOL execution environment), in the form:
hhmmss
where hh =hour, mm=minutes, and ss=seconds. TIME-OF-DAY is valid only as the sending area of a MOVE statement.
WHEN-COMPILED X(20) The WHEN-COMPILED special register contains the time and date that the COBOL compilation group was submitted to your COBOL system, in the form:
hh.mm.ssMMM DD, YYYY
where hh=hours (24-hour clock), mm=minutes, ss=seconds, MMM=month name (first 3 characters), DD=day of month, and YYYY=year.

WHEN-COMPILED is valid only as the sending area of a MOVE statement.

WHEN-COMPILED X(20) The WHEN-COMPILED special register contains the time and date that the COBOL compilation group was submitted to your COBOL system, in the form:
MM/DD/YYhh.mm.ss
where DD, hh, mm and ss are as above. YY=year in century and MM=month in year.

WHEN-COMPILED is valid only as the sending area of a MOVE statement.


Notes: Certain special registers are sensitive to Compiler directives and dialects.

  1. The format of the contents of the CURRENT-DATE special register is sensitive to the CURRENT-DATE directive.
  2. The LENGTH OF special register may be followed by an alphanumeric literal when using the Micro Focus dialect.
  3. The size of the RETURN-CODE special register is sensitive to the XOPEN and RTNCODE-SIZE directives.

2.2.4.7 Predefined Object Identifiers

Predefined Object Identifier Usage
SELF References the object on which the current method is executing. May be used in the Procedure Division of a method. References the object that was used to invoke the method in which SELF appears. If SELF is specified for a method invocation, the search for the method includes all methods declared for the object.
SELFCLASS References the object that is the class object of the current object (SELF). If SELF is itself a class object, SELFCLASS is the system class BEHAVIOR. The class object BEHAVIOR terminates this self-reference. (i.e., If SELF is the BEHAVIOR of class, so is SELFCLASS.)
SUPER References the object on which the current method is executing. May be used in the Procedure Division of a method. May be the object used to invoke a method with the INVOKE statement. References the object that was used to invoke the method in which SELF appears. If SUPER is specified for a method invocation, the search for the method ignores all the methods defined in the same class as the executing method.
NULL References the null object reference value, which is a unique value that is guaranteed to never reference an object. NULL is implicitly described as class object and category object reference, and is not a universal object reference. NULL must not be specified as a receiving operand.

2.2.4.8 PICTURE Character-Strings

A PICTURE character-string consists of certain combinations of characters in the COBOL character set, used as symbols. See the section The PICTURE Clause in the chapter Data Division - Data Descriptionfor the PICTURE character-string and for the rules that govern its use.

Any punctuation character that appears as part of the specification of a PICTURE character-string is not considered to be a punctuation character, but a symbol used in the specification of that PICTURE character-string.

2.2.4.9 Comment-Entries

A comment-entry is an entry in the Identification Division that can be any combination of characters from the computer's character set. A comment-entry is for documentary purposes only, may extend over more than one line and is terminated upon encountering a division, section or paragraph name that is a reserved word

or encountering any character

in area A of a line. The continuation of a comment-entry by the use of the hyphen in the indicator area is not permitted.

2.3 Formats and Rules

2.3.1 General Format

A general format is the specific arrangement of the elements of a clause or a statement. Throughout this document a format is shown adjacent to information defining the clause or statement. When more than one specific arrangement is permitted, the general format is separated into numbered formats. Clauses must be written in the sequence given in the general formats. (Clauses that are optional must appear in the sequence shown if they are used.) In certain cases, stated explicitly in the rules associated with a given format, the clauses can appear in sequences other than that shown. Applications, requirements or restrictions are shown as rules.

2.3.2 Syntax Rules

Syntax rules are those rules that define or clarify the order in which words or elements are arranged to form larger elements, such as phrases, clauses, or statements. Syntax rules also impose restrictions on individual words or elements.

These rules are used to define or clarify how the statement must be written; that is, the order of the elements of the statement and restrictions on what each element may represent.

2.3.3 General Rules

General rules are those rules that define or clarify the meaning or relationship of meanings of an element or set of elements. They are used to define or clarify the semantics of the statement and the effect that it has on either execution or on the way intermediate code is produced.

2.3.4 Elements

Elements which make up a clause or a statement consist of uppercase words, lowercase words, level-numbers, brackets, braces, connectives and special characters.

2.4 Concept of Computer-independent Data Description

To make data as computer-independent as possible, the characteristics or properties of the data are described in relation to a standard data format rather than to an equipment-oriented format. This standard data format is oriented to general data processing applications and uses the decimal system to represent numbers (regardless of the radix used by the computer) and the remaining characters in the COBOL character set to describe nonnumeric data items.

2.5 Concept of Levels

A level concept or hierarchy is inherent in the structure of a logical data record. This concept arises from the need to specify subdivisions of a record for the purpose of data reference. Once a subdivision has been specified, it can be further subdivided to permit more detailed data referral.

The most basic subdivisions of a record, that is, those not further subdivided, are called elementary items; consequently, a record is said to consist of a sequence of elementary items, or the record itself can be an elementary item.

In order to refer to a set of elementary items, the elementary items are combined into groups. Each group consists of a named sequence of one or more elementary items. Groups, in turn, can be combined into groups of two or more groups, and so on. Thus, an elementary item can belong to more than one group.

2.5.1 Level-Numbers

A system of level-numbers shows the organization of elementary items and group items. Since records are the most inclusive data items, level-numbers for records start at 01. Less inclusive data items are assigned higher (not necessarily successive) level-numbers not greater in value than 49. A maximum of 49 levels in a record is allowed. There are special level-numbers, 66, 77

, 78

and 88 which are exceptions to this rule (see below). Separate entries are written for each level-number used.

A group includes all group and elementary items following it until a level-number less than or equal to the level-number of that group is encountered. All items which are immediately subordinate to a given group item should be described using identical level-numbers greater than the level-number used to describe that group item

; this rule is not insisted upon.

Example

Correct
Incorrect but Permitted
01 A.
  05 C-1.
    10 D PICTURE X.
    10 E PICTURE X.
  05 C-2.
01  A.
  05 C-1.
    10 D PICTURE X.
    10 E PICTURE X.
 04 C-2.

Four types of entries exist for which there is no true concept of level. These are:

  1. Entries that specify elementary items or groups introduced by a RENAMES clause.

  2. Entries that specify noncontiguous working storage and linkage data items.

  3. Entries that specify condition-names.

  4. Entries that specify constant-names.

Entries describing items by means of RENAMES clauses for the purpose of regrouping data items have been assigned the special level-number 66.

Entries that specify noncontiguous data items, which are not subdivisions of other items, and are not themselves subdivided, have been assigned the special level-number 77.

Entries that specify condition-names, to be associated with particular values of a conditional variable, have been assigned the special level-number 88.

Entries that specify constant-names, to be associated with the value of a particular literal, have been assigned the special level-number 78.


Figure 2-1: Example of Level-numbers Representing a Data Hierarchy

Note that indentation of COBOL source code is a readability convention only and is not part of the language.

Elementary items are by definition those items without any subordinate entries (entries without numerically greater level-numbers) following, and must have a storage definition associated with them (see the sections The PICTURE Clause and The USAGE Clause in the chapter Data Division - Data Description).

Note that only elementary items (marked with an asterisk, "*", above) and FILLER items (marked with a "#" sign above) will have storage explicitly reserved for them (in accordance with the associated PICTURE clause); non-elementary items have implicit storage associated with them of size determined by their subordinate items plus any FILLER bytes needed for synchronization (see the section The SYNCHRONIZED Clause in the chapter Data Division - Data Description).

Level-numbers need not be consecutively ascending or descending as shown above for clarity; thus, the next subordinate level after 01 could be 05, and the next level 10, and so on.

The above data descriptions would produce storage allocation in the following manner:



Figure 2-2: Data Record Storage Allocation

where:

R-E-I is Record-Entry-Item
M-G-I is Major-Group-Item
R-G-I is Regular-Group-Item
S-G is Sub-Group
EI is Elementary-Item
NEI is Noncontiguous Elementary-Item

2.6 Class and Category of Data

Every elementary data item, every literal, and every function has a class and a category. The class and category of a data item are defined by its picture character string, by the BLANK WHEN ZERO clause, or by its usage;
the class and category of an intrinsic function are specified by the definition of that intrinsic function (see the chapter Procedure Division - Intrinsic Functions);
and the class and category of a literal are defined in the section Literals earlier in this chapter.

The category of a group item is alphanumeric.

The following table depicts the relationship of categories to classes of data for elementary items.

Table 2-3: Category and class relationships for elementary items

Class Category
Alphabetic Alphabetic
Alphanumeric Numeric Edited
Alphanumeric Edited
Alphanumeric
DBCS
Index Index
Numeric Numeric
Internal Floating-point
External Floating-point
Object Object-reference
Pointer Data-pointer
Program-pointer

2.6.1 Algebraic Signs

Algebraic signs fall into two categories:

  1. operational signs, which are associated with signed numeric data items and signed numeric literals to indicate their algebraic properties;

  2. editing signs, which appear on edited reports to identify the sign of the item.

The SIGN clause permits the programmer to state explicitly the location of the operational sign. The clause is optional; if it is not used, operational signs will be represented as described in the section Selection of Character Representation and Radix.

Editing signs are inserted into a data item through the use of the sign control symbols of the PICTURE clause.

2.6.2 Standard Alignment Rules

The standard rules for positioning data within an elementary item depend on the category of the receiving item. These rules are:

  1. If the receiving data item is described as numeric:

    1. the data is aligned by decimal point and is moved to the receiving character positions with zero fill or truncation on either end as required

    2. when an assumed decimal point is not explicitly specified, the data item is treated as if it had an assumed decimal point immediately following its rightmost character and is aligned as in paragraph a. above.

  2. If the receiving data item is a numeric edited data item, the data moved to the edited item is aligned by decimal point with zero fill or truncation at either end as required within the receiving character positions of the data item, except where editing requirements cause replacement of the leading zeros.

  3. If the receiving data item is alphanumeric (other than a numeric edited data item), alphanumeric edited or alphabetic, the sending data is moved to the receiving character position and aligned at the leftmost character position in the data item with space fill or truncation to the right, as required.

  4. If the receiving data item is external floating-point, the leftmost non-zero digit, if one exists, is aligned on the leftmost digit position: the exponent is adjusted accordingly.

If the JUSTIFIED clause is specified for the receiving item, these standard rules are modified as described in the section The JUSTIFIED Clause in the chapter Data Division - Data Description.

2.6.3 Item Alignment for Increased Object-code Efficiency

Some computer memories are organized so that natural addressing boundaries exist in the computer memory (for example, word boundaries, half-word boundaries, byte boundaries). The way in which data is stored need not respect these natural boundaries.

However, certain uses of data (for example, in arithmetic operations or in subscripting) can be facilitated if the data is stored so as to be aligned on these boundaries. Specifically, additional machine operations in the runtime element can be repeated for the accessing and storage of data if portions of two or more data items appear between adjacent natural boundaries, or if certain natural boundaries divide a single data item.

Data items which are aligned on these natural boundaries in such a way as to avoid additional machine operations are defined to be synchronized. A synchronized item is assumed to be introduced and carried in that form; conversion to synchronized form occurs only during the execution of a statement (other than READ or WRITE) which stores data in the item.

Synchronization can be accomplished in two ways:

  1. by use of the SYNCHRONIZED clause

  2. by organizing the data suitably on the appropriate natural boundaries without the use of the SYNCHRONIZED clause.

By use of the SYNCHRONIZED clause, the use of special types of alignment within a group can affect the results of statements in which the group is used as an operand. The effect of the implicit FILLER and the semantics of any statement referencing these groups is described later in this chapter.

2.6.4 Selection of Character Representation and Radix

The value of a numeric item (defined as numeric by its PICTURE, see the section The PICTURE Clause - Numeric Data Rules in the chapter Data Division - Data Description) can be represented in the computer's storage in either binary or decimal form depending on the USAGE clause of the declaration (see the section The USAGE Clause in the chapter Data Division - Data Description). These numeric formats are:

An alphanumeric function is always represented in the standard data format. Its size is determined by the definition of the function.

The representation of integer and numeric functions is as follows:

Integer and numeric functions can be used only in arithmetic expressions, and represent the value resulting from the evaluation of the function without the restriction on composite of operands and/or receiving data items.

When a computer provides more than one means of representing data, the standard data format must be used for data items

other than integer and numeric functions,

if not otherwise specified by the data description.

2.6.4.1 DISPLAY Format

The COBOL digit characters from 0 to 9 that represent the number value are held in radix 10, one digit character per byte of computer storage. This is the standard data format of the COBOL language. If the data item is signed and the sign is not specified as SEPARATE (see the section The SIGN Clause in the chapter Data Division - Data Descriptionand the NUMERIC SIGN clause in the section The Special-Names Paragraph in the chapter Environment Division) the numeric sign is incorporated into either the leading or trailing digit, according to the LEADING or TRAILING phrase in the SIGN clause. Signed data is incorporated into the requisite digit as shown in Table 2-4 below. (Effectively, bit 6 (hexadecimal value "40" ) of the character is set from 0 to 1 if the number has a negative value.) If the data item is signed and the sign is specified as SEPARATE, then the sign is held as a separate single COBOL character, additional to the digits, either plus (+) or minus (-) as necessary. If the data item is signed and no SIGN clause applies, the numeric sign is incorporated into the trailing digit, unless the NUMERIC SIGN clause is specified in the Special-Names paragraph. If the SIGN clause is specified in a data description entry, the NUMERIC SIGN clause, if specified, is ignored for that entry.

In the following table, the numbers in brackets represent the hexadecimal encoding for the COBOL character. On some systems, the encoding can be varied by the CHARSET and SIGN Compiler directives.

Table 2-4 : DISPLAY Non-SEPARATE Sign-Digit Characters

Leading or trailing value digit before sign incorporation Sign Digit Character for:
Positively-signed values Negatively-signed values
Charset (ASCII) Charset (EBCDIC) Charset (ASCII) Charset (EBCDIC)
Sign (ASCII) Sign (EBCDIC) Sign (EBCDIC) Sign (ASCII) Sign (EBCDIC) Sign (EBCDIC)
0
1
2
3
4
5
6
7
8
9
0(30)
1(31)
2(32)
3(33)
4(34)
5(35)
6(36)
7(37)
8(38)
9(39)
{(7B)
A(41)
B(42)
C(43)
D(44)
E(45)
F(46)
G(47)
H(48)
I(49)
{(C0)
A(C1)
B(C2)
C(C3)
D(C4)
E(C5)
F(C6)
G(C7)
H(C8)
I(C9)
p(70)
q(71)
r(72)
s(73)
t(74)
u(75)
v(76)
w(77)
x(78)
y(79)
}(7D)
J(4A)
K(4B)
L(4C)
M(4D)
N(4E)
O(4F)
P(50)
Q(51)
R(52)
}(D0)
J(D1)
K(D2)
L(D3)
M(D4)
N(D5)
O(D6)
P(D7)
Q(D8)
R(D9)

Storage character position requirements for DISPLAY data items are thus equal to the number of "9"s in the PICTURE clause plus one if the sign is specified as SEPARATE. The SYNCHRONIZED clause has no effect on DISPLAY format data declarations.

2.6.4.2 COMPUTATIONAL,
diala.gifBINARY, or
dialovm.gifCOMPUTATIONAL-4 Format

This format holds numeric data items in computer storage in pure binary two's complement representation. In this format, number values are held in radix of 2 where each computer bit in the representation starting from the right (least-significant) end represents the presence or absence of an increasingly significant power of 2 in that value. Negative numbers are represented by complementing (inverting all the bit values of) their positive counterpart, and then adding one to the whole. Storage requirements depend on the number of "9"s in the PICTURE clause, and whether the numeric data item is signed or unsigned (see the sections The PICTURE Clause, The COMPUTATIONAL Clause, and The SIGN Clause in the chapter Data Division - Data Description); also your COBOL system will assign storage for COMPUTATIONAL items in one of two modes; byte-storage and word-storage. Byte-storage is the default storage-assignment mode for this COBOL implementation.

Computer Memory Natural Boundaries: The fundamental natural boundaries of a modern computer's memory are usually based on an eight-bit character, known as a byte. Within this fundamental framework, machines fall into two broad categories; those with no other natural boundaries, called here byte-storage computers, and those with other natural boundaries based upon multiples of the fundamental boundary of the byte, called here word-storage computers.

In byte-storage mode, COBOL assigns numeric storage so that each numeric item occupies the minimum number of bytes (see the section Selection Of Character Representation And Radix in this chapter); the SYNCHRONIZED clause has no meaning in the context and hence has no effect.

Within word-storage computers, natural boundaries can occur at 2-byte, 4-byte and/or 8-byte boundaries. The COBOL language can provide such data item storage-assignment and synchronization when the COMPUTATIONAL clause and possibly the SYNCHRONIZED clause are used. This word-storage assignment of COMPUTATIONAL format data is controlled by the Compiler directive IBMCOMP.

Table 2-5 : COMP(UTATIONAL) Format Data Item Character-Position (Byte) Storage Assignment

Number of Digits (9s) in PICTURE Representation Character-Positions (Bytes) of Storage-Assigned
Signed Unsigned Byte-Storage Mode Word-Storage Mode
1-2
3-4
5-6
7-9
10-11
12-14
15-16
17-18
19-21
22-23
24-26
27-28
29-31
32-33
34-35
36-38
1-2
3-4
5-7
8-9
10-12
13-14
15-16
17-19
20-21
22-24
25-26
27-28
29-31
23-33
34-36
37-38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
2
4
4
8
8
8
8
16
16
16
16
16
16
16
16

Synchronization: If a data item description contains the SYNCHRONIZED clause, and word-storage mode is enabled, the position of that item within the computer storage is aligned so that the right-hand (least-significant) end is on a natural boundary of the computer's storage. Extra character positions (bytes) of computer storage are reserved adjacent to synchronized items to achieve this alignment; these bytes, known as padding bytes or implicit FILLER bytes, are normally inaccessible to the computer program except as part of a group item.

Each elementary data item that is described as SYNCHRONIZED is aligned to the natural storage boundary that corresponds to its data item storage assignment (according to Table 2-5 above). Thus, in word-storage mode, a numeric data item with a PICTURE description of S9(5) would be assigned 4 bytes of storage (being 1 padding byte and 3 data bytes). If SYNCHRONIZED was specified, it would be aligned to the next nearest 4-byte boundary (that is, with the total (4-byte) storage assignment aligned such that the number of bytes from the beginning of the record containing that item to the left-hand (most-significant) end of that item was a multiple of four). If the previous item does not end on a 4-byte boundary, implicit FILLER assignments are necessary to achieve this.

Other such implicit FILLER bytes can be generated by the use of SYNCHRONIZED items in non-elementary data descriptions containing an OCCURS clause (see the section The OCCURS Clause in the chapter Data Division - Data Description). This is because further bytes may need to be reserved for each group item occurrence in order that the second or subsequent occurrences have the same alignment to the natural boundaries of the computer storage as did the first occurrence.

Implicit Synchronization: With word-storage mode enabled, all record-level data descriptions are automatically synchronized to a full 8-byte boundary.

Where automatic alignment is enabled, it is sensitive to the ALIGN directive.

Example of Implicit FILLER Assignments: The following COBOL data description will produce the computer storage allocation shown in Figure 2-3. An explanation of the symbols used is given below the figure.

01 UNSYNCHRONIZED-RECORD.
    02 UNSYNCHRONIZED-DATA-1        PIC 9(3) DISPLAY.
    02 UNSYNCHRONIZED-DATA-2        PIC X(2).
01 COMPOUND-REPEATED-RECORD.
    02 ELEMENTARY-ITEM-1            PIC X(2).
    02 GROUP-ITEM OCCURS 3 TIMES.
	03 ELEMENTARY-ITEM-2        PIC X.
	03 ELEMENTARY-ITEM-3        PIC S9(2) COMP SYNC.
	03 ELEMENTARY-ITEM-4        PIC S9(4)V9(2) COMP SYNC.
	03 ELEMENTARY-ITEM-5        PIC X(5).


Figure 2-3: Sample Computer Storage Allocation

where:

@ indicates implicit FILLER bytes allocated due to automatic synchronization of a record (01-level) description.
# indicates implicit FILLER bytes allocated when following data item is explicitly synchronized.
$ indicates implicit FILLER bytes allocated when a non-elementary item is subject to an OCCURS clause.
9 indicates bytes allocated for a numeric DISPLAY character.
A indicates bytes allocated for an alphanumeric DISPLAY character.
C indicates bytes allocated for a COMPUTATIONAL data storage.

Truncation: In data items of USAGE COMP, data is held in binary format as described in the previous sections. The storage allocated for an item can have space for larger numbers than specified by the PICTURE clause. For example, an item described as PIC 99 COMP is normally assigned one byte, which can hold numbers up to 255.

To conform with the rules of ANSI COBOL, numbers behave as decimal numbers, regardless of their format. If, in an arithmetic statement, the result is bigger than the PICTURE clause of a receiving item allows, a size error occurs, and if the ON SIZE ERROR phrase is specified the result is not stored in the receiving item. In a non-arithmetic statement, if this situation occurs, the decimal value is truncated on the left, to the number of digits specified in the PICTURE clause.

However, data in USAGE COMP items can be forced to behave as binary data, that is, truncation occurs only if it is necessary in order for the data to fit the space allocated. The behavior of USAGE COMP items is controlled by the setting of the COBOL Compiler directive TRUNC. This directive selects whether the decimal value is truncated to the picture size, or the binary value is truncated to the space available. It distinguishes between results of arithmetic statements, and data being moved by non-arithmetic statements.

Regardless of the setting of any directive,

an arithmetic statement gives the size error condition if the result has more decimal digits than specified in the PICTURE clause of a receiving item.

Example of Truncation: TheTRUNC Compiler directive can change the results of some operations, as demonstrated in the following examples in which item A is described as PIC 99 COMP.

Operation Result
TRUNC NOTRUNC TRUNC"ANSI"
MOVE 163 TO A 63 163 63
MOVE 263 TO A 63 7 63
MOVE 13 TO A,
ADD 150 TO A
63 163 undefined results
MOVE 13 TO A,
ADD 250 TO A
63 7 undefined results


Notes:

  1. This directive has no effect on the truncation of low-order digits in non-integer data. This always conforms with the behavior specified in ANSI COBOL.

  2. If the IBMCOMP Compiler directive is set, extra upper bytes may be allocated to a COMP item. These are counted in the space allocated. When IBMCOMP is on, padding bytes may be generated before a COMP item with a SYNC clause; these are not part of the item, and are never affected by data stored in the item.

  3. When a value being stored into a signed item is limited to the number of digits by the PICTURE clause, it can never be big enough to overwrite the sign bit. When the NOTRUNC directive is set this is not true, and the value, if large enough, will overwrite the sign bit.


2.6.4.3
COMPUTATIONAL-1, COMPUTATIONAL-2,
FLOAT-SHORT and FLOAT-LONG Formats

These formats are used for internal floating-point data items. Such data items can be used in all syntax where a numeric data item can be used and where the syntax is a part of the ANSI'74, ANSI'85, ISO2000, OSVS, or VSC2 COBOL language definition. Such data items cannot be used where integer data items are required unless explicitly allowed by the rules for a specific COBOL verb. An internal floating-point data item cannot be used in other syntax unless a specific rule allows it.

The internal storage format can differ from operating system to operating system. In all storage formats, four pieces of information are encoded:

  1. the exponent - the power of 10 to which the specific numeric value is multiplied.

  2. the exponent sign - an indication of whether the specific numeric value (mantissa) is multiplied by a "whole" number in the series, 1, 10, 100, and so on, or by a fractional number in the series 1/10, 1/100, 1/1000, and so on.

  3. the mantissa - the specific value, which when multiplied by a power of 10 provides the numeric value of the data item.

  4. the mantissa sign - an indication of whether the resultant value of the data item is negative or positive.

USAGE FLOAT-SHORT is equivalent to USAGE COMPUTATIONAL-1. USAGE FLOAT-LONG is equivalent to USAGE COMPUTATIONAL-2.

Items that are USAGE COMPUTATIONAL-1 (COMP-1) are usually referred to as single precision floating-point items while items that are USAGE COMPUTATIONAL-2 (COMP-2) are usually referred to as double precision floating-point items. Depending on the operating system or mathematical support libraries available to this COBOL system, different constraints can exist for single and double precision floating-point items. There can be constraints on the maximum exponent sizes, on the maximum mantissa sizes, or both. See your operating system or mathematical library floating-point support documentation for additional information.

COMPUTATIONAL-1 and COMPUTATIONAL-2 are equivalent to Single Format and Double Format, respectively, for operating systems that conform to ANSI/IEEE Std 754-1985, IEEE Standard for Binary Floating-Point Arithmetic.

It is important to understand that internal floating-point representation is not a continuous numeric spectrum. Internal floating-point representations are not standard from operating system to operating system. For example, in one representation of internal floating-point values, the following shows internal to decimal equivalence:

Internal (Hexadecimal) Storage
Decimal Value (Scientific Notation)
x"AD17E148" -0.12345673E-23
x"AD17E149" -0.12345810E-23

Therefore, any application which tested for or expected an internal floating-point item with an exact decimal value of -0.12345678E-23, would never find it, while in some other system of internal floating-point storage, that value might be found while the values listed above would never exist. Therefore, any application which tests for exact equivalence between internal floating-point items and other numeric values (including external floating-point items and floating-point literals) cannot be portable and may result in different logic flow even when using the same input data.

For internal floating-point items, the size of the item in storage is determined by its USAGE clause. USAGE COMPUTATIONAL-1 reserves 4 bytes of storage for the item; USAGE COMPUTATIONAL-2 reserves 8 bytes of storage.

When the IBMCOMP Compiler directive is on, padding bytes can be generated before an internal floating-point item with a SYNC clause; these bytes are not part of the item, and are never affected by data stored in the item.

Within the COBOL system, COMP-1 items are accurate to 7 decimal digits and COMP-2 items to 16 decimal digits. However, for mainframe compatibility the DISPLAY statement will show 8 decimal places for COMP-1 and 18 for COMP-2. Any operations using floating-point items should take the limits of accuracy into account, and should disregard decimal places beyond the limits of accuracy.

2.6.4.4 COMPUTATIONAL-3
diala.gifor PACKED-DECIMAL
Format

This format, commonly called binary-coded-decimal format, represents numeric data items in radix 10, but with each digit of the value held in only one half of one computer character, as described in Table 2-6 below. The sign is held in a separate trailing digit (half-character) position; that is, at the right-hand or least significant end of the item.

Any unused half bytes will be set to zero.

Table 2-6: COMPUTATIONAL-3 Digit Representation

Digit Value Digit Representation in Hexadecimal
Left Half-Character (odd digit) Right Half-Character (even digit)
0 x"00" x"00"
1 x"10" x"01"
2 x"20" x"02"
3 x"30" x"03"
4 x"40" x"04"
5 x"50" x"05"
6 x"60" x"06"
7 x"70" x"07"
8 x"80" x"08"
9 x"90" x"09"


Note: Count even and odd starting from the right.


Table 2-7 shows the sign digit used for COMPUTATIONAL-3; storage requirements for this format depend only on the number of "9s" in the PICTURE clause of the data item as shown in Table 2-8.

Table 2-7: COMPUTATIONAL-3 Sign Digit Representation

Sign Convention in the PICTURE Clause Sign of Data Item Value Sign Half-character, in Hexadecimal
Unsigned n/a x"0F"
Signed + x"0C"
Signed x"0D"

Table 2-8: Numeric Data Storage for the COMP(UTATIONAL)-3
or PACKED-DECIMAL
PICTURE Clause.

Bytes Required Number of Digits (Signed or Unsigned)
1 1
2 2-3
3 4-5
4 6-7
5 8-9
6 10-11
7 12-13
8 14-15
9 16-17
10 18-19
11 20-21
12 22-23
13 24-25
14 26-27
15 28-29
16 30-31
17 32-33
18 34-35
19 36-37
20 38

Example:

  1. For COMPUTATIONAL-3 and PICTURE 9999, the number +1234 would be stored as follows:

    where F represents the non-printing plus sign.

  2. For COMPUTATIONAL-3 and PICTURE S9999, the number + 1234 would be stored as follows:

    where C represents the plus sign.

  3. For COMPUTATIONAL-3 and PICTURE S9999, the number -1234 would be stored as follows:

    where D represents the minus sign.

The SYNCHRONIZED clause (with or without the LEFT or RIGHT phrase) has no effect on COMPUTATIONAL-3 data declarations.

2.6.4.5 COMPUTATIONAL-X
dialx.gifand COMPUTATIONAL-5
Formats

These formats are as for COMPUTATIONAL format except for the differences given below. See the section COMPUTATIONAL, BINARY, Or COMPUTATIONAL-4 Format earlier in this chapter.

They both differ in the following ways from the COMPUTATIONAL format:

2.6.4.6 POINTER Format

The POINTER format holds a value that represents the memory address of an available data item. If the data item becomes unavailable (for example, because it is in a program that has been canceled) then the POINTER format is considered to hold a value that is incompatible with the format.

The default amount of storage allocated for the POINTER format may vary depending on the operating environment but will be at least four bytes. The method of representation of the memory address varies between environments and will in general be consistent with the representation used in non-COBOL languages.

When the IBMCOMP system directive is on, padding bytes can be generated before a pointer data item with a SYNC clause; these bytes are not part of the data item and are never affected by data stored in the item.

2.6.4.7 PROCEDURE-POINTER Format

The PROCEDURE-POINTER format holds a value that represents the memory address of an available procedure. If the procedure becomes unavailable (for example, because it is in a program that has been canceled) then the PROCEDURE-POINTER format is considered to hold a value that is incompatible with the format.

The default amount of storage allocated for the PROCEDURE-POINTER format may vary depending on the operating environment but will be at least four bytes. If the COBOL370 directive is specified, then eight bytes of storage are allocated. The method of representation of the memory address varies between environments and will in general be consistent with the representation used in non-COBOL languages.

When the IBMCOMP system directive is on, padding bytes can be generated before a procedure-pointer data item with a SYNC clause; these bytes are not part of the data item and are never affected by data stored in the item.

2.6.5 Uniqueness of Reference

2.6.5.1 Qualification

Every user-specified name that defines an element in a COBOL source element.

and is referenced in that source element

must be unique, either because no other name has the identical spelling and hyphenation, or because the name exists within a hierarchy of names such that references to the name can be made unique by mentioning one or more of the higher levels of the hierarchy. The higher levels are called qualifiers and the process that specifies uniqueness is called qualification. Enough qualification must be mentioned to make the name unique; however, it may not be necessary to mention all levels of the hierarchy.

In the Data Division, all data-names used for qualification must be associated with a level indicator or a level-number. Therefore, two identical data-names must not appear as entries subordinate to a group item unless they are capable of being made unique through qualification

or unless they are never referenced

. In the Procedure Division, two identical paragraph-names must not appear in the same section.

In the hierarchy of qualification, names associated with a level indicator are the most significant, followed by those names associated with level-number 01, followed by names associated with level-number 02 through 49. A section-name is the highest (and the only) qualifier available for a paragraph-name. Thus, the most significant name in the hierarchy must be unique and cannot be qualified. Subscripted or indexed data-names and conditional variables, as well as procedure-names and data-names, can be made unique by qualification. The name of a conditional variable can be used as a qualifier for any of its condition-names. Regardless of the available qualification, no name can be both a data-name and procedure-name.

Qualification is performed by following a data-name, a condition-name, a paragraph-name, or a text-name by one or more phrases composed of a qualifier preceded by IN or OF, which are logically equivalent.

When the resource named is a function, the function definition may require the user to specify in the reference to the function a value or set of values for one or more parameters which determine the value of the function for that particular reference. This is accomplished through the specification of arguments as described in the section Function-Identifier later in this chapter.

The general formats for qualification are:

Format 1

Format 2

Format 3

Format 4

The rules for qualification are as follows:

  1. Each qualifier must be of a successively higher level and within the same hierarchy as the name it qualifies.

  2. The same name must not appear at two levels in a hierarchy

    if it is explicitly referenced within the source unit.

  3. If a data-name or a condition-name is assigned to more than one data item in a source element, the data-name or condition-name must be qualified each time it is referred to in the Procedure, Environment, and Data Divisions (except in the REDEFINES clause, where qualification must not be used).

  4. A paragraph-name must not be duplicated within a section. When a paragraph-name is qualified by a section-name, the word SECTION must not appear. A paragraph-name need not be qualified when referred to from within the same section.

    Neither a paragraph-name nor a section-name need be unique, or capable of being made unique, unless explicitly referenced.

  5. A data-name cannot be subscripted when it is being used as a qualifier.

  6. A name can be qualified even when it does not need qualification; if there is more than one combination of qualifiers that ensures uniqueness, then any such set can be used. The complete set of qualifiers for a data-name must not be the same as any partial set of qualifiers for another data-name.

    Qualified data-names can have up to five qualifiers.

    Up to fifty qualifiers are permitted.

  7. If more than one COBOL library is available to your COBOL system, text-name must be qualified each time it is referenced.

    This restriction is not enforced.

2.6.5.2 Subscripting

Subscripts can be used only when reference is made to an individual element within a list or table of like elements that have not been assigned individual data-names (see the section The OCCURS Clause in the chapter Data Division - Data Description).

The subscript can be represented either by a numeric literal that is an integer, by a data-name, or by a data-name followed by the operator "+" or "–" , followed by an unsigned integer numeric literal. The data-name must be a numeric elementary item that represents an integer, and the whole subscript must be delimited by the balanced pair of separators, left-parenthesis and right-parenthesis.

The subscript data-name can be signed and, if signed, must be positive. The lowest possible subscript value is 1. This value points to the first element of the table. The next sequential elements of the table are pointed to by subscripts whose values are 2, 3, ... . The highest permissible subscript value, in any particular case, is the maximum number of occurrences of the item as specified in the OCCURS clause.

The subscript, or set of subscripts, that identifies the table element is delimited by the balanced pair of separators, left parenthesis and right parenthesis following the table element data-name. The table element data-name appended with a subscript is called a subscripted data-name or an identifier. When more than one subscript is required, they are written in the order of successively less inclusive dimensions of the data organization. Up to 3 subscripts are permitted.

Up to 7 subscripts are permitted.

Up to 16 subscripts are permitted.

General Format

Syntax Rules

  1. The data description entry containing data-name-1 or the data-name associated with condition-name-1 must contain an OCCURS clause or must be subordinate to a data description entry which contains an OCCURS clause.

  2. Except as defined in Syntax Rule 7, when a reference is made to a table element, the number of subscripts must equal the number of OCCURS clauses in the description of the table element being referenced. When more than one subscript is required, the subscripts are written in the order of successively less inclusive dimensions of the table.

  3. The subscript ALL can be used only when the subscripted identifier is used as a function argument and cannot be used when condition-name-1 is specified. (See the section Arguments in the chapter Procedure Division - Intrinsic Functions.)

  4. Integer-1 can be signed, and if signed, must be positive.

  5. Data-name-2 can be qualified and must be a numeric elementary item representing an integer.

  6. Index-name-1 must correspond to a data description entry in the hierarchy of the table being referenced which contains an INDEXED BY phrase specifying that index-name. An index described for some other table can be used instead, provided the two tables have elements of the same size.

  7. Each table element reference must be subscripted except when such reference appears:

    1. in a USE FOR DEBUGGING statement

    2. as the subject of a SEARCH or SORT statement

    3. in a REDEFINES clause

    4. in the KEY IS phrase of an OCCURS clause.

  8. The mixing of subscripts and indices in the same identifier is illegal.

    The mixing of subscripts and indices in the same identifier is legal.

General Rules

If the NOBOUND Compiler directive is specified, these General Rules are not applicable at run time.

  1. The value of the subscript must be a positive integer. The lowest possible occurrence number represented by a subscript is 1. The first element of any given dimension of a table is referenced by an occurrence number of 1. Each successive element within that dimension of the table is referenced by occurrence numbers of 2, 3, ... . The highest permissible occurrence number for any given dimension of the table is the maximum number of occurrences of the item specified in the associated OCCURS clause.

    If the subscript is a floating-point data item, the value will be rounded to the nearest integer, otherwise any fractional part will be truncated.

  2. The value of the index referenced by index-name-1 corresponds to the occurrence number of an element in the associated table.

  3. The value of the index referenced by index-name-1 must be initialized before it is used as a subscript. An index can be given an initial value by either a PERFORM statement with the VARYING phrase, a SEARCH statement with the ALL phrase, or a SET statement. An index can be modified only by the PERFORM, SEARCH, and SET statements.

  4. If

    integer-2 or

    integer-3 is specified, the value of the subscript is determined by incrementing by the value of

    integer-2 or

    integer-3 (when the operator "+" is used) or by decrementing by the value of

    integer-2 or

    integer-3 (when the operator "-" is used),

    either

    the occurrence number represented by the value of the index referenced by index-name-1

    or the value of the data item referenced by data-name-2.

2.6.5.3 Indexing

References can be made to individual elements within a table of like elements by specifying indexing for that reference. An index is assigned to that level of the table by using the INDEXED BY phrase in the definition of a table. A name given in the INDEXED BY phrase is known as an index-name and is used to refer to the assigned index. The value of an index corresponds to the occurrence number of an element in the associated table or any other table. An index-name must be initialized before it is used as a table reference. An index-name can be given an initial value by a SET statement.

Unlike a subscript, which is simply a numeric data item or literal, an index is a special type of item and holds a representation of an occurrence number. The form of this representation can vary; the contents of an index cannot be regarded as a numeric value.

Direct indexing is specified by using an index-name in the form of a subscript. Relative indexing is specified when the index-name is followed by the operator "+" or "–", followed by an unsigned integer numeric literal, all delimited by the balanced pair of separators left parenthesis and right parenthesis following the table element data-name. The occurrence number resulting from relative indexing is determined by incrementing (where the operator "+" is used) or decrementing (where the operator "–" is used), by the value of the literal, the occurrence number represented by the value of the index. When more than one index-name is required, they are written in the order of successively less inclusive dimensions of the data organization.

A table can be indexed only by the index described in its INDEXED BY phrase.

An index described for some other table can be used instead provided the two tables have elements of the same size.

At the time of execution of a statement which refers to an indexed table element, the value contained in the index used to index it must neither correspond to a value less than one nor to a value greater than the highest permissible occurrence number of an element of the associated table. This restriction also applies to the value resulting from relative indexing.

If the NOBOUND Compiler directive is specified, this rule is not applicable at run time.

Up to 3 index-names can be used with a data-name.

Up to 7 index-names can be used with a data-name.

Up to 16 index-names can be used with a data-name.

The general format for indexing is included in the general format for subscripting earlier in this chapter.

2.6.5.4 Function-identifier

A function-identifier is a syntactically correct combination of character strings and separators that uniquely references the data item resulting from the evaluation of a function.

General Format

   FUNCTION function-name-1 [({argument-1}...)] [reference-modifier]

Syntax Rules

  1. Argument-1 must be an identifier, a literal, or an arithmetic expression. Specific rules governing the number, class, and category of argument-1 are given in the definition of each function. (See the chapter Procedure Division - Intrinsic Functions.)

  2. A reference modifier can be specified only for functions of the category alphanumeric

    or national.

  3. A function-identifier that references an alphanumeric

    or national

    function can be specified anywhere in the general formats that an identifier is permitted and where the rules associated with the general formats do not specifically prohibit reference to functions, except:

    1. as a receiving operand of any statement

    2. where the rules associated with the general formats require the data item being referenced to have particular characteristics (such as class and category, usage, size, sign, and permissible values) and the evaluation of the function according to its definition and the particular arguments specified would not have these characteristics.

  4. A function-identifier that references an integer or numeric function can be used only in an arithmetic expression

    , or as the source of a MOVE statement.

General Rules

  1. The class and other characteristics of the function being referenced are determined by the function definition.

  2. At the time reference is made to a function, its arguments are evaluated individually in the order specified in the list of arguments, from left to right. An argument being evaluated can itself be a function-identifier or can be an expression containing function-identifiers. There is no restriction preventing the function referenced in evaluating an argument from being the same function as that for which the argument is specified. In other words, recursion is permitted.

    If a function is expecting an integer argument, then if a floating-point argument is provided, the value will be rounded to the nearest integer, otherwise any fractional part will be truncated.

2.6.5.5 Reference Modification

Reference modification defines a data item by specifying a leftmost character and length for the data item. Unless otherwise specified, it is allowed anywhere an identifier referencing an alphanumeric data item is permitted.

General Format


Note: Data-name-1 and FUNCTION function-name-1 (argument-1) are shown in the above format to provide context and are not part of the reference-modifier.


Syntax Rules

  1. Data-name-1 must reference a data item whose usage is DISPLAY.

  2. Leftmost-character-position and length must be arithmetic expressions.

  3. Unless otherwise specified, reference modification is allowed anywhere an identifier referencing a data item of the class alphanumeric is permitted.

  4. Data-name-1 can be qualified and/or subscripted.

  5. The function referenced by function-name-1 and its arguments, if any, must be an alphanumeric function.

General Rules

  1. Each character of a data item referenced by data-name-1 or by function-name-1 and its arguments, if any, is assigned an ordinal number incrementing by one from the leftmost position to the rightmost position. The leftmost position is assigned the ordinal number one. If the data description entry for data-name contains a SIGN IS SEPARATE clause, the sign position is assigned an ordinal number within that data item.

  2. If the data item referenced by data-name-1 is described as numeric,

    external floating-point,

    numeric edited, alphabetic, or alphanumeric edited, it is operated upon for purposes of reference modification as if it were redefined as an alphanumeric data item of the same size as the data item referenced by data-name.

  3. Reference modification for an operand is evaluated as follows:

    1. If subscripting is specified for the operand, the reference modification is evaluated immediately after evaluation of the subscripts. If an ALL subscript is specified for an operand, the reference-modifier is applied to each of the implicitly specified elements of the table.

    2. If subscripting is not specified for the operand, the reference modification is evaluated at the time subscripting would have been evaluated if subscripts had been specified.

    3. If reference modification is specified in a function reference, the reference modification is evaluated immediately after evaluation of the function.

  4. Reference modification creates a unique data item that is a subset of the data item referenced by data-name-1 or by function-name-1 and its arguments, if any. This unique data item is defined as follows:

    1. The evaluation of leftmost-character-position specifies the ordinal position of the leftmost character of the unique data item in relation to the leftmost character of the data item referenced by data-name-1 or by function-name-1 and its arguments, if any. Evaluation of leftmost-character-position must result in a positive nonzero integer less than or equal to the number of characters in the data item referenced by data-name-1 or by function-name-1 and its arguments, if any.

      The results are rounded if the expression is in floating-point, and truncated if the expression is in fixed-point.

    2. The evaluation of length specifies the size in bytes of the data item to be used in the operation. The evaluation of length must result in a positive nonzero integer. The sum of leftmost-character-position and length minus the value one, must be less than, or equal to, the number of characters in the data item referenced by data-name-1 or by function-name-1 and its arguments, if any. If length is not specified, the unique data item extends from and includes the character identified by leftmost-character-position, up to and including the rightmost character of the data item referenced by data-name-1 or by function-name-1 and its arguments, if any.

      The results are rounded if the expression is in floating-point, and truncated if the expression is in fixed-point.

  5. The unique data item is considered an elementary data item without the JUSTIFIED clause. When a function is referenced, the unique data item has the class and category of alphanumeric. When data-name-1 is specified, the unique data item has the same class and category as that defined for the data item referenced by data-name except that the categories numeric, numeric edited, alphanumeric edited

    and external

    floating-point are considered class and category alphanumeric.

  6. If the OSVS Compiler directive is set, reference modification cannot be used in conditional expressions (see the chapter Procedure Divisionfor a description of conditional expressions).

2.6.5.6 Identifier

An identifier is a sequence of character-strings and separators used to reference data uniquely.

When a data item other than a
function or
object-property
is being referenced,

identifier is a term used to reflect that a data-name, if not unique in a source element, must be followed by a syntactically correct combination of qualifiers, subscripts,

or reference-modifiers

necessary for uniqueness of reference.

General Formats

Format 1

Format 2

Format 3
   property-name-1 OF identifier-1
Rules for Format 2

Subscript-1 represents either subscripting (see the section Subscripting earlier in this section) or indexing (see the section Indexing earlier in this section).

  1. The words IN and OF are equivalent.

  2. A data-name must neither be subscripted nor indexed when it is being used as an index, or subscript.

  3. Indexing is not permitted where subscripting is not permitted.

  4. An index can be modified only by the SET, SEARCH, and PERFORM statements. Data items described by the USAGE IS INDEX clause permit storage of the values associated with index-names as data. Such data items are called index data items.

  5. Literals used as subscripts must be positive numeric integers. Literals used for relative subscripting and indexing must be unsigned numeric integers.
Rules for Format 3

Object properties provide a special syntax to get information out of and pass information back into an object. The mechanisms for accessing object properties are get property methods and set property methods. A get property method is a method explicitly defined with the GET PROPERTY phrase or a method implicitly generated for a data item described with the PROPERTY clause; a set property method is a method explicitly defined with the SET PROPERTY phrase or a method implicitly generated for a data items described with the PROPERTY clause.

  1. Property-name-1 must be an object property specified in the REPOSITORY paragraph.

  2. Identifier-1 must be an object reference; neither a universal object reference, nor the predefined object reference NULL can be specified.

  3. If the object property is used as a sending item, a get property method must exist for property-name-1 in the object referenced by identifier-1.

  4. If the object property is used as a receiving item, a set property method must exist for property-name-1 in the object referenced by identifier-1.

  5. The description of an object property used as a sending item is the same as the description of the returning item of the get property method. This object property can be specified wherever a data item with that description would be valid as a sending item.

  6. The description of an object property used as a receiving item is the same as the description of the using parameter of the set property method. This object property may be specified wherever a data item with that description would be valid as a receiving item.

  7. The data description of the item specified in the RETURNING phrase of the get property method must be the same as the data description of the item specified as the USING parameter of the set property method.

  8. When an object property is used only as a sending item, a conceptual temporary data item, temp-1 is used in its place. The value of the property is determined as though the associated get property method were invoked, in accordance with the rules of the INVOKE statement, and the returned value placed in temp-1. The data description of temp-1 is the same as the data description of the item specified in the RETURNING phrase of the get property method.

  9. When an object property is used only as a receiving item, a conceptual temporary data item, temp-2, is used in its place. The value of the property is assigned as though the associated set property method were invoked, in accordance with the rules of the INVOKE statement, passing the content of temp-2 as the parameter. The data description of temp-2 is the same as the data description of the item specified as the USING parameter of the set property method.

  10. When an object property is used as both a sending item and a receiving item, conceptual temporary data items temp-1 and temp-2 are used in its place; temp-1 and temp-2 are the same temporary data item, where temp-2 redefines temp-1. For sending operations, the value of the property is determined in the same manner as for sending items in general rule 1; for receiving operations, the value of the property is assigned in the same manner as for receiving items in general rule 2. The data descriptions of temp-1 and temp-2 are the same as the data description of the item specified in the RETURNING phrase of the get property method.

2.6.5.7 Condition-Name

Each condition-name must be unique, or be made unique through qualification and/or indexing, or subscripting. If qualification is used to make a condition-name unique, the associated conditional variable can be used as the first qualifier. The hierarchy of names associated with the conditional variable or the conditional variable itself must be used to make the condition-name unique.

If references to a conditional variable require indexing or subscripting, references to any of its condition-names require the same combination of indexing or subscripting.

The format and restrictions on the combined use of qualification, subscripting, and indexing of condition-names are exactly those of "identifier" except that data-name-1 is replaced by condition-name-1.

In the general formats, "condition-name" refers to a condition-name qualified, indexed or subscripted, as necessary.

2.6.6 Explicit and Implicit Specifications

There are four types of explicit and implicit specifications that occur in COBOL source elements:

  1. Explicit and implicit Procedure Division references.

  2. Explicit and implicit transfers of control.

  3. Explicit and implicit attributes.

  4. Explicit and implicit scope terminators.

2.6.6.1 Explicit and Implicit Procedure Division References

A COBOL source element can reference data items either explicitly or implicitly in Procedure Division statements. An explicit reference occurs when the name of the referenced item is written in a Procedure Division statement or when the name of the referenced item is copied into the Procedure Division by the processing of a COPY statement

, a REPLACE statement

, a -INC statement, or ++INCLUDE statement

. An implicit reference occurs when the item is referenced by a Procedure Division statement without the name of the referenced item being written in the source statement.

An implicit reference also occurs during the execution of a PERFORM statement, when the index or data item referenced by the index-name or identifier specified in the VARYING, AFTER or UNTIL phrase is initialized, modified, or evaluated by the control mechanism associated with that PERFORM statement. Such an implicit reference occurs if and only if the data item contributes to the execution of the statement.

2.6.6.2 Explicit and Implicit Transfers of Control

The flow of control mechanism transfers control from statement to statement in the sequence in which they were written unless an explicit transfer of control overrides this sequence or there is no next executable statement to which control may be passed. The transfer of control from statement to statement occurs without the writing of an explicit procedure division statement, and, therefore, is an implicit transfer of control.

COBOL provides both an explicit and an implicit means of altering the implicit control transfer mechanism.

In addition to the implicit transfer of control between consecutive statements, implicit transfer of control occurs when the normal flow is altered without the execution of a procedure branching statement. COBOL provides the following types of implicit control flow alterations which override the statement-to-statement transfers of control:

  1. If a paragraph is being executed under control of another COBOL statement (for example, PERFORM, USE, SORT and MERGE) and the paragraph is the last paragraph in the range of the controlling statement, then an implied transfer of control occurs from the last statement in the paragraph to the control mechanism of the last executed controlling statement. Further, if a paragraph is being executed under the control of a PERFORM statement which causes iterative execution and that paragraph is the first paragraph in the range of that PERFORM statement, an implicit transfer of control occurs between the control mechanism associated with that PERFORM statement and the first statement in that paragraph for each iterative execution of the paragraph.

  2. When a SORT or MERGE statement is executed, an implicit transfer of control occurs to any associated input or output procedures.

  3. When any COBOL statement is executed that results in the execution of a declarative section, an implicit transfer of control to the declarative section occurs.

Note: Another implicit transfer of control occurs after execution of the declarative section, as described in item 1. above.


An explicit transfer of control consists of an alteration of the implicit control transfer mechanism by the execution of a procedure branching, ending or conditional statement. An explicit transfer of control between statements can be caused only by the execution of a procedure branching or conditional statement. An explicit transfer of control between sentences can be caused only by the execution of the NEXT SENTENCE phrase of an IF or SEARCH statement.

The execution of the procedure branching statement ALTER does not in itself constitute an explicit transfer of control, but affects the explicit transfer of control that occurs when the associated GO TO statement is executed. The procedure branching statement EXIT PROGRAM causes an explicit transfer of control only when the statement is executed in a called program.

The term "next executable sentence" is used to refer to the next COBOL sentence to which control is either implicitly transferred according to the rules above, or explicitly transferred as a result of execution of the NEXT SENTENCE phrase. The next executable sentence is the first sentence following the separator period that terminates the current sentence. There is no next executable sentence when there is no next executable statement as described below.

The term "next executable statement" is used to refer to the next COBOL statement to which control is transferred according to the rules above and the rules associated with each language element in the Procedure Division.

There is no next executable statement following:

2.6.6.3 Explicit and Implicit Attributes

Attributes can be implicitly or explicitly specified. Any attribute which has been explicitly specified is called an explicit attribute. If an attribute has not been specified explicitly, then the attribute takes on the default specification. Such an attribute is known as an implicit attribute.

For example, the usage of a data item need not be specified, in which case a data item's usage is DISPLAY

, unless the PICTURE character-string contains a "G" or an "N", in which case a data item's usage is DISPLAY-1.

2.6.6.4 Explicit and Implicit Scope Terminators

Scope terminators delimit the scope of certain Procedure Division statements (delimited scope statements), and are of two types: explicit and implicit.

The explicit scope terminators are listed below:

END-ADD
END-PERFORM

END-ACCEPT

END-CALL

END-CHAIN

END-COMPUTE
END-DELETE

END-DISPLAY

END-DIVIDE
END-EVALUATE
END-IF
END-MULTIPLY
END-READ
END-RECEIVE
END-RETURN
END-REWRITE
END-SEARCH
END-START
END-STRING
END-SUBTRACT
END-UNSTRING
END-WRITE


Note: In some cases the delimited scope statement with which an explicit scope delimiter is paired, is determined differently for different COBOL language specifications.


Implicit scope termination occurs:


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousIntroduction to the COBOL Language Concepts of a Compilation GroupNext"