ILE COBOL Language Reference

COBOL Words

COBOL words must be character-strings from the

set of letters, digits, the hyphen, and the underscore. (The hyphen and the underscore cannot appear as the first or last character, however.) In the ILE COBOL language, each lowercase letter is generally equivalent to the corresponding uppercase letter.

The five types of COBOL words are:

The following rules apply to all COBOL words that are not special character words within a source program:

User-Defined Words

The types of user-defined words are listed below, with the rules that must be followed in forming them.

Types of User-Defined Words
General Rules
alphabet-name
class-name
condition-name
constant-name
data-name
file-name
index-name
locale-name
mnemonic-name
program-name
(for contained programs and
outermost programs that are
called using the PROCEDURE
linkage convention)
record-name
routine-name
type-name
Each word must contain at least one letter.
library-name
program-name
(for outermost programs that
are called using the PROGRAM
linkage convention)
text-name
Each word must contain at least one letter. The first 10 characters must form a unique word.
paragraph-name
section-name
The word need not contain an alphabetic character.
Level-numbers: 01-49,66,77,88
Segment-numbers: 00-99
Each word must be a 1- or 2-digit integer; it does not have to be unique. (Segmentation information is syntax checked only.)

The function of each user-defined word is described in the clause or statement in which it appears.

Related Information:

Constraints for Referencing User-Defined Words

In general, a user-defined word belongs to one, and only one, of the types listed in the preceding table. A user-defined word must also be unique within the type to which it belongs.

There are two exceptions to the general rule:

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

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

The following types of names, when they are declared within a Configuration Section, can be referenced by statements and entries either in that program which contains a Configuration Section or in any program contained within that program:

System-Names

A system-name is a character-string

that is defined by IBM to have a specific meaning to the system. There are four types of system-names:

Computer-name can be written in DBCS characters, but the other system-names cannot.

Function-Names

A function-name is a word that is one of a specified list of words used in COBOL source programs.

A function-name specifies the mechanism provided by ILE COBOL to determine the value of an intrinsic function.

With the exception of the words LENGTH, RANDOM, SUM, and WHEN-COMPILED, a word that is a function-name, in a different context, can appear in a program as a user-defined word, a system-name, or a context-sensitive word.

+-------------------------------IBM Extension--------------------------------+

Context-Sensitive Words

A context-sensitive word is a COBOL word that is formed according to rules for reserved words, and may be used as specified in the general formats. The same word may also be used as a function-name, a user-defined word, or a system-name.

ILE COBOL context-sensitive words are listed in Appendix D, ILE COBOL Function-Name and Context-Sensitive Word List.

+----------------------------End of IBM Extension----------------------------+

Reserved Words

A reserved word is a character-string with a predefined meaning in a COBOL source program, and can be used only as specified in the language defined formats.

ILE COBOL reserved words are listed in Appendix E, ILE COBOL Reserved Word List.

There are five types of reserved words:

Keywords

Keywords are reserved words that are required within a given clause, entry, or statement.

Optional Words

Optional words are reserved words that may be included in the format of a clause, entry, or statement in order to improve readability. They have no effect on the meaning or execution of the program. Optional words are shown in formats as uppercase, but appear below the main path.

Special Character Words

There are two types of special character words:

Figurative Constants

Figurative constants are reserved words that name and refer to specific constant values. The reserved words for figurative constants and their meanings are:

ZERO/ZEROS/ZEROES
Represents one of the following, depending on the context:

+-------------------------------IBM Extension--------------------------------+

+----------------------------End of IBM Extension----------------------------+

SPACE/SPACES
Represents one or more blanks or spaces; treated as a nonnumeric literal. SPACES represent one or more double-byte spaces when used with DBCS data items. SPACES represent one or more single-byte UCS-2 spaces when used with national data items.
HIGH-VALUE/HIGH-VALUES
Represents one or more occurrences of the character that has the highest ordinal position in the collating sequence used. For the NATIVE and EBCDIC collating sequences, the character is X'FF'; for the STANDARD-1 and STANDARD-2 collating sequences, the character is X'07'; for other collating sequences, the actual character used depends on the collating sequence. HIGH-VALUE is treated as a nonnumeric literal.
LOW-VALUE/LOW-VALUES
Represents one or more occurrences of the character that has the lowest ordinal position in the collating sequence used. For the NATIVE, EBCDIC, STANDARD-1, and STANDARD-2 collating sequences, the character is X'00'; for other collating sequences, the actual character used depends on the collating sequence. LOW-VALUE is treated as a nonnumeric literal.
QUOTE/QUOTES
Represents one or more occurrences of the quotation mark character and must be nonnumeric. QUOTE, or QUOTES cannot be used in place of a quotation mark or an apostrophe to enclose a nonnumeric literal.

+-------------------------------IBM Extension--------------------------------+

When APOST is specified as a compiler option, the figurative constant QUOTE has the EBCDIC value of an apostrophe.

+----------------------------End of IBM Extension----------------------------+

ALL literal
Represents one or more occurrences of the string of characters comprising the literal. The literal must be a nonnumeric literal or a figurative constant other than the ALL literal.

When a figurative constant other than ALL literal is used, the word ALL is redundant and is used for readability only. The figurative constant ALL literal must not be used with the INSPECT, STOP, or STRING statements.

Note:
The figurative constant ALL literal, when associated with a numeric or numeric-edited item and when the length of the literal is greater than one, is an obsolete element and is to be deleted from the next revision of the ANSI Standard.

+-------------------------------IBM Extension--------------------------------+

The literal used in an ALL literal can be a Boolean literal, DBCS literal, or national hexadecimal literal.

+----------------------------End of IBM Extension----------------------------+

+-------------------------------IBM Extension--------------------------------+

NULL/NULLS
Represents a value used to indicate that a data item defined with the USAGE IS POINTER clause, USAGE IS PROCEDURE-POINTER clause, ADDRESS OF phrase, or ADDRESS OF special register does not contain a valid address. NULL can be used only where explicitly allowed in the syntax format.

In the ILE COBOL language, a value of NULL is undefined.

+----------------------------End of IBM Extension----------------------------+

The singular and plural forms of ZERO, SPACE, HIGH-VALUE, LOW-VALUE, QUOTE, and NULL are equivalent, and may be used interchangeably. For example, if DATA-NAME-1 is a 5-character data item, each of the following statements will fill DATA-NAME-1 with five spaces:

MOVE SPACE TO DATA-NAME-1
MOVE SPACES TO DATA-NAME-1
MOVE ALL SPACES TO DATA-NAME-1

A figurative constant can be used wherever 'literal' appears in a format, except where explicitly prohibited. When a numeric literal appears in a format, only the figurative constant ZERO can be used. Figurative constants are not allowed as function arguments except in an arithmetic expression, where they are arguments to a function.

+-------------------------------IBM Extension--------------------------------+

The figurative constant ZERO can be used as a Boolean literal.

+----------------------------End of IBM Extension----------------------------+

The length of a figurative constant depends on the context of the program. The following rules apply:

Special Registers

Special registers are reserved words that name storage areas generated by the compiler. Their primary use is to store information produced through specific COBOL features. Each such storage area has a fixed name, and must not be further defined within the program.

In the general formats of this specification, a special register can be used, unless otherwise restricted, wherever a data-name or identifier is specified provided that the special register is the same category as the data-name or identifier. If qualification is allowed, special registers can be qualified as necessary to provide uniqueness.

When control of a program is transferred for the first time from one program to another within the run unit by the CALL statement, the compiler initializes the special register fields to their initial values. The RETURN-CODE and SORT-RETURN special registers are reset to their initial values in the following instances:

In all other cases, the special registers are not reset to their initial values. Instead, they remain unchanged from the value retained the previous time program control was transferred via the CALL statement.

You can specify an alphanumeric register in a function wherever an alphanumeric argument is allowed, unless specifically prohibited.

You can specify a numeric special register in a function wherever a numeric argument is allowed, unless specifically prohibited.

Each special register is discussed in the section beginning on the indicated page.

The special registers are:

This register is syntax checked only.

Special Register
Page

DEBUG-ITEM
This register is syntax checked only.

LINAGE-COUNTER
"LINAGE-COUNTER Special Register"

+-------------------------------IBM Extension--------------------------------+

ADDRESS OF
"ADDRESS OF Special Register"

DB-FORMAT-NAME
"DB-FORMAT-NAME Special Register"

LENGTH OF
"LENGTH OF Special Register"

LOCALE OF
"LOCALE OF Special Register"

FORMAT OF
"FORMAT OF Special Register"

RETURN-CODE
"RETURN-CODE Special Register"

SORT-RETURN
"SORT-RETURN Special Register"

WHEN-COMPILED
"WHEN-COMPILED Special Register"

XML-CODE
"XML-CODE Special Register"

XML-EVENT
"XML-EVENT Special Register"

XML-NTEXT
"XML-NTEXT Special Register"

XML-TEXT
"XML-TEXT Special Register"

+----------------------------End of IBM Extension----------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]