COBOL Language Reference
COBOL Language Reference
Language Reference
SC26-9046-04
Note!
Before using this information and the product it supports, be sure to read the general
information under “Notices” on page 520.
Order publications by phone or fax. IBM Software Manufacturing Solutions takes publication orders between
8:30 a.m. and 7:00 p.m. Eastern Standard Time (EST). The phone number is (800) 879-2755. The fax number is
(800) 445-9269. You can also order publications through your IBM representative or the IBM branch office serving
your locality. Publications are not stocked at the address below.
Editions marked “softcopy only” cannot be ordered as printed publications. For information about obtaining these
editions, see “Softcopy publications for IBM COBOL” on page 524.
A form for reader's comments appears at the back of this publication. If the form has been removed, address your
comments to:
http://www.ibm.com/software/ad/rcf/
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any
way it believes appropriate without incurring any obligation to you.
Copyright International Business Machines Corporation 1991, 2000. All rights reserved.
US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract
with IBM Corp.
Contents
About this book . . . . . . . . . . . . . . . . . vi
Compatibility with previous IBM COBOL products Part 2. COBOL source unit
(OS/390 and VM only) . . . . . . . . . . . . . . . vi structure . . . . . . . . . . . . . . . . . . . . 57
IBM extensions . . . . . . . . . . . . . . . . . . . . vi
Obsolete language elements . . . . . . . . . . . . . vi
How to read the syntax diagrams . . . . . . . . . . vii COBOL program structure . . . . . . . . 58
DBCS notation . . . . . . . . . . . . . . . . . . . . ix Nested programs . . . . . . . . . . . . . . . . . . . 60
Acknowledgment . . . . . . . . . . . . . . . . . . . . x
COBOL class definition structure . . . . 63
Summary of changes . . . . . . . . . . . . . xi
Fifth edition (September 2000) . . . . . . . . . . . . xi COBOL method definition structure . . 65
Fourth edition (November 1998) . . . . . . . . . . . xi
Third edition (August 1998, softcopy only) . . . . . xii
Second edition (April 1998) . . . . . . . . . . . . . xii
Part 3. Identification Division . . . . 67
Contents v
About this book
This book presents the syntax of COBOL for OS/390 & VM, COBOL Set for AIX,
and VisualAge COBOL (collectively referred to in this book as IBM COBOL). To
indicate platform-specific information, this book use the following methods:
Prefix the text with platform-specific indicators (for example, Under AIX and
Windows...)
Add parenthetical qualifications (for example, (Workstation only))
Prefix the text with icons. This book uses the following icons:
Informs you of information specific to COBOL for OS/390 & VM.
Notes:
1. This book documents extensions for object-oriented COBOL. Object-oriented
COBOL is not supported under VM.
| 2. This book documents support for 31-digit decimal data, which is available
| when the ARITH(EXTEND) compiler option is in effect. The ARITH compiler
| option, and the 31-digit support, are currently only available in COBOL for
| OS/390 & VM.
Use this book in conjunction with the IBM COBOL Programming Guide for your
platform.
IBM extensions
IBM extensions generally add to language element rules or restrictions. In the
hardcopy, published book, IBM extensions appear in blue ink. For example:
IBM extensions in text are shown this way.
IBM extensions are not indicated in the appendixes, glossary, or index.
Format
──STATEMENT──required item───────────────────────────────────────────
When you can choose from two or more items, they appear vertically, in a
stack.
If you must choose one of the items, one item of the stack appears on the main
path.
Format
──STATEMENT──┬─required choice 1─┬───────────────────────────────────
└─required choice 2─┘
If choosing one of the items is optional, the entire stack appears below the
main path.
Format
──STATEMENT──┬───────────────────┬───────────────────────────────────
├─optional choice 1─┤
└─optional choice 2─┘
An arrow returning to the left above the main line indicates an item that can
be repeated.
Format
┌──
─────────────────┐
──STATEMENT───/─repeatable item─┴─────────────────────────────────────
A repeat arrow above a stack indicates that you can make more than one
choice from the stacked items, or repeat a single choice.
Variables appear in all lowercase letters (for example, parmx). They represent
user-supplied names or values.
If punctuation marks, parentheses, arithmetic operators, or such symbols are
shown, they must be entered as part of the syntax.
The following example shows how the syntax is used.
└─literal-1──────┘ (3) ┘
└─┤ item 1 ├─── └─ROUNDED─┘
(5)──┬─────────────────┬──────────────────────────
──┬────────────────────────────────────────────┬──
└─┬────┬──SIZE ERROR──imperative-statement-1─┘ (6) ┘
└─END-STATEMENT───
└─ON─┘
item 1
├──┬─identifier-2──────────────┬───────────────────────────────────────────────────────────────────┤
├─literal-2─────────────────┤
(7) ┘
└─arithmetic-expression-1───
Notes:
1 The STATEMENT key word must be specified and coded as shown.
3 The item 1 fragment is optional; it can be coded or not, as required by the application. If item 1
is coded, it can be repeated with each entry separated by one or more COBOL separators. Entry
selections allowed for this fragment are described at the bottom of the diagram.
4 The operand identifier-3 and associated TO key word are required and can be repeated with one
or more COBOL separators separating each entry. Each entry can be assigned the key word
ROUNDED.
5 The ON SIZE ERROR phrase with associated imperative-statement-1 are optional. If the ON
delimiter.
7 The blue text indicates that arithmetic-expression-1 is an IBM extension. This operand is
optional.
DBCS notation
Double-Byte Character Strings (DBCS) in literals, comments, and
user-defined words are delimited by shift-out and shift-in characters. In this
manual, the shift-out delimiter is represented pictorially by the < character, and the
shift-in character is represented pictorially by the > character. The EBCDIC codes
for the shift-out and shift-in delimiters are X'0E' and X'0F', respectively.
The <> symbol denotes contiguous shift-out and shift-in characters. The >< symbol
denotes contiguous shift-in and shift-out characters.
Double-byte characters are represented in this form: D1D2D3. EBCDIC characters
in double-byte form are represented in this form:.A.B.C. The dots separating the
letters represent the hexadecimal value X'42'.
Under AIX and Windows, you do not delimit DBCS character strings
by shift-in or shift-out characters.
Characters
The most basic and indivisible unit of the COBOL language is the character. The
IBM COBOL character set includes the letters of the alphabet, digits, and special
characters. The complete set of characters that form the IBM COBOL character set
is shown in Table 1 on page 3.
The basic IBM COBOL language is restricted to the character set shown in Table 1
on page 3, but the content of nonnumeric literals, comment lines, comment entries,
and data can include any of the characters from the character set of the computer.
In some cases, the basic character set is extended with the national character set.
The national character set support includes the Double-Byte Character Set (DBCS)
and, additionally for AIX, the Extended Unix Code (EUC) code page.
Double-byte characters, as the name implies, occupy two adjacent bytes to
represent 1 character. A character string containing DBCS characters is called a
DBCS character-string.
Under AIX, characters from the EUC code page can be from one to four
bytes long.
DBCS and EUC characters are valid characters in certain COBOL character-strings.
For details, see “COBOL words with multi-byte characters” on page 4 and “DBCS
literals” on page 21.
Individual characters are joined to form character-strings, separators, and text
words.
A character-string is a character or a sequence of contiguous characters that forms
a COBOL word, a literal, a PICTURE character-string, or a comment-entry. A
character-string is delimited by separators.
A separator is a string of one or two contiguous characters used to delimit
character strings. Separators are described in detail under “Separators” on
page 24.
A text word is a character or a sequence of contiguous characters between
character positions 8 and 72 inclusive on a line in a COBOL library, source
program, or in pseudo-text. For more information on pseudo-text, see
“Pseudo-text” on page 33.
Character-strings
You can use EBCDIC and/or DBCS character strings under OS/390 and VM or
ASCII and/or DBCS/EUC character-strings under AIX and Windows to form the
following:
COBOL words
Literals
PICTURE character-strings (EBCDIC or ASCII character-strings only)
Comment text
User-defined words
The following sets of user-defined words are supported:
Multi-byte characters allowed?
Alphabet-name Yes
Function-names
A function-name specifies the mechanism provided to determine the value of an
intrinsic function. The same word, in a different context, can appear in a program
as a user-defined word or a system-name. For a list of function-names and their
definitions, see Table 51 on page 409.
Reserved words
A reserved word is a character-string with a predefined meaning in a COBOL
source program. IBM COBOL reserved words are listed in Appendix D,
“Reserved words” on page 506.
For information on selecting an alternate reserved word table, see the IBM COBOL
Programming Guide for your platform.
There are six types of reserved words:
Keywords
Optional words
Figurative constants
Special character words
Special object identifiers
Special registers
Keywords
Keywords are reserved words that are required within a given clause, entry, or
statement. Within each format, such words appear in uppercase on the main
path.
Optional words
Optional words are reserved words that can be included in the format of a
clause, entry, or statement in order to improve readability. They have no
effect on the execution of the program.
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 the numeric value zero (0), or one or more occurrences of the
nonnumeric character zero (0), depending on context.
When the context cannot be determined, a nonnumeric zero is used.
SPACE/SPACES
Represents one or more blanks or spaces. SPACE is treated as a nonnumeric
literal.
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 EBCDIC collating
sequence, the character is X'FF'; for other collating sequences, the actual
character used depends on the collating sequence indicated by the locale. For
more information on locale, see Appendix F, “Locale considerations
You can use a figurative constant wherever “literal” appears in a syntax diagram,
except where explicitly prohibited. When a numeric literal appears in a syntax
diagram, only the figurative constant ZERO (ZEROS, ZEROES) can be used.
Figurative constants are not allowed as function arguments except in an arithmetic
expression, where they are arguments to a function.
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
defined within the program.
Unless otherwise explicitly restricted, a special register can be used wherever a
data-name or identifier having the same definition as the implicit definition of the
special register, (which is specified later in this section).
If qualification is allowed, special registers can be qualified as necessary to provide
uniqueness. (For more information, see “Qualification” on page 39.)
For the first CALL to a program or INVOKE of a method, the compiler initializes
the special register fields to their initial values.
In the following cases:
For subsequent CALLs to a CANCELed program
Programs that possess the INITIAL attribute
Programs that possess the RECURSIVE attribute
Programs compiled with the THREAD option (Workstation only)
The following special registers are reset to their initial value on each program or
method entry:
ADDRESS OF (for each record in the Linkage Section)
RETURN-CODE
SORT-CONTROL
SORT-CORE-SIZE
SORT-FILE-SIZE
SORT-MESSAGE
SORT-MODE-SIZE
SORT-RETURN
TALLY
In all other cases, the special registers will not be reset; they will be unchanged
from the value contained on the previous CALL or INVOKE.
You can specify an alphanumeric special register in a function wherever an
alphanumeric argument to a function is allowed, unless specifically prohibited.
ADDRESS OF
The ADDRESS OF special register exists for each record (01 or 77) in the Linkage
Section, except for those records that redefine each other. In such cases, the
ADDRESS OF special register is similarly redefined.
DEBUG-ITEM
The DEBUG-ITEM special register provides information for a debugging
declarative procedure about the conditions causing debugging section execution.
DEBUG-ITEM has the following implicit description:
?1 DEBUG-ITEM.
?2 DEBUG-LINE PICTURE IS X(6).
?2 FILLER PICTURE IS X VALUE SPACE.
?2 DEBUG-NAME PICTURE IS X(3?).
?2 FILLER PICTURE IS X VALUE SPACE.
?2 DEBUG-SUB-1 PICTURE IS S9999 SIGN IS LEADING SEPARATE CHARACTER.
?2 FILLER PICTURE IS X VALUE SPACE.
?2 DEBUG-SUB-2 PICTURE IS S9999 SIGN IS LEADING SEPARATE CHARACTER.
?2 FILLER PICTURE IS X VALUE SPACE.
?2 DEBUG-SUB-3 PICTURE IS S9999 SIGN IS LEADING SEPARATE CHARACTER.
?2 FILLER PICTURE IS X VALUE SPACE.
?2 DEBUG-CONTENTS PICTURE IS X(n).
LENGTH OF
The LENGTH OF special register contains the number of bytes used by an
identifier.
LENGTH OF creates an implicit special register whose content is equal to the
current byte length of the data item referenced by the identifier.
Note: For DBCS data items, each character occupies 2 bytes of storage.
LENGTH OF can be used in the Procedure Division anywhere a numeric data item
having the same definition as the implied definition of the LENGTH OF special
register can be used. The LENGTH OF special register has the implicit definition:
USAGE IS BINARY PICTURE 9(9)
If the data item referenced by the identifier contains the GLOBAL clause, the
LENGTH OF special register is a global data item.
The LENGTH OF special register can appear within either the starting character
position or the length expressions of a reference modification specification.
However, the LENGTH OF special register cannot be applied to any operand that
is reference-modified.
The LENGTH OF operand cannot be a function, but the LENGTH OF special
register is allowed in a function where an integer argument is allowed.
Note: The number of bytes occupied by a COBOL item is also accessible through
the intrinsic function LENGTH (see “LENGTH” on page 430). LENGTH supports
nonnumeric literals in addition to data names.
LINAGE-COUNTER
A separate LINAGE-COUNTER special register is generated for each FD entry
containing a LINAGE clause. When more than one is generated, you must qualify
each reference to a LINAGE-COUNTER with its related file-name.
The implicit description of the LINAGE-COUNTER special register is one of the
following:
If the LINAGE clause specifies a data-name, LINAGE-COUNTER has the same
PICTURE and USAGE as that data-name.
If the LINAGE clause specifies an integer, LINAGE-COUNTER is a binary item
with the same number of digits as that integer.
For more information, see “LINAGE clause” on page 140.
The value in LINAGE-COUNTER at any given time is the line number at which
the device is positioned within the current page. LINAGE-COUNTER can be
referred to in Procedure Division statements; it must not be modified by them.
LINAGE-COUNTER is initialized to 1 when an OPEN statement for its associated
file is executed.
LINAGE-COUNTER is automatically modified by any WRITE statement for this
file. (See “WRITE statement” on page 393.)
If the file description entry for a sequential file contains the LINAGE clause and
the EXTERNAL clause, the LINAGE-COUNTER data item is an external data item.
If the file description entry for a sequential file contains the LINAGE clause and
the GLOBAL clause, the LINAGE-COUNTER data item is a global data item.
RETURN-CODE
The RETURN-CODE special register can be used to pass a return code to the
calling program or operating system when the current COBOL program ends.
When a COBOL program ends:
If control returns to the operating system, the value of the RETURN-CODE
special register is passed to the operating system as a user return code. The
supported user return code values are determined by the operating system,
and might not include the full range of RETURN-CODE special register values.
For information on user return code values under AIX, see the IBM
COBOL Set for AIX Programming Guide.
If control returns to a calling program, the value of the RETURN-CODE special
register is passed to the calling program. If the calling program is a COBOL
program, the RETURN-CODE special register in the calling program is set to
the value of the RETURN-CODE special register in the called program.
The RETURN-CODE special register has the implicit definition:
?1 RETURN-CODE GLOBAL PICTURE S9(4) USAGE BINARY VALUE ZERO
The following are examples of how to set the RETURN-CODE special register:
COMPUTE RETURN-CODE = 8
or
MOVE 8 to RETURN-CODE.
When used in nested programs, this special register is implicitly defined in the
outermost program.
Note: The RETURN-CODE special register does not return a value from an
invoked method or from a program that uses CALL...RETURNING. For more
information, see “INVOKE statement” on page 307 or “CALL statement” on
page 260.
You can specify the RETURN-CODE special register in a function wherever an
integer argument is allowed.
The RETURN-CODE special register will not contain return code information:
On the host, from a service call for a Language Environment callable service.
For more information, see the IBM COBOL for OS/390 & VM Programming
Guide and Language Environment Programming Guide.
On the workstation, from a date/time callable service. For more information,
see the IBM COBOL Programming Guide for your platform.
?1 DBCSGRP.
?5 SO PIC X.
?5 DBCSITEM PIC G(3) USAGE DISPLAY-1
?5 SI PIC X.
..
.
PROCEDURE DIVISION.
MOVE SHIFT-OUT TO SO
MOVE G"<D1D2D3>" TO DBCSITEM
MOVE SHIFT-IN TO SI
DISPLAY DBCSGRP
When used in nested programs, this special register is implicitly defined in the
outermost program.
SORT-CONTROL
The SORT-CONTROL special register is the name of an alphanumeric data item.
Where "file name" is the file name used by SMARTSort as the source for additional
sort/merge options.
Under OS/390 and VM it is implicitly defined as:
?1 SORT-CONTROL GLOBAL PICTURE X(8) USAGE DISPLAY VALUE "IGZSRTCD"
This register contains the ddname of the data set that holds the control statements
used to improve the performance of a sorting or merging operation.
Under OS/390, you can provide a DD statement for the data set identified by the
SORT-CONTROL special register, and COBOL for OS/390 & VM will attempt to
open the data set at execution time. Any error will be diagnosed with an
informational message.
You can specify the SORT-CONTROL special register in a function wherever an
alphanumeric argument is allowed.
The SORT-CONTROL special register is not necessary for a successful sorting or
merging operation.
Note that the sort control file takes precedence over the SORT special registers.
When used in nested programs, this special register is implicitly defined in the
outermost program.
SORT-FILE-SIZE
The SORT-FILE-SIZE special register is the name of a binary data item that you
can use to specify the estimated number of records in the sort input file,
file-name-1. It has the implicit definition:
?1 SORT-FILE-SIZE GLOBAL PICTURE S9(8) USAGE BINARY VALUE ZERO
SORT-MESSAGE
The SORT-MESSAGE special register is the name of an alphanumeric data item
that is available to both sort and merge programs.
You can use the SORT-MESSAGE special register to specify the ddname of a data
set that the sort utility should use in place of the SYSOUT data set.
The ddname specified in SORT-MESSAGE is equivalent to the name specified on
the 'MSGDDN=' control statement in the sort control file.
You can specify the SORT-MESSAGE special register in a function wherever an
alphanumeric argument is allowed.
When used in nested programs, this special register is implicitly defined in the
outermost program.
SORT-MODE-SIZE
The SORT-MODE-SIZE special register is the name of a binary data item that you
can use to specify the length of variable-length records that occur most frequently.
It has the implicit definition:
?1 SORT-MODE-SIZE GLOBAL PICTURE S9(5) USAGE BINARY VALUE ZERO
SORT-RETURN
The SORT-RETURN special register is the name of a binary data item and is
available to both sort and merge programs.
The SORT-RETURN special register has the implicit definition:
?1 SORT-RETURN GLOBAL PICTURE S9(4) USAGE BINARY VALUE ZERO
WHEN-COMPILED
The WHEN-COMPILED special register contains the date at the start of the
compilation. WHEN-COMPILED is an alphanumeric data item with the implicit
definition:
?1 WHEN-COMPILED GLOBAL PICTURE X(16) USAGE DISPLAY
Note: The compilation date and time is also accessible via the date/time intrinsic
function WHEN-COMPILED (See “WHEN-COMPILED” on page 459). That
function supports 4-digit year values, and provides additional information.
Literals
A literal is a character-string whose value is specified either by the characters of
which it is composed, or by the use of a figurative constant. (See “Figurative
constants” on page 7.) The literal types are nonnumeric, DBCS, and numeric.
Nonnumeric literals
A nonnumeric literal is a character string enclosed in quotation marks ("), and can
contain any allowable character from the character set of the computer. The
maximum length of a nonnumeric literal is 160 characters.
The enclosing quotation marks are excluded from the literal when the program is
compiled. An embedded quotation mark must be represented by a pair of
quotation marks (""). For example,
"THIS ISN""T WRONG"
The delimiter character used as the opening delimiter for a literal must be used as
the closing delimiter for that literal. For example,
'THIS IS RIGHT'
"THIS IS RIGHT"
'THIS IS WRONG"
Any punctuation characters included within a nonnumeric literal are part of the
value of the literal.
Every nonnumeric literal is in the alphanumeric data category. (Data categories
are described in “Classes and categories of data” on page 127.)
Table 4 lists when nonnumeric literals with double-byte or multiple-byte
characters cannot be used.
" The opening and closing delimiter (Alternatively, you can use apostrophes (')
as delimiters.)
< Represents the shift-out control character (X'0E')
> Represents the shift-in control character (X'0F')
Shift-out and shift-in control characters are part of the literal and must be paired
with zero or an even number of intervening bytes.
Nested shift codes are not allowed in the DBCS portion of the literal.
The syntax rules for EBCDIC parts of the literal follow the rules for nonnumeric
literals. The syntax rules for DBCS parts of the literal follow the rules for DBCS
literals. The move and comparison rules for nonnumeric literals with double-byte
characters are the same as those for any nonnumeric literal.
The length of a nonnumeric literal with double-byte characters is its byte length,
including the shift control characters. The maximum length is limited by the
available space on one line in Area B. A nonnumeric literal with double-byte
characters cannot be continued.
A nonnumeric literal with double-byte characters is of the alphanumeric category.
Under COBOL for OS/390 & VM, COBOL statements process nonnumeric literals
with double-byte characters without sensitivity to the shift codes and character
codes. The use of statements that operate on a byte-to-byte basis (for example,
STRING and UNSTRING) can result in strings that are not valid mixtures of
EBCDIC and double-byte characters. You must be certain that the statements use
DBCS characters. See IBM COBOL for OS/390 & VM Programming Guide for more
information on using nonnumeric literals and data items with double-byte
characters in statements that operate on a byte-by-byte basis.
Hexadecimal notation can be used for nonnumeric literals. This hexadecimal
notation has the following format:
Numeric literals
A numeric literal is a character-string whose characters are selected from the digits
0 through 9, a sign character (+ or -), and the decimal point. If the literal contains
no decimal point, it is an integer. (In this manual, the word integer appearing in a
format represents a numeric literal of nonzero value that contains no sign and no
decimal point; any other restrictions are included with the description of the
format.) The following rules apply:
| If the ARITH(COMPAT) compiler option is in effect, then one through 18
| digits are allowed. If the ARITH(EXTEND) compiler option is in effect, then
| one through 31 digits are allowed.
Only one sign character is allowed. If included, it must be the leftmost
character of the literal. If the literal is unsigned, it is a positive value.
The sign is optional before the mantissa and the exponent; if you omit the
sign, the compiler 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 1 or 2
digits.
Under OS/390 and VM, the magnitude of a floating-point literal
value must fall between 0.54E-78 and 0.72E+76. For values outside of this
range, an E-level diagnostic will be produced and the value will be replaced by
either 0 or 0.72E+76, respectively.
Under AIX and Windows, the magnitude of a floating-point
literal value must fall between:
— 32-bit representation—1.175(10-38) to 3.403(1038)
— 64-bit representation—2.225(10-308) to 1.798(10308)
Every numeric literal is in the numeric data category. (Data categories are
described under “Classes and categories of data” on page 127.)
DBCS literals
Table 5 lists the formats and rules for DBCS literals. You can use either quotes or
apostrophes for the opening and closing delimiters.
Table 5 (Page 1 of 2). Format and rules for forming DBCS literals
Rules OS/390 and VM AIX and Windows
Format G"<D1D2D3>" G"D1D2D3"
N"<D1D2D3>" N"D1D2D3"
PICTURE character-strings
A PICTURE character-string is composed of the currency symbol and certain
combinations of characters in the COBOL character set. PICTURE character-strings
are delimited only by the separator space, separator comma, separator semicolon,
or separator period.
A chart of PICTURE clause symbols appears in Table 11 on page 161.
Comments
A comment is a character-string that can contain any combination of characters
from the character set of the computer. It has no effect on the execution of the
program. There are two forms of comments:
Comment entry (Identification Division)
This form is described under “Optional paragraphs” on page 76.
Comment line (any division)
This form is described under “Comment lines” on page 32.
Character-strings that form comments can contain:
Under OS/390 and VM, DBCS characters or a combination of DBCS
and EBCDIC characters.
Under AIX and Windows any character from the code page in
effect.
Multiple comment lines containing DBCS/EUC strings are allowed. The
embedding of DBCS/EUC characters in a comment line must be done on a
Separators
A separator is a string of one or more contiguous characters as shown in Table 6.
The IBM COBOL character set does not include a tab character (ASCII
code 9). You cannot use the tab character as a separator in IBM COBOL.
Space {␣}
A space can immediately precede or follow any separator except:
The opening pseudo-text delimiter, where the preceding space is required.
Within quotation marks. Spaces between quotation marks are considered
part of the nonnumeric literal; they are not considered separators.
Period {.␣}, Comma {,␣}, Semicolon {;␣}
A separator comma is composed of a comma followed by a space; a separator
period is composed of a period followed by a space; a separator semicolon is
composed of a semicolon followed by a space.
The separator period must be used only to indicate the end of a sentence, or as
shown in formats. The separator comma and separator semicolon can be used
anywhere the separator space is used.
In the Identification Division, each paragraph must end with a separator
period.
In the Environment Division, the SOURCE-COMPUTER,
OBJECT-COMPUTER, SPECIAL-NAMES, and I-O-CONTROL paragraphs
must each end with a separator period. In the FILE-CONTROL paragraph,
each File-Control entry must end with a separator period.
In the Data Division, file (FD), sort/merge file (SD), and data description
entries must each end with a separator period.
Entries
An entry is a series of clauses ending with a separator period. Entries are
constructed in the Identification, Environment, and Data Divisions.
Clauses
A clause is an ordered set of consecutive COBOL character-strings that specifies an
attribute of an entry. Clauses are constructed in the Identification, Environment,
and Data Divisions.
Statements
A statement is a valid combination of a COBOL verb and its operands. It specifies
an action to be taken by the object program. Statements are constructed in the
Procedure Division. For descriptions of the different types of statements, see:
“Imperative statements” on page 235
“Conditional statements” on page 236
“Scope of names” on page 35
“Compiler-directing statements” on page 464
Phrases
Each clause or statement in the program can be subdivided into smaller units
called phrases.
Reference format
COBOL programs must be written in the COBOL reference format. Figure 1
shows the reference format for a COBOL source line.
Indicator area
Use the indicator area to specify:
The continuation of words or nonnumeric literals from the previous line onto
the current line
The treatment of text as documentation
Debugging lines
See “Continuation lines” on page 31, “Comment lines” on page 32, and
“Debugging lines” on page 33.
The indicator area can be used for source listing formatting. A slash (“/”) placed
in the indicator column will cause the compiler to start a new page for the source
listing, and the corresponding source record to be treated as a comment. The
effect may be dependent on the LINECOUNT compiler option. For information on
the LINECOUNT compiler option, see the IBM COBOL Programming Guide for
your platform.
Area A
The following items must begin in Area A:
Division header
Section header
Paragraph header or paragraph name
Level indicator or level-number (01 and 77)
DECLARATIVES and END DECLARATIVES
End program, end class, and end method header
Division header
A division header is a combination of words, followed by a separator period, that
indicates the beginning of a division:
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
A division header (except when a USING phrase is specified with a Procedure
Division header) must be immediately followed by a separator period. Except for
the USING phrase, no text can appear on the same line.
Section header
In the Environment and Procedure Divisions, a section header indicates the
beginning of a series of paragraphs; for example:
INPUT-OUTPUT SECTION.
In the Data Division, a section header indicates the beginning of an entry; for
example:
FILE SECTION.
LINKAGE SECTION.
WORKING-STORAGE SECTION.
A section header must be immediately followed by a separator period.
For programs
Program-name must be identical to the program-name of the corresponding
PROGRAM-ID paragraph. Every COBOL program, except an outermost
program that contains no nested programs and is not followed by another
batch program, must end with an END PROGRAM header.
For classes
Class-name must be identical to the class-name of the corresponding CLASS-ID
paragraph.
For methods
Method-name must be identical to the method-name of the corresponding
METHOD-ID paragraph.
Area B
The following items must begin in Area B:
Entries, sentences, statements, clauses
Continuation lines
Continuation lines
Any sentence, entry, clause, or phrase that requires more than one line can be
continued in Area B of the next line that is neither a comment line nor a blank
line. The line being continued is a continued line; the succeeding lines are
continuation lines. Area A of a continuation line must be blank.
If there is no hyphen (-) in the indicator area (column 7) of a line, the last character
of the preceding line is assumed to be followed by a space.
DBCS literals and user-defined words containing multi-byte characters cannot be
continued.
Both characters making up the opening delimiter must be on the same line for the:
Hexadecimal notation of a nonnumeric literal (X" or X')
Hexadecimal notation of a null-terminated nonnumeric literal (Z" or Z')
If there is a hyphen in the indicator area of a line, the first nonblank character of
this continuation line immediately follows the last nonblank character of the
continued line without an intervening space.
If the continued line contains a nonnumeric literal without a closing quotation
mark, all spaces at the end of the continued line (through column 72) are
considered to be part of the literal. The continuation line must contain a hyphen
in the indicator area, and the first nonblank character must be a quotation mark.
The continuation of the literal begins with the character immediately following the
quotation mark.
| If a nonnumeric literal that is to be continued on the next line has as its last
| character a quotation mark in column 72, the continuation line must start with two
| consecutive quotation marks. This will result in a single quotation mark as part of
the value of the nonnumeric literal.
If the last character on the continued line of a nonnumeric literal is a single
quotation mark in Area B, the continuation line can start with a single quotation
mark. This will result in two consecutive nonnumeric literals instead of one
continued nonnumeric literal.
Both characters making up the pseudo-text delimiter separator “==” must be on
the same line.
To continue a literal such that the continued lines and the continuation lines are
part of one literal:
Code a hyphen in the indicator area of each continuation line.
Do not terminate the continued lines with a single quotation mark followed by
a space.
Code the literal value using all columns of the continued lines, up to and
including column 72.
Code a quotation mark before the first character of the literal on each
continuation line.
Terminate the last continuation line with a single quotation mark followed by
a space.
Example
|...+.V..1....+....2....+....3....+....4....+....5....+....6....+....7..
?????1 "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEE
- "GGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJKKKKKKKKKK
- "LLLLLLLLLLMMMMMMMMMM"
?????5 "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEE
- "GGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJKKKKKKKKKK
- "LLLLLLLLLLMMMMMMMMMM"
????1? "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEE"
- "GGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJKKKKKKKKKK"
- "LLLLLLLLLLMMMMMMMMMM"
Note: To code a continued literal where the length of each continued segment of
the literal is less than the length of Area-B, adjust the starting column such that the
last character of the continued segment is in column 72.
Area A or Area B
The following items can begin in either Area A or Area B:
Level-numbers
Comment lines
Compiler-directing statements
Debugging lines
Pseudo-text
Level-numbers
A level-number that can begin in Area A or B is a 1- or 2-digit integer with a value
of 02 through 49; 66, or 88. A level-number that must begin in Area A is a 1- or
2-digit integer with a value of 01 or 77. It must be followed by a space or a
separator period. For more information, see “Level-numbers” on page 146.
Comment lines
A comment line is any line with an asterisk (*) or slash (/) in the indicator area
(column 7) of the line. The comment can be written anywhere in Area A and Area
B of that line, and can consist of any combination of characters from the character
Note: Comments intermixed with control cards could nullify some of the control
cards and cause them to be diagnosed as errors.
Multiple comment lines are allowed. Each must begin with either an asterisk (*) or
a slash (/) in the indicator area.
An asterisk (*) comment line is printed on the next available line in the output
listing. The effect may be dependent on the LINECOUNT compiler option. For
information on the LINECOUNT compiler option, see the IBM COBOL
Programming Guide for your platform. A slash (/) comment line is printed on the
first line of the next page, and the current page of the output listing is ejected.
The compiler treats a comment line as documentation, and does not check it
syntactically.
Compiler-directing statements
Most compiler-directing statements can start in either Area A or Area B, including
COPY and REPLACE.
As an IBM extension BASIS, CBL (PROCESS), *CBL (*CONTROL), DELETE,
EJECT, INSERT, SKIP1/2/3, and TITLE can also start in Area A or Area B.
Debugging lines
A debugging line is any line with a 'D' (or 'd') in the indicator area of the line.
Debugging lines can be written in the Environment Division (after the
OBJECT-COMPUTER paragraph), the Data Division, and the Procedure Division.
If a debugging line contains only spaces in Area A and Area B, it is considered a
blank line.
See “WITH DEBUGGING MODE” in “SOURCE-COMPUTER paragraph” on
page 80.
Pseudo-text
The character-strings and separators comprising pseudo-text can start in either
Area A or Area B. If, however, there is a hyphen in the indicator area (column 7)
of a line which follows the opening pseudo-text delimiter, Area A of the line must
be blank, and the rules for continuation lines apply to the formation of text words.
Scope of names
A COBOL resource is any resource in a COBOL program that is referenced via a
user-defined word. You can use names to identify COBOL resources. This section
describes COBOL names and their scope. It explains the range of where the names
can be referenced and the range of their usability and accessibility.
Types of names
In addition to identifying a resource, a name can have global or local attributes.
Some names are always global, some names are always local, and some names are
either local or global depending on specifications in the program in which the
names are declared.
For programs
A global name can be used to refer to the resource with which it is associated
both:
From within the program in which the global name is declared
From within any other program that is contained in the program that
declares the global name
You use the GLOBAL clause in the data description entry to indicate that a
name is global. For more information on using the GLOBAL clause, see
“GLOBAL clause” on page 134.
A local name can be used only to refer to the resource with which it is
associated from within the program in which the local name is declared.
By default, if a data-name, a file-name, a record-name, or a condition-name
declaration in a data description entry does not include the GLOBAL clause,
the name is local.
For classes and methods
Names declared in a class definition are global to all the methods contained in
that class definition. All names declared in methods are implicitly local.
Note: Specific rules sometimes prohibit specifying the GLOBAL clause for certain
data description, file description, or record description entries.
The following list indicates the names you can use and whether the name can be
local or global:
data-name
Data-name assigns a name to a data item.
A data-name is global if the GLOBAL clause is specified either in the data
description entry that declares the data-name, or in another entry to which that
data description entry is subordinate.
file-name
File-name assigns a name to a file connector.
A file-name is global if the GLOBAL clause is specified in the file description
entry for that file-name.
Scope of names 37
Resolution of names
Two programs or methods in a run unit can reference the same file connector in
the following circumstances:
An external file connector can be referenced from any program or method that
describes that file connector.
If a program is contained within another program, both programs can refer to
a global file connector by referring to an associated global file-name either in
the containing program, or in any program that directly or indirectly contains
the containing program.
Two programs or methods in a run unit can reference common data in the
following circumstances:
The data content of an external data record can be referenced from any
program or method provided that program or method has described that data
record.
If a program is contained within another program, both programs can refer to
data possessing the global attribute either in the program or in any program
that directly or indirectly contains the containing program.
The data records described as subordinate to a file description entry that does not
contain the EXTERNAL clause or a sort-merge file description entry, as well as any
data items described subordinate to the data description entries for such records,
are always internal to the program or method describing the file-name. If the
EXTERNAL clause is included in the file description entry, the data records and
the data items attain the external attribute.
Resolution of names
When a program, program B, is directly contained within another program,
program A, both programs can define a condition-name, a data-name, a file-name,
or a record-name using the same user-defined word. When such a duplicated
name is referenced in program B, the following steps determine the referenced
resource (note, these rules also apply to classes and contained methods):
1. The referenced resource is identified from the set of all names which are
defined in program B and all global names defined in program A and in any
programs which directly or indirectly contain program 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 resource is identified.
2. If only one resource is identified, it is the referenced resource.
3. If more than one resource is identified, no more than one of them can have a
name local to program B. If zero or one of the resources has a name local to
program B, the following applies:
If the name is declared in program B, the resource in program B is the
referenced resource.
If the name is not declared in program B, the referenced resource is:
— The resource in program A if the name is declared in program A.
— The resource in the containing program if the name is declared in the
program containing program A.
This rule is applied to further containing programs until a valid resource is
found.
Uniqueness of reference
Every user-defined name in a COBOL program is assigned by the user to name a
resource for solving a data processing problem. To use a resource, a statement in
a COBOL program must contain a reference which uniquely identifies that
resource. To ensure uniqueness of reference, a user-defined name can be qualified,
subscripted, or reference-modified.
When the same name has been assigned in separate programs to two or more
occurrences of a resource of a given type, and when qualification by itself does not
allow the references in one of those programs to differentiate between the
identically named resources, then certain conventions that limit the scope of names
apply. The conventions ensure that the resource identified is that described in the
program containing the reference. For more information on resolving
program-names, see “Resolution of names” on page 38.
Unless otherwise specified by the rules for a statement, any subscripts and
reference modification are evaluated only once as the first step in executing that
statement.
Qualification
A name can be made unique if it exists within a hierarchy of names by specifying
one or more higher-level names in the hierarchy. The higher-level names are
called qualifiers, and the process by which such names are made unique is called
qualification.
Qualification is specified by placing one or more phrases after a user-specified
name, with each phrase made up of the word IN or OF followed by a qualifier (IN
and OF are logically equivalent).
In any hierarchy, the data name associated with the highest level must be unique if
it is referenced, and cannot be qualified.
You must specify enough qualification to make the name unique; however, it is
not always necessary to specify all the levels of the hierarchy. For example, if
there is more than one file whose records contain the field EMPLOYEE-NO, but only
one of the files has a record named MASTER-RECORD:
EMPLOYEE-NO OF MASTER-RECORD sufficiently qualifies EMPLOYEE-NO
EMPLOYEE-NO OF MASTER-RECORD OF MASTER-FILE is valid but unnecessary
Qualification rules
The rules for qualifying a name are:
A name can be qualified even though it does not need qualification except in a
REDEFINES clause, in which case it must not be qualified.
Identical names
When programs are directly or indirectly contained within other programs, each
program can use identical user-defined words to name resources. With
identically-named resources, a program will reference the resource which that
program describes rather than the same-named resource described in another
program, even when it is a different type of user-defined word.
These same rules apply to classes and their contained methods.
If more than one COBOL library is available to the compiler during compilation, as
an IBM extension, text-name-1 need not be qualified each time it is referenced; a
qualification of SYSLIB is assumed.
For rules on referencing COPY libraries, see “COPY statement” on page 468.
Format 2
──section-name-1─────────────────────────────────────────────────────────
Format
──data-name-1────────────────────────────────────────────────────────────
data-name-1
Can be any data description entry.
Data-name-1 must be unique in a program.
Identifier
When used in a syntax diagram in this manual, the term identifier refers to a
valid combination of a data-name or function-identifier with its qualifiers,
subscripts, and reference-modifiers as required for uniqueness of reference. Rules
for identifiers associated with a format can, however, specifically prohibit
qualification, subscripting, or reference-modification.
The term data-name refers to a name that must not be qualified, subscripted, or
reference modified, unless specifically permitted by the rules for the format.
For a description of qualification, see “Qualification” on page 39.
For a description of subscripting, see “Subscripting” on page 43.
For a description of reference modification, see “Reference modification” on
page 46.
Format 1
┌──
─────────────────────────┐
──data-name-1───/─┬─────────────────────┬─┴──┬─────────────────────┬───────
└─┬─IN─┬──data-name-2─┘ └─┬─IN─┬──file-name-1─┘
└─OF─┘ └─OF─┘
┌──
─────────────────────┐
───/─┬─────────────────┬─┴──────────────────────────────────────────────────
└─(──subscript──)─┘
──┬────────────────────────────────────────────────┬──────────────────────
└─(──leftmost-character-position:──┬────────┬──)─┘
└─length─┘
Format 1
┌──
─────────────────────────┐
──┬─condition-name-1─┬───/─┬─────────────────────┬─┴───────────────────────
└─data-name-1──────┘ └─┬─IN─┬──data-name-2─┘
└─OF─┘
──┬─────────────────────┬─────────────────────────────────────────────────
└─┬─IN─┬──file-name-1─┘
└─OF─┘
Format 2
──LINAGE-COUNTER──┬─────────────────────┬────────────────────────────────
└─┬─IN─┬──file-name-2─┘
└─OF─┘
data-name-1, data-name-2
Can be a record-name.
condition-name-1
Can be referenced by statements and entries either in that program containing
the Configuration Section or in a program contained within that program.
file-name-1
Must be identified by an FD or SD entry in the Data Division.
Must be unique within this program.
LINAGE-COUNTER
Must be qualified each time it is referenced if more than one file description
entry containing a LINAGE clause has been specified in the source program.
file-name-2
Must be identified by the FD or SD entry in the Data Division. File-name-2
must be unique within this program.
Duplication of data-names must not occur in those places where the data-name
cannot be made unique by qualification.
In the same program, the data-name specified as the subject of the entry whose
level-number is 01 that includes the EXTERNAL clause must not be the same
data-name specified for any other data description entry that includes the
EXTERNAL clause.
In the same Data Division, the data description entries for any two data items for
which the same data-name is specified must not include the GLOBAL clause.
Data Division names that are explicitly referenced must either be uniquely defined
or made unique through qualification. Unreferenced data items need not be
uniquely defined. The highest level in a data hierarchy must be uniquely named,
if referenced. This is a data item associated with a level indicator (FD or SD in the
File Section) or with a level-number 01. Data items associated with level-numbers
02 through 49 are successively lower levels of the hierarchy.
condition-name-1
Can be referenced by statements and entries either in the program containing
the definition of condition-name-1, or in a program contained within that
program.
If explicitly referenced, a condition-name must be unique or be made unique
through qualification and/or subscripting except when the scope of names
conventions by themselves ensure uniqueness of reference.
If qualification is used to make a condition-name unique, the associated
conditional variable can be used as the first qualifier. If qualification is used,
the hierarchy of names associated with the conditional variable itself must be
used to make the condition-name unique.
If references to a conditional variable require subscripting, reference to any of
its condition-names also requires the same combination of subscripting.
In the general format of the chapters that follow, "condition-name" refers to a
condition-name qualified or subscripted, as necessary.
data-name-1
Can be a record-name.
file-name-1
Must be identified by an FD or SD entry in the Data Division.
File-name-1 must be unique within this program.
mnemonic-name-1
For information on acceptable values for mnemonic-name-1, see
“SPECIAL-NAMES paragraph” on page 83.
Subscripting
Subscripting is a method of providing table references through the use of
subscripts. A subscript is a positive integer whose value specifies the occurrence
number of a table element.
condition-name-1
The conditional variable for condition-name-1 must contain an OCCURS clause
or must be subordinate to a data description entry which contains an OCCURS
clause.
data-name-1
Must contain an OCCURS clause or must be subordinate to a data description
entry which contains an OCCURS clause.
data-name-2, file-name-1
Must name data items or records that contain data-name-1.
integer-1
Can be signed. If signed, it must be positive.
data-name-3
Must be a numeric elementary item representing an integer.
Data-name-3 can be qualified. Data-name-3 cannot be a windowed date field.
index-name-1
Corresponds to a data description entry in the hierarchy of the table being
referenced which contains an INDEXED BY phrase specifying that name.
integer-2, integer-3
Cannot be signed.
The subscripts, enclosed in parentheses, are written immediately following any
qualification for the name of the table element. The number of subscripts in such
a reference must equal the number of dimensions in the table whose element is
being referenced. That is, there must be a subscript for each OCCURS clause in
the hierarchy containing the data-name including the data-name itself.
When more than one subscript is required, they are written in the order of
successively less inclusive dimensions of the data organization. If a
multi-dimensional table is thought of as a series of nested tables and the most
inclusive or outermost table in the nest is considered to be the major table with the
innermost or least inclusive table being the minor table, the subscripts are written
from left to right in the order major, intermediate, and minor.
Subscripted references can also be reference modified. See the third example
under “Reference modification examples” on page 48. A reference to an item
must not be subscripted unless the item is a table element or an item or
condition-name associated with a table element.
Each table element reference must be subscripted except when such reference
appears:
In a USE FOR DEBUGGING statement
As the subject of a SEARCH statement
In a REDEFINES clause
In the KEY is phrase of an OCCURS clause
The lowest permissible occurrence number represented by a subscript is 1. The
highest permissible occurrence number in any particular case is the maximum
number of occurrences of the item as specified in the OCCURS clause.
Relative subscripting
In relative subscripting, the name of a table element is followed by a subscript of
the form data-name or index-name followed by the operator + or -, and an
unsigned integer literal.
As an IBM extension, the integer can be positively signed.
The operators + and - must be preceded and followed by a space. The value of
the subscript used is the same as if the index-name or data-name had been set up
or down by the value of the integer. The use of relative indexing does not cause
the program to alter the value of the index.
Reference modification
Reference modification defines a data item by specifying a leftmost character and
optional length for the data item.
Format
──┬─data-name-1─────────────────────────────────────────┬─────────────────
└─FUNCTION──function-name-1──┬──────────────────────┬─┘
│ ┌──
────────────┐ │
└─(───/─argument-1─┴──)─┘
──(──leftmost-character-position:──┬────────┬──)──────────────────────────
└─length─┘
data-name-1
Must reference a data item whose usage is DISPLAY or DISPLAY-1.
Data-name-1 can be qualified or subscripted. Data-name-1 cannot be a
windowed date field.
leftmost-character-position
Must be an arithmetic expression. The evaluation of leftmost-character-position
must result in a positive nonzero integer that is less than or equal to the
number of characters in the data item referenced by data-name-1.
Evaluation of operands
Reference modification for an operand is evaluated as follows:
If subscripting is specified for the operand, the reference modification is
evaluated immediately after evaluation of the subscript.
If subscripting is not specified for the operand, the reference modification is
evaluated at the time subscripting would be evaluated if subscripts had been
specified.
The following statement transfers the last 15 characters of the data-item referenced
by WHOLE-NAME to the data-item referenced by LAST-NAME.
The following statement transfers the fourth and fifth characters of the third
occurrence of TAB to the variable SUFFIX.
?1 TABLE-1.
?2 TAB OCCURS 1? TIMES PICTURE X(5).
77 SUFFIX PICTURE X(2).
..
.
Function-identifier
A function-identifier is a syntactically correct sequence of character strings and
separators that uniquely references the data item resulting from the evaluation of a
function.
Format
──FUNCTION──function-name-1──┬──────────────────────┬─────────────────────
│ ┌──
────────────┐ │
└─(───/─argument-1─┴──)─┘
──┬────────────────────┬──────────────────────────────────────────────────
└─reference-modifier─┘
argument-1
Must be an identifier, literal (other than a figurative constant), or arithmetic
expression.
For more information, see “Intrinsic functions” on page 402.
function-name-1
Function-name-1 must be one of the Intrinsic Function names.
reference-modifier
Can be specified only for functions of the category alphanumeric
A function-identifier that makes reference to an alphanumeric function can be
specified anywhere that an identifier is permitted and where references to
functions are not specifically prohibited, except as follows:
Transfer of control
In the Procedure Division, unless there is an explicit control transfer or there is no
next executable statement, program flow transfers control from statement to
statement in the order in which the statements are written. (See Note below.)
This normal program flow is an implicit transfer of control.
In addition to the implicit transfers of control between consecutive statements,
implicit transfer of control also occurs when the normal flow is altered without the
execution of a procedure branching statement. The following examples show
implicit transfers of control, overriding statement-to-statement transfer of control:
After execution of the last statement of a procedure being executed under
control of another COBOL statement, control implicitly transfers. (COBOL
statements that control procedure execution are, for example: MERGE,
PERFORM, SORT, and USE.) 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.
During SORT or MERGE statement execution, control is implicitly transferred
to an input or output procedure.
During execution of any COBOL statement that causes execution of a
declarative procedure, control is implicitly transferred to that procedure.
At the end of execution of any declarative procedure, control is implicitly
transferred back to the control mechanism associated with the statement that
caused its execution.
COBOL also provides explicit control transfers through the execution of any
procedure branching, program call, or conditional statement. (Lists of procedure
branching and conditional statements are contained in “Statement categories” on
page 234.)
Note: The term “next executable statement” refers to the next COBOL statement
to which control is transferred, according to the rules given above. There is no
next executable statement under these circumstances:
When the program contains no Procedure Division
Following the last statement in a declarative section when the paragraph in
which it appears is not being executed under the control of some other COBOL
statement
Following the last statement in a program or method when the paragraph in
which it appears is not being executed under the control of some other COBOL
statement in that program
Following the last statement in a declarative section when the statement is in
the range of an active PERFORM statement executed in a different section and
this last statement of the declarative section is not also the last statement of the
procedure that is the exit of the active PERFORM statement
Following a STOP RUN statement or EXIT PROGRAM statement that transfers
control outside the COBOL program
Following a GOBACK statement that transfers control outside the COBOL
program
Date field
A date field can be any of the following:
A data item whose data description entry includes a DATE FORMAT clause.
A value returned by one of the following intrinsic functions:
DATE-OF-INTEGER
DATE-TO-YYYYMMDD
DATEVAL
DAY-OF-INTEGER
DAY-TO-YYYYDDD
YEAR-TO-YYYY
YEARWINDOW
The conceptual data items DATE, DATE YYYYMMDD, DAY, and DAY
YYYYDDD of the ACCEPT statement.
The result of certain arithmetic operations (for details, see “Arithmetic with
date fields” on page 211).
The term date field refers to both expanded date fields and windowed date fields.
Note: The main use of expanded date fields is to provide correct results when
these are used in combination with windowed date fields; for example, where
migration to 4-digit year dates is not complete. If all the dates in an application
use 4-digit years, there is no need to use the millennium language extensions.
Date format
Date format refers to the date pattern of a date field, specified either:
Explicitly, by the DATE FORMAT clause or DATEVAL intrinsic function
argument-2
or
Implicitly, by statements and intrinsic functions that return date fields (for
details, see “Date field” on page 53)
Century window
A century window is a 100-year interval within which any 2-digit year is unique.
There are several types of century window available to COBOL programmers:
1. For windowed date fields, it is specified by the YEARWINDOW compiler
option
2. For windowing intrinsic functions DATE-TO-YYYYMMDD,
DAY-TO-YYYYDDD, and YEAR-TO-YYYY, it is specified by argument-2
3. For Language Environment callable services, it is specified in CEESCEN
Nested programs
A COBOL program can contain other COBOL programs, which in turn can contain
still other COBOL programs. These contained programs are called nested
programs. Nested programs can be directly or indirectly contained in the
containing program.
A COBOL program can contain other COBOL programs. The contained (or
nested) programs can themselves contain yet other programs. A contained
program can be directly or indirectly contained within another program. Figure 2
describes a nested program structure with directly and indirectly contained
programs.
Figure 2. Nested program structure with directly and indirectly contained programs
If Program-D does not possess the COMMON attribute, then Program-D can only
be referenced by the program that directly contains Program-D, that is, Program-C.
If Program-D does possess the COMMON attribute, then Program-D can be
referenced by Program-C since it contains Program-D and by any programs
contained in Program-C except for programs contained in Program-D. In other
words, if Program-D possesses the COMMON attribute, Program-D can be
referenced in Program-C and Program-F but not by statements in Program-E,
Program-A or Program-B.
END CLASS
Specifies the end of a class definition.
END METHOD
Specifies the end of a method definition.
Methods defined in a class can access instance data (class Working-Storage Section
data items) introduced in the same class but not instance data introduced by a
parent class or metaclass. Therefore, instance data is always private to the class
that introduces it.
Methods introduced in class-name-1 must have unique names within the class
definition.
Identification Division
The Identification Division must be the first division in every COBOL source
program, class definition, and method definition. It names the program, class, or
method, and can include the date the program, class, or method was written, the
date of compilation, and other such documentary information. The Identification
Division must begin with the words IDENTIFICATION DIVISION or ID
DIVISION followed by a separator period.
Program IDENTIFICATION DIVISION
For a program, the first paragraph of the Identification Division must be the
PROGRAM-ID paragraph.
The other paragraphs are optional, and as an IBM extension, can appear in any
order.
Class IDENTIFICATION DIVISION
For a class, the first paragraph of the Identification Division must be the
CLASS-ID paragraph.
The other paragraphs are optional, and can appear in any order.
Method IDENTIFICATION DIVISION
For a method, the first paragraph of the Identification Division must be the
METHOD-ID paragraph.
The other paragraphs are optional, and can appear in any order.
PROGRAM-ID paragraph
The PROGRAM-ID paragraph specifies the name by which the program is known
and assigns selected program attributes to that program. It is required and must
be the first paragraph in the Identification Division.
program-name
A user-defined word or nonnumeric literal that identifies your program. It
must follow the following rules of formation, depending on the setting of the
PGMNAME compiler option:
Table 7 (Page 1 of 2). Formation rules for program names based on PGMNAME compiler option
Formation rules
PGMNAME
setting OS/390 and VM AIX and Windows
PGMNAME The name can be up to 30 characters in Flagged with a warning message and
(COMPAT) length. treated as PGMNAME(UPPER).
Only the hyphen, digit, and alphabetic characters are allowed in the name.
The name can be up to 160 characters in The name can be up to 160 characters in
length. length.
Program-name can consist of any character Wherever alphabetic characters are allowed,
in the range X'41' to X'FE'. you can use multi-byte characters.
For information on the PGMNAME compiler option and how the compiler
processes the names, see the IBM COBOL Programming Guide for your
platform.
RECURSIVE
An optional clause that allows COBOL programs to be recursively reentered.
You can specify the RECURSIVE clause only on the outermost program of a
compilation unit. Recursive programs cannot contain nested subprograms.
If the RECURSIVE clause is specified, program-name-1 can be recursively
reentered while a previous invocation is still active. If the RECURSIVE clause
is not specified, an active program cannot be recursively reentered.
The Working-Storage Section of a recursive program defines storage that is
statically allocated and initialized on the first entry to a program, and is
available in a last-used state to any of the recursive invocations.
The Local-Storage Section of a recursive program (as well as a non-recursive
program) defines storage that is automatically allocated, initialized, and
deallocated on a per-invocation basis.
Internal file connectors corresponding to FDs in the File Section of a recursive
program are statically allocated. The status of internal file connectors is part of
the last-used state of a program that persists across invocations.
The following language elements are not supported in a recursive program:
ALTER
GO TO without a specified procedure name
RERUN
SEGMENTATION
USE FOR DEBUGGING
For the rules governing non-unique program names, see “Rules for
program-names” on page 61.
CLASS-ID paragraph
The CLASS-ID paragraph specifies the name by which the class is known and
assigns selected attributes to that class. It is required and must be the first
paragraph in a class Identification Division.
class-name-1
A user-defined word that identifies the class.
If you want to use more flexible naming conventions for class-name-1, specify
class-name-1 in the REPOSITORY paragraph of the class definition. (This
defines an external class name to identify the class outside of this class
definition.)
INHERITS
A clause that defines class-name-1 to be a subclass (or derived class) of
class-name-2 (the parent class). Class-name-1 cannot directly or indirectly
inherit from class-name-1. A class name can only appear once in the
INHERITS clause.
Note: The INHERITS and METACLASS clauses can appear in either order in
the CLASS-ID paragraph.
class-name-3
The name of a metaclass that is responsible for creating and/or managing
objects of the class being defined. You must specify class-name-3 in the
REPOSITORY paragraph of the Configuration Section of the class definition.
General rules
Class-name-1, class-name-2, and class-name-3 must conform to the normal rules of
formation for a COBOL user-defined word, as described in “COBOL words with
single-byte characters” on page 3.
See “REPOSITORY paragraph” on page 91 for details on:
Class names mapping to CORBA compliant names
Specification of external class-names with more flexible rules of formation
You can specify a sequence of class definitions and program definitions in a single
COBOL source file, forming a batch compile.
Inheritance
Every method available on instances of a class is also available on instances of any
subclass directly or indirectly derived from it. A subclass can introduce new
methods that do not exist in the parent (or ancestor) class or can override a
method from the parent class. When a subclass overrides an existing method from
the parent class, it defines a new implementation for that method, which replaces
the inherited implementation.
The instance data of class-name-1 is a copy of the instance data from class-name-2
together with the data declared in the Working-Storage Section of class-name-1.
Note however, instance data is always private to the class that introduces it.
The semantics of inheritance are defined by the IBM SOM. All classes must be
derived directly or indirectly from the SOMObject class. All metaclasses must be
derived directly or indirectly from SOMClass.
Multiple inheritance
Multiple inheritance is when more than one class name is specified on the
INHERITS phrase. With multiple inheritance, a class might inherit the same
methods and instance data from different parents (if each of these parents have a
common ancestor). In this situation, (“diamond inheritance”) the subclass inherits
only one set of method implementations and one copy of the instance data.
METHOD-ID paragraph
The METHOD-ID paragraph specifies the name by which a method is known and
assigns selected attributes to that method. It is required and must be the first
paragraph in a method Identification Division.
method-name-1
A user-defined word or a nonnumeric literal that identifies the method.
The rules of formation for method-name-1 are as follows:
If the method name is specified in the user-defined word format, then
normal COBOL rules for a user-defined word apply.
If the method name is specified as a nonnumeric literal, then:
— The name can be up to 160 characters in length.
— The characters used in the name must be uppercase or lowercase
alphabetic, digit, hyphen, or underscore.
— At least one character must be alphabetic.
— Hyphen cannot be used as the first or last character.
OVERRIDE
A clause that allows a subclass to override an existing method implementation
when it inherits a method from a parent class.
You must specify the OVERRIDE clause in the METHOD-ID paragraph, if
method-name-1 is overriding a method with the same name that is inherited
from a parent class.
Do not specify the OVERRIDE clause if the method is not inherited from an
ancestor class, and is being introduced by the current class definition.
Note: Method names that differ only in case are not considered unique. For
example, naming one method “SAYHELLO” and another method “sayHELLO”
is invalid.
2. Method names are processed by the compiler as follows:
Literal-format methods names are processed in a case-sensitive manner.
However, when processing method resolution as part of INVOKE
statements or method names that are specified as user-defined words, the
compiler ignores any difference in case.
If necessary, the compiler translates method names to conform to CORBA
requirements:
— Hyphens are translated to zero
— If the first character of the name is a digit, it is converted as follows:
– 1 through 9 are changed to A through I
– 0 is changed to J
3. If a method in class-name-1 overrides a method in class-name-2, these two
methods must satisfy the following conformance rules:
The number of formal parameters on the Procedure Division USING
phrase must be the same for both methods.
The presence or absence of the Procedure Division RETURNING phrase
must be consistent on the two methods.
Corresponding parameters in the Procedure Division USING phrases must
satisfy the following:
— If a formal parameter is a COBOL elementary data item not described
with USAGE IS OBJECT REFERENCE, then the corresponding
parameter must have the same PICTURE, USAGE, SIGN,
SYNCHRONIZED, JUSTIFIED, and BLANK WHEN ZERO clauses.
Note that periods and commas can be interchanged if using the
DECIMAL POINT IS COMMA clause, and the PICTURE clause
currency symbols can differ.
— If a formal parameter is a COBOL elementary data item described with
USAGE IS OBJECT REFERENCE, then the corresponding parameter
must be defined with an identical USAGE IS OBJECT REFERENCE
clause.
— BY VALUE and BY REFERENCE specifications must be consistent.
The identifiers specified on the Procedure Division RETURNING phrases
must satisfy the following:
— If one of the identifiers is a COBOL elementary data item not described
with USAGE IS OBJECT REFERENCE, then the corresponding
identifier must have the same PICTURE, USAGE, SIGN,
SYNCHRONIZED, JUSTIFIED, and BLANK WHEN ZERO clauses.
Note that periods and commas can be interchanged if using the
DECIMAL POINT IS COMMA clause, and the PICTURE clause
currency symbols can differ.
— If the class-name-2 Procedure Division RETURNING identifier is a
universal object reference, the class-name-1 Procedure Division
Optional paragraphs
These optional paragraphs in the Identification Division can be omitted:
AUTHOR
Name of the author of the program.
INSTALLATION
Name of the company or location.
DATE-WRITTEN
Date the program was written.
DATE-COMPILED
Date the program was compiled.
SECURITY
Level of confidentiality of the program.
The comment-entry in any of the optional paragraphs can be any combination of
characters from the character set of the computer. The comment-entry is written in
Area B on one or more lines.
The paragraph name DATE-COMPILED and any comment-entry associated with it
appear in the output program listing with the current date inserted:
DATE-COMPILED. ?4/27/95.
Configuration Section
The Configuration Section is an optional section for programs and classes, which
can describe the computer environment on which the program is compiled and
executed.
Program Configuration Section
The Configuration Section can be specified only in the Environment Division
of the outermost program of a COBOL source program.
You should not specify the Configuration Section in a program that is
contained within another program. The entries specified in the Configuration
Section of a program apply to any program contained within that program.
Class Configuration Section
Specify the Configuration Section only in the Environment Division of the
outermost program of a class definition.
Entries in a class Configuration Section apply to the entire class definition,
including all methods introduced by that class.
Method Configuration Section
The Configuration Section is not valid for method definitions.
SOURCE-COMPUTER paragraph
The SOURCE-COMPUTER paragraph describes the computer on which the source
program is to be compiled.
computer-name
A system-name. For example:
IBM-39?
OBJECT-COMPUTER paragraph
The OBJECT-COMPUTER paragraph specifies the system for which the object
program is designated.
Format
──OBJECT-COMPUTER.───────────────────────────────────────────────────────────────────────────────
──┬──────────────────────────────────────────────────────────────────────────────┬───────────────
└─computer-name──┬───────────────────────────────────────────┬──┤ entry 1 ├──.─┘
└─MEMORY──┬──────┬──integer──┬─WORDS──────┬─┘
└─SIZE─┘ ├─CHARACTERS─┤
└─MODULES────┘
entry 1
├──┬─────────────────────────────────────────────────────────────┬─────────────────────────────────
└─┬─────────┬──┬───────────┬──SEQUENCE──┬────┬──alphabet-name─┘
└─PROGRAM─┘ └─COLLATING─┘ └─IS─┘
──┬────────────────────────────────────────┬──────────────────────────────────────────────────────┤
└─SEGMENT-LIMIT──┬────┬──priority-number─┘
└─IS─┘
computer-name
A system-name. For example:
IBM-39?
MEMORY SIZE
The amount of main storage needed to run the object program. The MEMORY
SIZE clause is syntax checked, but it has no effect on the execution of the
program.
integer
Expressed in words, characters, or modules.
PROGRAM COLLATING SEQUENCE IS
The collating sequence used in this program is the collating sequence
associated with the specified alphabet-name.
The collating sequence pertains to this program and any programs it might
contain.
alphabet-name
The collating sequence.
PROGRAM COLLATING SEQUENCE determines the truth value of the following
nonnumeric comparisons:
Those explicitly specified in relation conditions
Those explicitly specified in condition-name conditions
The PROGRAM COLLATING SEQUENCE clause also applies to any nonnumeric
merge or sort keys, unless the COLLATING SEQUENCE phrase is specified in the
MERGE or SORT statement.
Under OS/390 and VM, the PROGRAM COLLATING SEQUENCE
clause is not applied to the DBCS character set.
SPECIAL-NAMES paragraph
The SPECIAL-NAMES paragraph:
Relates IBM-specified environment-names to user-defined mnemonic-names
Relates alphabetic-names to character sets or collating sequences
Specifies symbolic characters
Relates class names to sets of characters
Specifies a currency sign value, and the currency symbol used in the PICTURE
clause to represent the currency sign value (multiple currency sign values and
currency symbols can be specified)
Specifies that the functions of the comma and decimal point are to be
interchanged in PICTURE clauses and numeric literals
Note: The clauses in the SPECIAL-NAMES paragraph can appear in any order.
environment-name-2
A 1-byte User Programmable Status Indicator (UPSI) switch. Valid
specifications for environment-name-2 are UPSI-0 through UPSI-7.
mnemonic-name-1, mnemonic-name-2
Mnemonic-name-1 and mnemonic-name-2 follow the rules of formation for
user-defined names. Mnemonic-name-1 can be used in ACCEPT, DISPLAY,
and WRITE statements. Mnemonic-name-2 can be referenced only in the SET
statement. Mnemonic-name-2 can qualify cond-1 or cond-2 names.
Mnemonic-names and environment-names need not be unique. If you choose
a mnemonic-name that is also an environment-name, its definition as a
mnemonic-name will take precedence over its definition as an
environment-name.
ON STATUS IS, OFF STATUS IS
UPSI switches process special conditions within a program, such as
year-beginning or year-ending processing. For example, at the beginning of
the Procedure Division, an UPSI switch can be tested; if it is ON, the special
branch is taken. (See “Switch-status condition” on page 229.)
cond-1, cond-2
Condition-names follow the rules for user-defined names. At least one
character must be alphabetic. The value associated with the condition-name is
considered to be alphanumeric. A condition-name can be associated with the
on status and/or off status of each UPSI switch specified.
In the Procedure Division, the UPSI switch status is tested through the
associated condition-name. Each condition-name is the equivalent of a level-88
ALPHABET clause
ALPHABET alphabet-name-1 IS
Provides a means of relating an alphabet-name to a specified character code set
or collating sequence.
It specifies a collating sequence when used in either:
The PROGRAM COLLATING SEQUENCE clause of the
OBJECT-COMPUTER paragraph
The COLLATING SEQUENCE phrase of the SORT or MERGE statement
It specifies a character code set when specified in either:
The FD entry CODE-SET clause
The SYMBOLIC CHARACTERS clause
EBCDIC
Specifies the EBCDIC character set.
CLASS clause
Under AIX and Windows, you cannot specify the CLASS clause if the
code page in effect is a DBCS or EUC code page.
CLASS class-name-1 IS
Provides a means for relating a name to the specified set of characters listed in
that clause. Class-name can be referenced only in a class condition. The
characters specified by the values of the literals in this clause define the
exclusive set of characters of which this class-name consists.
Under OS/390 and VM, the class-name in the CLASS clause can be
a DBCS user-defined word.
literal-4, literal-5
If numeric, must be unsigned integers and must have a value that is greater
than or equal to 1 and less than or equal to the number of characters in the
alphabet specified. Each number corresponds to the ordinal position of each
character in the EBCDIC or ASCII collating series. Cannot be specified as
floating-point literals or as DBCS literals.
If nonnumeric, the literal is the actual EBCDIC or ASCII character. Literal-4
and literal-5 must not specify a symbolic-character figurative constant. If the
REPOSITORY paragraph
The REPOSITORY paragraph defines the names of the classes that you can use in a
class definition or program. Optionally, the REPOSITORY paragraph defines
associations between class-names and external class-names.
Format
──REPOSITORY.──┬────────────────────────────────────────────────────────┬──.────────────────────
└─CLASS──class-name-1──┬───────────────────────────────┬─┘
└─┬────┬──external-class-name-1─┘
└─IS─┘
class-name-1
A user-defined word that identifies the class.
external-class-name-1
A name that enables a COBOL program to define or access classes with names
that are defined using CORBA rules of formation. (Class names defined using
CORBA rules of formation might not be expressible as a COBOL user-defined
word, such as the case-sensitive SOM class names (SOMObject for example), or
a class implemented in C with a name containing underscores.)
You must specify external-class-name-1 as a nonnumeric literal, conforming to
the following rules of formation:
The name must not be a figurative constant.
General rules
1. All class names (whether referenced in a program, class definition, or method
introduced by the class) must have an entry in the REPOSITORY paragraph.
(You do not have to put the name of the class you are defining in the
REPOSITORY paragraph. Note, if you don't, the class name is stored in all
uppercase in the SOM repository.)
You can only specify a class name once in a given REPOSITORY paragraph.
2. Entries in a class REPOSITORY paragraph apply to the entire class definition,
including all methods introduced by that class. Entries in a program
REPOSITORY paragraph apply globally to all nested programs contained
within the program.
Input-Output Section
The Input-Output Section of the Environment Division contains two paragraphs:
FILE-CONTROL paragraph
I-O-CONTROL paragraph
The exact contents of the Input-Output Section depend on the file organization and
access methods used. See “ORGANIZATION clause” on page 103 and “ACCESS
MODE clause” on page 107.
Program Input-Output Section
The same rules apply to program and method I-O Sections.
Class Input-Output Section
The Input-Output Section is not valid for class definitions.
Method Input-Output Section
The same rules apply to program and method I-O Sections.
──┬────────────────────────────────────────────────┬──────────────────────
└─I-O-CONTROL.──┬──────────────────────────────┬─┘
│ ┌──
───────────────────────┐ │
└──/─i-o-control-paragraph─┴──.─┘
Notes:
1 If there are no files defined in the program and the INPUT-OUTPUT
FILE-CONTROL
The key word FILE-CONTROL names the FILE-CONTROL paragraph. This
key word can appear only once, at the beginning of the FILE-CONTROL
paragraph. It must begin in Area A, and be followed by a separator period.
file-control-paragraph
Names the files and associates them with the external data sets.
Must begin in Area B with a SELECT clause. It must end with a separator
period. See “FILE-CONTROL paragraph” on page 94.
I-O-CONTROL
The key word I-O-CONTROL names the I-O-CONTROL paragraph.
input-output-control-paragraph
Specifies information needed for efficient transmission of data between the
external data set and the COBOL program. The series of entries must end
with a separator period. See “I-O-CONTROL paragraph” on page 114.
FILE-CONTROL paragraph
The FILE-CONTROL paragraph associates each file in the COBOL program with
an external data set, and specifies file organization, access mode, and other
information.
The following are the formats for the FILE-CONTROL paragraph:
Sequential file entries
Indexed file entries
Relative file entries
| Line-sequential file entries (not supported under VM)
Table 9 lists the different type of files available to mainframe and workstation
COBOL programs.
1 Under AIX, you can access the SFS file system through VSAM.
| 3 Line-sequential support on the host is limited to HFS files under OS/390. Line-sequential files
| are not supported under VM.
Format 2—indexed-file-control-entries
┌──
───────────────────┐
──SELECT──┬──────────┬──file-name-1──ASSIGN──┬─┬────┬───/─assignment-name-1─┴─┬───────────────────
└─OPTIONAL─┘ │ └─TO─┘ │
(1) ─────────┘
└─USING──data-name-9───
──┬─────────────────────────────┬──┬──────────────────────┬──INDEXED──────────────────────────────
└─RESERVE──integer──┬───────┬─┘ └─ORGANIZATION──┬────┬─┘
├─AREA──┤ └─IS─┘
└─AREAS─┘
──┬──────────────────────────────────────────┬──RECORD──┬─────┬──┬────┬──data-name-2──────────────
└─ACCESS──┬──────┬──┬────┬──┬─SEQUENTIAL─┬─┘ └─KEY─┘ └─IS─┘
└─MODE─┘ └─IS─┘ ├─RANDOM─────┤
└─DYNAMIC────┘
┌──
─────────────────┐
──┬───────────────────────────────┬───/─┬─────────────┬─┴──────────────────────────────────────────
└─PASSWORD──┬────┬──data-name-6─┘ └─┤ entry 1 ├─┘
└─IS─┘
──┬────────────────────────────────────────────────────────┬──.──────────────────────────────────
└─┬──────┬──STATUS──┬────┬──data-name-1──┬─────────────┬─┘
└─FILE─┘ └─IS─┘ └─data-name-8─┘
entry 1
(2) ─┬─────┬──┬────┬──data-name-3──┬──────────────────────┬──────────────────────
├──ALTERNATE RECORD───
└─KEY─┘ └─IS─┘ └─┬──────┬──DUPLICATES─┘
└─WITH─┘
──┬───────────────────────────────┬───────────────────────────────────────────────────────────────┤
└─PASSWORD──┬────┬──data-name-7─┘
└─IS─┘
Notes:
1 The USING data-name phrase of the ASSIGN clause is only valid under AIX and Windows.
|
| Format 4—line-sequential-file-control-entries (all platforms except VM)
┌──
───────────────────┐
──SELECT──┬──────────┬──file-name-1──ASSIGN──┬─┬────┬───/─assignment-name-1─┴─┬───────────────────
└─OPTIONAL─┘ │ └─TO─┘ │
(1) ─────────┘
└─USING──data-name-9───
──┬──────────────────────┬──LINE SEQUENTIAL──┬──────────────────────────────────────┬─────────────
└─ORGANIZATION──┬────┬─┘ └─ACCESS──┬──────┬──┬────┬──SEQUENTIAL─┘
└─IS─┘ └─MODE─┘ └─IS─┘
──┬──────────────────────────────────────────────────────────┬──.────────────────────────────────
└─┬──────┬──STATUS──┬────┬──data-name-1──┬───────────────┬─┘
└─FILE─┘ └─IS─┘ (1) ┘
└─data-name-8───
Note:
1 The USING data-name-9 phrase and data-name-8 are only valid under AIX and Windows.
SELECT clause
The SELECT clause chooses a file in the COBOL program to be associated with an
external data set.
SELECT OPTIONAL
Can be specified only for files opened in the input, I-O, or extend mode. You
must specify SELECT OPTIONAL for such input files that are not necessarily
present each time the object program is executed. For more information, see
the IBM COBOL Programming Guide for your platform.
file-name-1
Must be identified by an FD or SD entry in the Data Division. A file-name
must conform to the rules for a COBOL user-defined name, must contain at
least one alphabetic character, and must be unique within this program.
When file-name-1 specifies a sort or a merge file, only the ASSIGN clause can
follow the SELECT clause.
If the file connector referenced by file-name-1 is an external file connector, all file
control entries in the run unit that reference this file connector must have the same
specification for the OPTIONAL phrase.
ASSIGN clause
The ASSIGN clause associates the program's name for a file with the external
name for the actual data file.
Format—QSAM file
──┬─────────┬──┬─────┬──name─────────────────────────────────────────────
└─label- ─┘ └─S- ─┘
|
| Format—Line-sequential, VSAM indexed or VSAM relative file
──┬─────────┬──name──────────────────────────────────────────────────────
└─label- ─┘
label-
Documents the device and device class to which a file is assigned. If specified,
it must end with a hyphen.
| Note: The environment variable name must be defined using only upper case,
| since the COBOL compiler automatically folds the external file name to upper case.
| If this environment variable exists, and contains a valid PATH or DSN option
| (described below), then the file is dynamically allocated using the information
| supplied by that option.
| If the environment variable does not contain a valid PATH or DSN option, or if
| the dynamic allocation fails, then attempting to open the file results in file status
| 98.
| The contents of the environment variable are checked at each OPEN statement. If
| a file was dynamically allocated by a previous OPEN statement and the contents
| of the environment variable have changed since the previous OPEN, then the
| previous allocation is dynamically deallocated prior to dynamically reallocating the
| file using the options currently set in the environment variable.
| Environment variable contents for a QSAM file: For a QSAM file, the
| environment variable must contain either a PATH option or a DSN option in the
| following format:
| The options following DSN (such as NEW, TRACKS etc.) must be separated by a
| comma or by one or more blanks.
|
| Environment variable format (OS/390 QSAM files)—DSN option
| ──DSN──(──data-set-name──┬───────────────┬──)──┬─────┬──┬────────┬──
| └─(member-name)─┘ ├─NEW─┤ ├─TRACKS─┤
| ├─OLD─┤ └─CYL────┘
| ├─SHR─┤
| └─MOD─┘
| ──┬─────────────────┬──┬────────────────────┬──┬────────────┬──
| └─SPACE(nnn,mmmm)─┘ └─VOL(volume-serial)─┘ └─UNIT(type)─┘
| ──┬───────────┬──┬─────────────────────────┬──
| ├─KEEP──────┤ └─STORCLAS(storage-class)─┘
| ├─DELETE────┤
| ├─CATALOG───┤
| └─UNCATALOG─┘
| ──┬────────────────────────────┬──┬──────────────────────┬──
| └─MGMTCLAS(management-class)─┘ └─DATACLAS(data-class)─┘
| The data-set-name must be fully qualified. The data set must not be a temporary
| data set (that is, it must not start with an ampersand). After data-set-name or
| member-name, the data set attributes can follow in any order.
| For information on specifying the values of the data set attributes, see the
| description of the DD statement in the OS/390 MVS JCL Reference, GC28-1757.
|
| Environment variable format (OS/390)—PATH option
| ──PATH──(──path-name──)──
| The path-name must be an absolute path name (that is, it must begin with a slash).
| For more information on specifying path-name, see the description of the PATH
| parameter in the OS/390 MVS JCL Reference, GC28-1757.
| Blanks at the beginning and end of the environment variable contents are ignored.
| Blanks are not allowed within the parentheses.
|
| Environment variable format (OS/390)—PATH option
| ──PATH──(──path-name──)──
| The path-name must be an absolute path name (that is, it must begin with a slash).
| For more information on specifying path-name, see the description of the PATH
| parameter in the OS/390 MVS JCL Reference, GC28-1757.
| Blanks at the beginning and end of the environment variable contents are ignored.
| Blanks are not allowed within the parentheses.
|
| Environment variable format (OS/390 VSAM)—DSN option
| ──DSN──(──data-set-name──)──┬─OLD─┬──
| └─SHR─┘
| The data-set-name specifies the data set name for the base cluster. The data-set-name
| must be fully qualified, and must reference an existing predefined and cataloged
| VSAM data set.
| If an indexed file has alternate indexes, then additional environment variables
| must be defined containing DSN options (as above) for each of the alternate index
| paths. The names of these environment variables must follow the same naming
| convention as used for alternate index ddnames. That is:
| The environment variable name for each alternate index path is formed by
| concatenating the base cluster environment variable name with an integer,
| beginning with 1 for the path associated with the first alternate index and
| incrementing by 1 for the path associated with each successive alternate index.
| (For example, if the environment variable name for the base cluster is CUST,
| then the environment variable names for the alternate indexes would be
| CUST1, CUST2 etc.)
| If the length of the base cluster environment variable name is already 8
| characters, then the environment variable names for the alternate indexes are
| formed by truncating the base cluster portion of the environment variable
| name on the right, to reduce the concatenated result to 8 characters. (For
| example, if the environment variable name for the base cluster is DATAFILE,
| then the environment variable names for the alternate clusters would be
| DATAFIL1, DATAFIL2 etc.)
| Blanks at the beginning and end of the environment variable contents are ignored.
| Blanks are not allowed within the parentheses.
| The options following DSN (such as SHR) must be separated by a comma or by
| one or more blanks.
comment
All characters to the left of the system-file ID are treated as comments.
Comments can be hyphenated, for example, my-comment or
this-is-my-comment.
file-system ID
The first three characters of the file-system ID are used to determine the
file-system identifier. If the character string for the file-system ID is less than
three characters, then the entire character string (along with any character
strings to the left of it) is treated as a comment. If you include comments
(hyphenated or not), you must include the separating hyphen between the
comment and the file-system ID.
For example, take the following two assignment-name formats:
my-comment-vsam-myfile
In this example, my-comment is the comment, vsam is the file-system ID, and
myfile is the system file or environment variable name.
my-comment-am-myfile
In the above example, the compiler will assign a default file name for the
second alternate index file.
Alternate index file names are ignored for file systems that do not require
separate alternate index files, such as the STL file system.
file-system ID
If the file-system ID is specified explicitly using the environment variable value
or the data-name value, that specification for the file system overrides any file
system specification made by the ASSIGNment name.
The environment variable value for a file is obtained when the program
containing the file is first run (or called) in its initial state. This value is kept
for the file for subsequent calls to the program in the last used state.
RESERVE clause
| The RESERVE clause is not supported for line-sequential files.
Under AIX and Windows, the RESERVE clause is syntax checked, but
has no effect on the execution of the program.
The RESERVE clause allows the user to specify the number of input/output
buffers to be allocated at run-time for the files.
If the RESERVE clause is omitted, the number of buffers at run time is taken from
the DD statement when running under OS/390. If none is specified, the system
default is taken.
If the file connector referenced by file-name-1 in the SELECT clause is an external
file connector, all file control entries in the run unit that reference this file
connector must have the same value for the integer specified in the RESERVE
clause.
ORGANIZATION clause
The ORGANIZATION clause identifies the logical structure of the file. The logical
structure is established at the time the file is created and cannot subsequently be
changed.
You can find a discussion of the different ways in which data can be organized
and of the different access methods that you can use to retrieve the data under
“File organization and access modes” on page 108.
ORGANIZATION IS SEQUENTIAL (format 1)
A predecessor-successor relationship among the records in the file is
established by the order in which records are placed in the file when it is
created or extended.
ORGANIZATION IS INDEXED (format 2)
The position of each logical record in the file is determined by indexes created
with the file and maintained by the system. The indexes are based on
embedded keys within the file's records.
File organization
You establish the organization of the data when you create the file. Once the file
has been created, you can expand the file, but you cannot change the organization.
Sequential organization
The physical order in which the records are placed in the file determines the
sequence of records. The relationships among records in the file do not change,
except that the file can be extended. Records can be fixed-length or
variable-length; there are no keys.
Each record in the file, except the first, has a unique predecessor record, and each
record, except the last, also has a unique successor record.
Indexed organization
Each record in the file has one or more embedded keys (referred to as key data
items); each key is associated with an index. An index provides a logical path to
the data records, according to the contents of the associated embedded record key
data items. Indexed files must be direct-access storage files. Records can be
fixed-length or variable-length.
Each record in an indexed file must have an embedded prime key data item.
When records are inserted, updated, or deleted, they are identified solely by the
values of their prime keys. Thus, the value in each prime key data item must be
unique and must not be changed when the record is updated. You tell COBOL
the name of the prime key data item on the RECORD KEY clause of the
FILE-CONTROL paragraph.
In addition, each record in an indexed file can contain one or more embedded
alternate key data items. Each alternate key provides another means of identifying
which record to retrieve. You tell COBOL the name of any alternate key data
items on the ALTERNATE RECORD KEY clause of the FILE-CONTROL
paragraph.
The key used for any specific input-output request is known as the key of
reference.
| Line-sequential organization
| In a line-sequential file, each record contains a sequence of characters ending with
| a record delimiter. The delimiter is not counted in the length of the record.
| Upon writing, any trailing blanks are removed prior to adding the record
| delimiter. The characters in the record area from the first character up to and
| including the added record delimiter constitute one record and are written to the
| file.
| Upon reading the record, characters are read one at a time into the record area
| until:
| The first record delimiter is encountered. The record delimiter is discarded
| and the remainder of the record is filled with spaces.
| The entire record area is filled with characters. If the first unread character is
| the record delimiter, it is discarded. Otherwise, the first unread character
| becomes the first character read by the next READ statement.
| Records written to line-sequential files must consist of USAGE...DISPLAY and/or
| DISPLAY-1 data items. An external decimal data item must either be unsigned or,
| if signed, must be declared with the SEPARATE CHARACTER phrase.
| A line-sequential file must only contain printable characters and the following
| control characters:
| Alarm
| Backspace
| Form feed
| New-line
| Carriage-return
| Horizontal tab
| Vertical tab
| DBCS shift-out
| DBCS shift-in
| New-line characters are processed as record delimiters, while other control
| characters are treated by COBOL as part of the data for the records in the file.
| The following are not supported for line-sequential files:
| APPLY WRITE ONLY clause
| CODE-SET clause
| DATA RECORDS clause
| LABEL RECORDS clause
| LINAGE clause
| OPEN I-O option
| PADDING CHARACTER clause
| RECORD CONTAINS 0 clause
Access modes
Sequential-access mode
Allows reading and writing records of a file in a serial manner; the order of
reference is implicitly determined by the position of a record in the file.
Random-access mode
Allows reading and writing records in a programmer-specified manner; the
control of successive references to the file is expressed by specifically defined
keys supplied by the user.
Dynamic-access mode
Allows the specific input-output statement to determine the access mode.
Therefore, records can be processed sequentially and/or randomly.
For EXTERNAL files, every file control entry in the run unit that is associated with
that external file must specify the same access mode. In addition, for relative file
entries, data-name-4 must reference an external data item and the RELATIVE KEY
phrase in each associated file control entry must reference that same external data
item in each case.
PASSWORD clause
Under AIX and Windows the PASSWORD clause is syntax checked,
but has no effect on the execution of the program.
The PASSWORD clause controls access to files.
data-name-6
data-name-7
Password data items. Each must be defined in the Working-Storage Section (of
the Data Division) as an alphanumeric item. The first 8 characters are used as
the password; a shorter field is padded with blanks to 8 characters. Each
password data item must be equivalent to one that is externally defined.
Note: This also applies to SFS files accessed through VSAM on AIX.
I-O-CONTROL paragraph
The I-O-CONTROL paragraph of the Input-Output Section specifies when
checkpoints are to be taken and the storage areas to be shared by different files.
This paragraph is optional in a COBOL program.
The key word I-O-CONTROL can appear only once, at the beginning of the
paragraph. The word I-O-CONTROL must begin in Area A, and must be followed
by a separator period.
Each clause within the paragraph can be separated from the next by a separator
comma or a separator semicolon. The order in which I-O-CONTROL paragraph
clauses are written is not significant. The I-O-CONTROL paragraph ends with a
separator period.
Sequential I-O-control entries
(1) ─┬─assignment-name-1─┬──┬───────┬──┤ phrase 1 ├───────────────────────┬─────────
──┬─RERUN──ON───
│ └─file-name-1───────┘ └─EVERY─┘ │
│ ┌──
───────────────┐ │
├─SAME──┬────────┬──┬──────┬──┬─────┬──file-name-3───/─file-name-4─── (2) ┴───────────────┤
└─ON─┘
phrase 1
├──┬─integer-1──RECORDS────┬──┬────┬──file-name-1──────────────────────────────────────────────────┤
└─END──┬────┬──┬─REEL─┬─┘ └─OF─┘
└─OF─┘ └─UNIT─┘
Notes:
1 ON is optional as an IBM extension.
3 The MULTIPLE FILE clause and APPLY WRITE-ONLY clause are not supported for OS/390
| VSAM files. On AIX and Windows, these clauses are syntax checked, but have no effect on the
| execution of the program.
Note:
1 File-name-4 is optional as an IBM extension.
RERUN clause
| Under AIX and Windows, the RERUN clause is not supported for
| programs compiled with the THREAD compiler option. If you use NOTHREAD,
| the RERUN clause is treated as a comment.
The RERUN clause specifies that checkpoint records are to be taken. Subject to the
restrictions given with each phrase, more than one RERUN clause can be specified.
For information regarding the checkpoint data set definition and the checkpoint
method required for complete compliance to the COBOL 85 Standard, see IBM
COBOL for OS/390 & VM Programming Guide.
Do not use the RERUN clause:
On files with the EXTERNAL attribute
In programs with the RECURSIVE attribute
In programs compiled with the THREAD option (Workstation only)
In methods
file-name-1
Must be a sequentially organized file.
assignment-name-1
The external data set for the checkpoint file. It must not be the same
assignment-name as that specified in any ASSIGN clause throughout the entire
program, including contained and containing programs. For QSAM files, it
has the format:
Format—QSAM file
──┬─────────┬──┬─────┬──name─────────────────────────────────────────
└─label- ─┘ └─S- ─┘
That is, it must be a QSAM file. It must reside on a tape or direct access
device. See also Appendix E, “ASCII considerations for OS/390 and VM” on
page 512.
VSAM and QSAM considerations:
Note: This clause is not supported. If you code it in your program, it will be
syntax checked, but have no effect on the execution of the program.
When multiple END OF REEL/UNIT phrases are specified, no two of them
can specify the same file-name-1.
The END OF REEL/UNIT phrase can only be used if file-name-1 is a
sequentially organized file.
File Section
The File Section defines the structure of data files. The File Section must begin
with the header FILE SECTION, followed by a separator period.
file-description-entry
Represents the highest level of organization in the File Section. It provides
information about the physical structure and identification of a file, and gives
the record-name(s) associated with that file. For the format and the clauses
required in a file description entry, see “Data Division—file description
entries” on page 131.
record-description-entry
A set of data description entries (described in “Data Division—data description
entry” on page 145) that describe the particular record(s) contained within a
particular file.
More than one record description entry can be specified; each is an alternative
description of the same record storage area.
Data areas described in the File Section are not available for processing unless the
file containing the data area is open.
Note: A method File Section can define EXTERNAL files only. A single run-unit
level file connector is shared by all programs and methods containing a declaration
of a given EXTERNAL file.
Working-Storage Section
The Working-Storage Section describes data records that are not part of data files
but are developed and processed by a program or method. It also describes data
items whose values are assigned in the source program or method and do not
change during execution of the object program.
The Working-Storage Section must begin with the section header Working-Storage
Section, followed by a separator period.
Program Working-Storage
The Working-Storage Section for programs (and methods) can also describe
external data records, which are shared by programs and methods throughout
the run-unit. All clauses that are used in record descriptions in the File Section
as well as the VALUE and EXTERNAL clauses (which might not be specified
in record description entries in the File Section) can be used in record
descriptions in the Working-Storage Section.
Method Working-Storage
A single copy of the Working-Storage for a method is statically allocated and
persists in a last-used state for the duration of the run-unit. The same single
copy is used whenever the method is invoked, regardless of which object the
method is invoked upon.
If a VALUE clause is specified on a method Working-Storage data item, the
data item is initialized to the VALUE clause value on the first invocation.
If the EXTERNAL attribute is specified on a data description entry in a method
Working-Storage Section, a single copy of the storage for that data item is
allocated once for the duration of the run-unit. That storage is shared by all
IDENTIFICATION DIVISION.
CLASS-ID. OOClass INHERITS SOMObject.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
CLASS SOMObject IS "SOMObject"
CLASS OOClass IS "OOClass".
DATA DIVISION.
Working-Storage Section.
?1 instance-data PIC X(3).
PROCEDURE DIVISION.
IDENTIFICATION DIVISION.
METHOD-ID. "somInit" OVERRIDE.
PROCEDURE DIVISION.
MOVE "new" TO instance-data.
EXIT METHOD.
END METHOD "somInit".
IDENTIFICATION DIVISION.
METHOD-ID. "MyMethod".
PROCEDURE DIVISION.
IF instance-data = "new"
CALL "Creating"
MOVE "old" TO instance-data
ELSE
CALL "Existing"
END-IF.
EXIT METHOD.
END METHOD "MyMethod".
Note: The data description entries for a class differ from a program and
method in that:
You cannot specify the EXTERNAL attribute in a data description entry.
The GLOBAL attribute has no effect.
You can only specify the VALUE clause on condition names.
Local-Storage Section
| The Local-Storage Section defines storage that is allocated and freed on a
| per-invocation basis. On each invocation, data items defined in the Local-Storage
| Section are reallocated and initialized to the value assigned in their VALUE clause.
| (For nested programs, data items defined in the Local-Storage Section are allocated
| upon each invocation of the containing outermost program. However, they are
| reinitialized to the value assigned in their VALUE clause each time the nested
| program is invoked.) Data items defined in the Local-Storage Section cannot
| specify the EXTERNAL clause.
The Local-Storage Section must begin with the header LOCAL-STORAGE
SECTION followed by a separator period.
You can specify the Local-Storage Section in recursive programs, in non-recursive
programs, and in methods.
Linkage Section
The Linkage Section describes data made available from another program or
method.
record-description-entry
See “Working-Storage Section” on page 121 for description.
data-item-description-entry
See “Working-Storage Section” on page 121 for description.
Record description entries and data item description entries in the Linkage Section
provide names and descriptions, but storage within the program or method is not
reserved because the data area exists elsewhere.
Any data description clause can be used to describe items in the Linkage Section
with the following exceptions:
Data types
Two types of data can be processed: file data and program data.
File data
File data is contained in files. (See “File Section” on page 133.) A file is a
collection of data records existing on some input-output device. A file can be
considered as a group of physical records; it can also be considered as a group of
logical records. The Data Division describes the relationship between physical and
logical records.
A physical record is a unit of data that is treated as an entity when moved into or
out of storage. The size of a physical record is determined by the particular
input-output device on which it is stored. The size does not necessarily have a
direct relationship to the size or content of the logical information contained in the
file.
A logical record is a unit of data whose subdivisions have a logical relationship.
A logical record can itself be a physical record (that is, be contained completely
within one physical unit of data); several logical records can be contained within
one physical record, or one logical record can extend across several physical
records.
File description entries specify the physical aspects of the data (such as the size
relationship between physical and logical records, the size and name(s) of the
logical record(s), labeling information, and so forth).
Record description entries describe the logical records in the file, including the
category and format of data within each field of the logical record, different values
the data might be assigned, and so forth.
After the relationship between physical and logical records has been established,
only logical records are made available to you. For this reason, a reference in this
manual to “records” means logical records, unless the term “physical records” is
used.
Program data
Program data is created by a program, instead of being read from a file.
The concept of logical records applies to program data as well as to file data.
Program data can thus be grouped into logical records, and be defined by a series
of record description entries. Items that need not be so grouped can be defined in
independent data description entries (called data item description entries).
Data relationships
The relationships among all data to be used in a program are defined in the Data
Division, through a system of level indicators and level-numbers.
Levels of data
After a record has been defined, it can be subdivided to provide more detailed
data references.
For example, in a customer file for a department store, one complete record could
contain all data pertaining to one customer. Subdivisions within that record could
be: customer name, customer address, account number, department number of
sale, unit amount of sale, dollar amount of sale, previous balance, plus other
pertinent information.
The basic subdivisions of a record (that is, those fields not further subdivided) are
called elementary items. Thus, a record can be made up of a series of elementary
items, or it can itself be an elementary item.
It might be necessary to refer to a set of elementary items; thus, elementary items
can be combined into group items. Groups themselves can be combined into a
more inclusive group that contains one or more subgroups. Thus, within one
hierarchy of data items, an elementary item can belong to more than one group
item.
A system of level-numbers specifies the organization of elementary and group
items into records. Special level-numbers are also used; they identify data items
used for special purposes.
Special level-numbers
Special level-numbers identify items that do not structure a record. The special
level-numbers are:
66 Identifies items that must contain a RENAMES clause; such items regroup
previously defined data items.
(For details, see “RENAMES clause” on page 178.)
77 Identifies data item description entries — independent Working-Storage or
Linkage Section items that are not subdivisions of other items, and are not
subdivided themselves. Level-77 items must begin in Area A.
88 Identifies any condition-name entry that is associated with a particular value of
a conditional variable. (For details, see “VALUE clause” on page 195.)
Note: Level-77 and level-01 entries in the Working-Storage and Linkage Sections
that are referenced in the program must be given unique data-names, because
neither can be qualified. Subordinate data-names that are referenced in the
program must be either uniquely defined, or made unique through qualification.
Unreferenced data-names need not be uniquely defined.
Indentation
Successive data description entries can begin in the same column as preceding
entries, or can be indented. Indentation is useful for documentation, but does not
affect the action of the compiler.
Alignment rules
The standard alignment rules for positioning data in an elementary item depend
on the category of a receiving item (that is, an item into which the data is moved;
see “Elementary moves” on page 321).
Numeric
For such receiving items, the following rules apply:
1. The data is aligned on the assumed decimal point and, if necessary,
truncated or padded with zeros. (An assumed decimal point is one
that has logical meaning but that does not exist as an actual character
in the data.)
2. If an assumed decimal point is not explicitly specified, the receiving
item is treated as though an assumed decimal point is specified
immediately to the right of the field. The data is then treated
according to the preceding rule.
Numeric-edited
The data is aligned on the decimal point, and (if necessary) truncated or
padded with zeros at either end, except when editing causes replacement
of leading zeros.
Internal floating-point
A decimal point is assumed immediately to the left of the field. The data
is aligned then on the leftmost digit position following the decimal point,
with the exponent adjusted accordingly.
Signed data
There are two categories of algebraic signs used in IBM COBOL: operational signs
and editing signs.
Editing signs
Editing signs are associated with numeric-edited items; editing signs are PICTURE
symbols that identify the sign of the item in edited output.
File Section
The File Section must contain a level indicator for each input and output file:
For all files except sort/merge, the File Section must contain an FD entry.
For each sort or merge file, the File Section must contain an SD entry.
file-name
Must follow the level indicator (FD or SD), and must be the same as that
specified in the associated SELECT clause. The file-name must adhere to the
rules of formation for a user-defined word; at least one character must be
alphabetic. The file-name must be unique within this program.
EXTERNAL clause
The EXTERNAL clause specifies that a file connector is external, and permits
communication between two programs by the sharing of files. A file connector is
external if the storage associated with that file is associated with the run unit
rather than with any particular program within the run unit. An external file can
be referenced by any program in the run unit that describes the file. References to
an external file from different programs using separate descriptions of the file are
always to the same file. In a run unit, there is only one representative of an
external file.
In the File Section, the EXTERNAL clause can only be specified in file description
entries.
The records appearing in the file description entry need not have the same name
in corresponding external file description entries. In addition, the number of such
records need not be the same in corresponding file description entries.
Use of the EXTERNAL clause does not imply that the associated file-name is a
global name. See the IBM COBOL Programming Guide for your platform for
specific information on the use of the EXTERNAL clause.
GLOBAL clause
The GLOBAL clause specifies that the file connector named by a file-name is a
global name. A global file-name is available to the program that declares it and to
every program that is contained directly or indirectly in that program.
A file-name is global if the GLOBAL clause is specified in the file description entry
for that file-name. A record-name is global if the GLOBAL clause is specified in
the record description entry by which the record-name is declared or, in the case
of record description entries in the File Section, if the GLOBAL clause is specified
in the file description entry for the file-name associated with the record description
entry. (For details on using the GLOBAL clause, see the IBM COBOL Programming
Guide for your platform
RECORD clause
When the RECORD clause is used, the record size must be specified as the number
of character positions needed to store the record internally. That is, it must specify
the number of bytes occupied internally by the characters of the record (not the
number of characters used to represent the item within the record).
For example, if you have a record with 10 DBCS characters, the RECORD clause
should say RECORD CONTAINS 2? CHARACTERS.
The size of a record is determined according to the rules for obtaining the size of a
group item. (See “USAGE clause” on page 187 and “SYNCHRONIZED clause”
on page 181.)
When the RECORD clause is omitted, the compiler determines the record lengths
from the record descriptions. When one of the entries within a record description
Format 1
Format 1 specifies the number of character positions for fixed-length records.
Format 1
──RECORD──┬──────────┬──integer-3──┬────────────┬────────────────────────
└─CONTAINS─┘ └─CHARACTERS─┘
integer-3
Must be an unsigned integer that specifies the number of character positions
contained in each record in the file.
Format 2
Format 2 specifies the number of character positions for either fixed-length or
variable-length records. Fixed-length records are obtained when all 01 record
description entry lengths are the same. The format 2 RECORD CONTAINS clause
is never required, because the minimum and maximum record lengths are
determined from the record description entries.
Format 2
──RECORD──┬──────────┬──integer-4──TO──integer-5──┬────────────┬─────────
└─CONTAINS─┘ └─CHARACTERS─┘
integer-4
integer-5
Must be unsigned integers. Integer-4 specifies the size of the smallest data
record, and integer-5 specifies the size of the largest data record.
Format 3
──RECORD──┬────┬──VARYING──┬────┬──┬──────┬──┬─────────────────────┬──────
└─IS─┘ └─IN─┘ └─SIZE─┘ └─┬──────┬──integer-6─┘
└─FROM─┘
──┬───────────────┬──┬────────────┬──┬────────────────────────────────┬───
└─TO──integer-7─┘ └─CHARACTERS─┘ └─DEPENDING──┬────┬──data-name-1─┘
└─ON─┘
integer-6
Specifies the minimum number of character positions to be contained in any
record of the file. If integer-6 is not specified, the minimum number of
character positions to be contained in any record of the file is equal to the least
number of character positions described for a record in that file.
integer-7
Specifies the maximum number of character positions in any record of the file.
If integer-7 is not specified, the maximum number of character positions to be
contained in any record of the file is equal to the greatest number of character
positions described for a record in that file.
The number of character positions associated with a record description is
determined by the sum of the number of character positions in all elementary data
items (excluding redefinitions and renamings), plus any implicit FILLER due to
synchronization. If a table is specified:
The minimum number of table elements described in the record is used in the
summation above to determine the minimum number of character positions
associated with the record description.
The maximum number of table elements described in the record is used in the
summation above to determine the maximum number of character positions
associated with the record description.
If data-name-1 is specified:
Data-name-1 must be an elementary unsigned integer.
Data-name-1 cannot be a windowed date field.
The number of character positions in the record must be placed into the data
item referenced by data-name-1 before any RELEASE, REWRITE, or WRITE
statement is executed for the file.
The execution of a DELETE, RELEASE, REWRITE, START, or WRITE
statement or the unsuccessful execution of a READ or RETURN statement does
not alter the content of the data item referenced by data-name-1.
After the successful execution of a READ or RETURN statement for the file,
the contents of the data item referenced by data-name-1 indicate the number of
character positions in the record just read.
During the execution of a RELEASE, REWRITE, or WRITE statement, the number
of character positions in the record is determined by the following conditions:
If data-name-1 is specified, by the content of the data item referenced by
data-name-1.
If data-name-1 is not specified and the record does not contain a variable
occurrence data item, by the number of character positions in the record.
VALUE OF clause
The VALUE OF clause describes an item in the label records associated with this
file. The clause is syntax checked, but has no effect on the execution of the
program.
data-name-3
Should be qualified when necessary, but cannot be subscripted. It must be
described in the Working-Storage Section. It cannot be described with the
USAGE IS INDEX clause.
LINAGE clause
The LINAGE clause specifies the depth of a logical page in terms of number of
lines. Optionally, it also specifies the line number at which the footing area
begins, as well as the top and bottom margins of the logical page. (The logical
page and the physical page cannot be the same size.)
The LINAGE clause is effective for sequential files opened OUTPUT and, as an
IBM extension, EXTEND.
All integers must be unsigned. All data-names must be described as unsigned
integer data items.
data-name-5
integer-8
The number of lines that can be written and/or spaced on this logical page.
The area of the page that these lines represent is called the page body. The
value must be greater than zero.
WITH FOOTING AT
Integer-9 or the value of the data item in data-name-6 specifies the first line
number of the footing area within the page body. The footing line number
must be greater than zero, and not greater than the last line of the page body.
The footing area extends between those two lines.
LINES AT TOP
Integer-10 or the value of the data item in data-name-7 specifies the number of
lines in the top margin of the logical page. The value can be zero.
LINES AT BOTTOM
Integer-11 or the value of the data item in data-name-8 specifies the number of
lines in the bottom margin of the logical page. The value can be zero.
Figure 5 illustrates the use of each phrase of the LINAGE clause.
The logical page size specified in the LINAGE clause is the sum of all values
specified in each phrase except the FOOTING phrase. If the LINES AT TOP
and/or the LINES AT BOTTOM phrase is omitted, the assumed value for top and
bottom margins is zero. Each logical page immediately follows the preceding
logical page, with no additional spacing provided.
If the FOOTING phrase is omitted, its assumed value is equal to that of the page
body (integer-8 or data-name-5).
At the time an OPEN OUTPUT statement is executed, the values of integer-8,
integer-9, integer-10, and integer-11, if specified, are used to determine the page
body, first footing line, top margin, and bottom margin of the logical page for this
file. See Figure 5 above. These values are then used for all logical pages printed
for this file during a given execution of the program.
At the time an OPEN statement with the OUTPUT phrase is executed for the file,
data-name-5, data-name-6, data-name-7, and data-name-8 determine the page
body, first footing line, top margin, and bottom margin for the first logical page
only.
At the time a WRITE statement with the ADVANCING PAGE phrase is executed
or a page overflow condition occurs, the values of data-name-5, data-name-6,
data-name-7, and data-name-8 if specified, are used to determine the page body,
first footing line, top margin, and bottom margin for the next logical page.
If an external file connector is associated with this file description entry, all file
description entries in the run unit that are associated with this file connector must
have:
A LINAGE clause, if any file description entry has a LINAGE clause.
The same corresponding values for integer-8, integer-9, integer-10, and
integer-11, if specified.
The same corresponding external data items referenced by data-name-5,
data-name-6, data-name-7, and data-name-8.
See “ADVANCING phrase” on page 394 for the behavior of carriage control
characters in EXTERNAL files.
The LINAGE clause is treated as a comment under an SD.
Note: You cannot use RECORDING MODE U if you are using the BLOCK
CONTAINS clause.
Recording Mode S (Spanned)
The records can be either fixed-length or variable-length, and can be larger
than a block. If a record is larger than the remaining space in a block, a
segment of the record is written to fill the block. The remainder of the record
is stored in the next block (or blocks, if required). Only complete records are
made available to you. Each segment of a record in a block, even if it is the
entire record, includes a segment-descriptor field, and each block includes a
block-descriptor field. These fields are not described in the Data Division;
provision is automatically made for them. These fields are not available to
you.
CODE-SET clause
| Under AIX and Windows, the CODE-SET clause is syntax checked,
| but has no effect on the execution of the program.
The CODE-SET clause specifies the character code used to represent data on a
magnetic tape file. When the CODE-SET clause is specified, an alphabet-name
identifies the character code convention used to represent data on the input-output
device.
Alphabet-name must be defined in the SPECIAL-NAMES paragraph as
STANDARD-1 (for ASCII-encoded files), as STANDARD-2 (for ISO 7-bit encoded
files), as EBCDIC (for EBCDIC-encoded files), or as NATIVE. When NATIVE is
specified, the CODE-SET clause is syntax checked, but it has no effect on the
execution of the program.
The CODE-SET clause also specifies the algorithm for converting the character
codes on the input-output medium from/to the internal EBCDIC character set.
Format 1
Format 1 is used for data description entries in all Data Division sections.
Format 1
──level-number──┬─────────────┬──┬──────────────────┬─────────────────────
├─data-name-1─┤ └─redefines-clause─┘
└─FILLER──────┘
──┬────────────────────────┬──┬─────────────────┬──┬───────────────┬───────
└─blank-when-zero-clause─┘ └─external-clause─┘ └─global-clause─┘
──┬──────────────────┬──┬───────────────┬──┬────────────────┬──────────────
└─justified-clause─┘ └─occurs-clause─┘ └─picture-clause─┘
──┬─────────────┬──┬─────────────────────┬──┬──────────────┬───────────────
└─sign-clause─┘ └─synchronized-clause─┘ └─usage-clause─┘
──┬──────────────┬──┬────────────────────┬────────────────────────────────
└─value-clause─┘ └─date-format-clause─┘
Note: The clauses can be written in any order with two exceptions:
If data-name or FILLER is specified, it must immediately follow the
level-number.
When the REDEFINES clause is specified, it must immediately follow
data-name or FILLER, if either is specified. If data-name or FILLER is not
specified, the REDEFINES clause must immediately follow the level-number.
Level-number in format 1 can be any number from 01–49 or 77.
A space, a separator comma, or a separator semicolon must separate clauses.
Format 2
Format 2 regroups previously defined items.
Format 2
──66──data-name-1──renames-clause.───────────────────────────────────────
A level-66 entry cannot rename another level-66 entry, nor can it rename a level-01,
level-77, or level-88 entry.
All level-66 entries associated with one record must immediately follow the last
data description entry in that record.
Details are contained in “RENAMES clause” on page 178.
Format 3
Format 3 describes condition-names.
Format 3
──88──condition-name-1──value-clause.────────────────────────────────────
condition-name
A user-specified name that associates a value, a set of values, or a range of
values with a conditional variable.
A conditional variable is a data item that can assume one or more values, that
can, in turn, be associated with a condition-name.
Format 3 can be used to describe both elementary and group items. Further
information on condition-name entries can be found under “VALUE clause” on
page 195.
Level-numbers
The level-number specifies the hierarchy of data within a record, and identifies
special-purpose data entries. A level-number begins a data description entry, a
renamed or redefined item, or a condition-name entry. A level-number has a
value taken from the set of integers between 1 and 49, or from one of the special
level-numbers, 66, 77, or 88.
Format
──level-number──┬─────────────┬──────────────────────────────────────────
├─data-name-1─┤
└─FILLER──────┘
level-number
01 and 77 must begin in Area A and must be followed either by a separator
period; or by a space, followed by its associated data-name, FILLER, or
appropriate data description clause.
Level numbers 02 through 49 can begin in Areas A or B and must be followed
by a space or a separator period.
Format
──BLANK──┬──────┬──┬─ZERO───┬────────────────────────────────────────────
└─WHEN─┘ ├─ZEROS──┤
└─ZEROES─┘
The BLANK WHEN ZERO clause can be specified only for elementary numeric or
numeric-edited items. These items must be described, either implicitly or
explicitly, as USAGE IS DISPLAY. When the BLANK WHEN ZERO clause is
specified for a numeric item, the item is considered a numeric-edited item.
Format
──DATE FORMAT──┬────┬──date-pattern──────────────────────────────────────
└─IS─┘
EXTERNAL clause
The EXTERNAL clause specifies that the storage associated with a data item is
associated with the run unit rather than with any particular program or method
within the run unit. An external data item can be referenced by any program or
method in the run unit that describes the data item. References to an external data
item from different programs or methods using separate descriptions of the data
item are always to the same data item. In a run unit, there is only one
representative of an external data item.
The EXTERNAL clause can be specified only in data description entries whose
level-number is 01. It can only be specified on data description entries that are in
the Working-Storage Section of a program or method. It cannot be specified in
Linkage Section or File Section data description entries. Any data item described
by a data description entry subordinate to an entry describing an external record
also attains the EXTERNAL attribute. Indexes in an external data record do not
possess the external attribute.
The data contained in the record named by the data-name clause is external and
can be accessed and processed by any program or method in the run unit that
describes and, optionally, redefines it. This data is subject to the following rules:
If two or more programs or methods within a run unit describe the same
external data record, each record-name of the associated record description
entries must be the same and the records must define the same number of
standard data format characters. However, a program or method that
describes an external record can contain a data description entry including the
REDEFINES clause that redefines the complete external record, and this
complete redefinition need not occur identically in other programs or methods
in the run unit.
Use of the EXTERNAL clause does not imply that the associated data-name is
a global name.
GLOBAL clause
The GLOBAL clause specifies that a data-name is available to every program
contained within the program that declares it, as long as the contained program
does not itself have a declaration for that name. All data-names subordinate to or
condition-names or indexes associated with a global name are global names.
A data-name is global if the GLOBAL clause is specified either in the data
description entry by which the data-name is declared or in another entry to which
that data description entry is subordinate. The GLOBAL clause can be specified in
the Working-Storage Section, the File Section, the Linkage Section, and the
Local-Storage Section, but only in data description entries whose level-number is
01.
In the same Data Division, the data description entries for any two data items for
which the same data-name is specified must not include the GLOBAL clause.
A statement in a program contained directly or indirectly within a program which
describes a global name can reference that name without describing it again.
Two programs in a run unit can reference common data in the following
circumstances:
JUSTIFIED clause
The JUSTIFIED clause overrides standard positioning rules for a receiving item of
the alphabetic or alphanumeric categories.
Format
──┬─JUSTIFIED─┬──┬───────┬───────────────────────────────────────────────
└─JUST──────┘ └─RIGHT─┘
You can only specify the JUSTIFIED clause at the elementary level. JUST is an
abbreviation for JUSTIFIED, and has the same meaning.
You cannot specify the JUSTIFIED clause:
For numeric, numeric-edited, or alphanumeric-edited items
In descriptions of items described with the USAGE IS INDEX clause
For items described as USAGE IS POINTER, USAGE IS
PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE
For external or internal floating-point items
For an edited DBCS item
For date fields
With level-66 (RENAMES) and level-88 (condition-name) entries
When the JUSTIFIED clause is specified for a receiving item, the data is aligned at
the rightmost character position in the receiving item. Also:
If the sending item is larger than the receiving item, the leftmost characters are
truncated.
If the sending item is smaller than the receiving item, the unused character
positions at the left are filled with spaces.
The JUSTIFIED clause can be specified for a DBCS item (except edited DBCS
items). When JUSTIFIED is specified for a receiving item, the data is aligned on
the rightmost character position. If the sending item is larger than the receiving
item, extra characters are truncated on the left. If the sending item is smaller than
the receiving item, any unused positions on the left are filled with DBCS blanks.
If you omit the JUSTIFIED clause, the rules for standard alignment are followed
(see “Alignment rules” on page 128).
The JUSTIFIED clause does not affect initial settings, as determined by the VALUE
clause.
OCCURS clause
The Data Division clauses used for table handling are the OCCURS clause and
USAGE IS INDEX clause. For the USAGE IS INDEX description, see “USAGE
clause” on page 187.
Fixed-length tables
Fixed-length tables are specified using the OCCURS clause. Because seven
subscripts or indexes are allowed, six nested levels and one outermost level of the
format 1 OCCURS clause are allowed. The format 1 OCCURS clause can be
specified as subordinate to the OCCURS DEPENDING ON clause. In this way, a
table of up to seven dimensions can be specified.
integer-2
The exact number of occurrences. Integer-2 must be greater than zero.
The keys for EMPLOYEE-TABLE are subordinate to that entry, while the key for
WEEK-RECORD is subordinate to that subordinate entry.
In the preceding example, records in EMPLOYEE-TABLE must be arranged in
ascending order of WAGE-RATE, and in ascending order of EMPLOYEE-NO
within WAGE-RATE. Records in WEEK-RECORD must be arranged in ascending
order of WEEK-NO. If they are not, results of any SEARCH ALL statement will be
unpredictable.
INDEXED BY phrase
The INDEXED BY phrase specifies the indexes that can be used with a table. The
INDEXED BY phrase is required if indexing is used to refer a this table element.
See “Subscripting using index-names (indexing)” on page 45.
A table without an INDEXED BY option can be referred to through indexing.
Indexes normally are allocated in static memory associated with the program
containing the table. Thus, indexes are in the last-used state when a program is
reentered. However, in the following cases, indexes are allocated on a
per-invocation basis. Thus, you must SET the value of the index on every entry
for indexes on tables in the:
Local-Storage Section
Working-Storage Section of a class definition (object instance variables)
Linkage Section of a:
— Method
— Program compiled with the RECURSIVE attribute
— Program compiled with the THREAD option (workstation only)
Note: Indexes specified in an External data record do not possess the external
attribute.
index-name-1
Must follow the rules for formation of user-defined words. At least one
character must be alphabetic.
Each index-name specifies an index to be created by the compiler for use by
the program. These index-names are not data-names, and are not identified
elsewhere in the COBOL program; instead, they can be regarded as private
special registers for the use of this object program only. They are not data, or
part of any data hierarchy.
As an IBM extension, unreferenced index names need not be uniquely defined.
Variable-length tables
Variable-length tables are specified using the OCCURS DEPENDING ON clause.
integer-1
The minimum number of occurrences.
The value of integer-1 must be greater than or equal to zero; it must also be
less than the value of integer-2.
integer-2
The maximum number of occurrences.
Integer-2 must be greater than integer-1.
The length of the subject item is fixed; it is only the number of repetitions of the
subject item that is variable.
PICTURE clause
The PICTURE clause specifies the general characteristics and editing requirements
of an elementary item.
Format
──┬─PICTURE─┬──┬────┬──character-string──────────────────────────────────
└─PIC─────┘ └─IS─┘
PICTURE or PIC
The PICTURE clause must be specified for every elementary item except an
index data item or the subject of the RENAMES clause. In these cases, use of
this clause is prohibited.
The PICTURE clause can be specified only at the elementary level.
PIC is an abbreviation for PICTURE and has the same meaning.
character-string
PICTURE character-string is made up of certain COBOL characters used as
symbols. The allowable combinations determine the category of the
elementary data item.
All other lowercase letters are not equivalent to their corresponding uppercase
representations.
The heading Size refers to the number of bytes the symbol contributes to the
actual size of the data item.
In the following description of the PICTURE clause, cs indicates any valid currency
symbol. For details, see “Currency symbol” on page 165.
Figure 6 shows the sequence in which PICTURE clause symbols must be specified.
Figure legend:
Closed circle indicates that the symbol(s) at the top of
the column can, in a given character-string, appear
anywhere to the left of the symbol(s) at the left of the
row.
■ Closed square indicates that the item is an IBM
extension.
{} Braces indicate items that are mutually exclusive.
P symbol
Because the scaling position character P implies an assumed decimal point (to the
left of the Ps, if the Ps are leftmost PICTURE characters; to the right of the Ps, if
the Ps are rightmost PICTURE characters), the assumed decimal point symbol, V,
is redundant as either the leftmost or rightmost character within such a PICTURE
description.
In certain operations that reference a data item whose PICTURE character-string
contains the symbol P, the algebraic value of the data item is used rather than the
actual character representation of the data item. This algebraic value assumes the
decimal point in the prescribed location and zero in place of the digit position
specified by the symbol P. The size of the value is the number of digit positions
represented by the PICTURE character-string. These operations are any of the
following:
Any operation requiring a numeric sending operand.
A MOVE statement where the sending operand is numeric and its PICTURE
character-string contains the symbol P.
A MOVE statement where the sending operand is numeric-edited and its
PICTURE character-string contains the symbol P and the receiving operand is
numeric or numeric-edited.
A comparison operation where both operands are numeric.
In all other operations the digit positions specified with the symbol P are ignored
and are not counted in the size of the operand.
Currency symbol
The currency symbol in a character-string is represented by the symbol $, or by a
single character specified either in the CURRENCY compiler option or in the
CURRENCY SIGN clause in the SPECIAL-NAMES paragraph of the Environment
Division.
If the CURRENCY SIGN clause is specified, the CURRENCY and NOCURRENCY
compiler options are ignored. If the CURRENCY SIGN clause is not specified and
the NOCURRENCY compiler option is in effect, the dollar sign ($) is used as the
default currency sign value and currency symbol. For more information about the
CURRENCY SIGN clause, see “CURRENCY SIGN clause” on page 90. For more
information about the CURRENCY and NOCURRENCY compiler options, see the
IBM COBOL Programming Guide for your platform.
A currency symbol can be repeated within the PICTURE character-string to specify
floating insertion. Different currency symbols must not be used in the same
PICTURE character-string.
Unlike all other PICTURE clause symbols, currency symbols are case-sensitive: for
example, 'D' and 'd' specify different currency symbols.
Character-string representation
Symbols that can appear more than once
The following symbols can appear more than once in one PICTURE
character-string:
A B P X Z 9 ? / , + - V cs
G N
PICTURE IS $9(5).9(2)CR
Except for the PICTURE symbol V, each time any of the above symbols
appears in the character-string, it represents an occurrence of that character or
set of allowable characters in the data item.
Alphabetic items
The PICTURE character-string can contain only the symbol A.
The contents of the item in standard data format must consist of any of the letters
of the English alphabet and the space character.
Numeric items
Types of numeric items are:
Binary
Packed decimal (internal decimal)
Zoned decimal (external decimal)
The PICTURE character-string can contain only the symbols 9, P, S, and V. For
numeric date fields, the PICTURE character-string can contain only the symbols 9
and S.
| For binary items, the number of digit positions must range from 1 through 18
| inclusive. For packed decimal and zoned decimal items the number of digit
| positions must range from 1 through 18, inclusive, when the ARITH(COMPAT)
| compiler option is in effect, or from 1 through 31, inclusive, when the
| ARITH(EXTEND) compiler option is in effect. For numeric date fields, the number
of digit positions must match the number of characters specified by the DATE
FORMAT clause.
If unsigned, the contents of the item in standard data format must contain a
combination of the Arabic numerals 0-9. If signed, it can also contain a +, −, or
other representation of the operational sign.
Numeric-edited items
The PICTURE character-string can contain the following symbols:
B P V Z 9 ? / , . + - CR DB V cs
Alphanumeric items
The PICTURE character-string must consist of either of the following:
The symbol X
Combinations of the symbols A, X, and 9 (A character-string containing all As
or all 9s does not define an alphanumeric item.)
The item is treated as if the character-string contained only the symbol X.
The contents of the item in standard data format can be any allowable characters
from the character set of the computer.
Alphanumeric-edited items
The PICTURE character-string can contain the following symbols:
A X 9 B ? /
The string must contain at least one A or X, and at least one B or 0 (zero) or /.
The contents of the item in standard data format must be two or more characters
from the character set of the computer.
+ or −
A sign character must immediately precede both the mantissa and the
exponent.
A + sign indicates that a positive sign will be used in the output to represent
positive values and that a negative sign will represent negative values.
A − sign indicates that a blank will be used in the output to represent positive
values and that a negative sign will represent negative values.
Each sign position occupies one byte of storage.
An actual decimal point can be represented with a period (.) while an assumed
decimal point is represented by a V.
Either an actual or an assumed decimal point must be present in the mantissa;
the decimal point can be leading, embedded, or trailing.
The mantissa can contain from 1 to 16 numeric characters.
E Indicates the exponent.
exponent
The exponent must consist of the symbol 99.
Other clauses: The OCCURS, REDEFINES, RENAMES, and USAGE clauses can
be associated with external floating-point items.
The SIGN clause is accepted as documentation and has no effect on the
representation of the sign.
The SYNCHRONIZED clause is treated as documentation.
The following clauses are invalid with external floating-point items:
BLANK WHEN ZERO
JUSTIFIED
VALUE
Special insertion .
Fixed insertion cs + − CR DB
Floating insertion cs + −
Zero suppression Z*
Replacement Z * + − cs
Alphanumeric None None
Alphanumeric-edited Simple insertion B0/
DBCS Simple insertion B
External floating-point Special insertion .
+ + -
- space -
CR 2 spaces CR
DB 2 spaces DB
For example:
PICTURE Value of Data Edited Result
Do not specify both the asterisk (*) as a suppression symbol and the BLANK
WHEN ZERO clause for the same entry.
REDEFINES clause
The REDEFINES clause allows you to use different data description entries to
describe the same computer storage area.
Format
──level-number──┬─────────────┬──REDEFINES──data-name-2──────────────────
├─data-name-1─┤
└─FILLER──────┘
In this example, A is the redefined item, and B is the redefining item. Redefinition
begins with B and includes the two subordinate items B-1 and B-2. Redefinition
ends when the level-05 item C is encountered.
The data description entry for data-name-2, the redefined item, can contain a
REDEFINES clause.
The data description entry for the redefined item cannot contain an OCCURS
clause. However, the redefined item can be subordinate to an item whose data
description entry contains an OCCURS clause. In this case, the reference to the
redefined item in the REDEFINES clause must not be subscripted. Neither the
redefined item nor the redefining item, or any items subordinate to them, can
contain an OCCURS DEPENDING ON clause.
If the GLOBAL clause is used in the data description entry which contains the
REDEFINES clause, it is only the subject of that REDEFINES clause that possesses
the global attribute.
The EXTERNAL clause must not be specified on the same data description entry
as a REDEFINES clause.
If the data item referenced by data-name-2 is either declared to be an external data
record or is specified with a level-number other than 01, the number of character
positions it contains must be greater than or equal to the number of character
positions in the data item referenced by the subject of this entry. If the data-name
referenced by data-name-2 is specified with a level-number of 01 and is not
declared to be an external data record, there is no such constraint.
Data item lengths and types can also be re-specified within an area. For example:
?5 NAME-2.
1? SALARY PICTURE XXX.
1? SO-SEC-NO PICTURE X(9).
1? MONTH PICTURE XX.
?5 NAME-1 REDEFINES NAME-2.
1? WAGE PICTURE 999V999.
1? EMP-NO PICTURE X(6).
1? YEAR PICTURE XX.
When an area is redefined, all descriptions of the area are always in effect; that is,
redefinition does not cause any data to be erased and never supersedes a previous
description. Thus, if B REDEFINES C has been specified, either of the two
procedural statements, MOVE X TO B and MOVE Y TO C, could be executed at any
point in the program.
In the first case, the area described as B would assume the value and format of X.
In the second case, the same physical area (described now as C) would assume the
value and format of Y. Note that, if the second statement is executed immediately
after the first, the value of Y replaces the value of X in the one storage area.
The usage of a redefining data item need not be the same as that of a redefined
item. This does not, however, cause any change in existing data. For example:
Redefining B does not change the bit configuration of the data in the storage area.
Therefore, the following two statements produce different results:
ADD B TO A
ADD C TO A
In the first case, the value 8 is added to A (because B has USAGE DISPLAY). In the
second statement, the value -3848 is added to A (because C has USAGE
COMPUTATIONAL-4), and the bit configuration of the storage area has the binary
value -3848.
The above example demonstrates how the improper use of redefinition can give
unexpected or incorrect results.
Undefined results
Undefined results can occur when:
A redefining item is moved to a redefined item (that is, if B REDEFINES C and
the statement MOVE B TO C is executed).
A redefined item is moved to a redefining item (that is, if B REDEFINES C and if
the statement MOVE C TO B is executed).
RENAMES clause
The RENAMES clause specifies alternative, possibly overlapping, groupings of
elementary data items.
Format
──66──data-name-1──RENAMES──data-name-2──┬──────────────────────────┬────
└─┬─THROUGH─┬──data-name-3─┘
└─THRU────┘
The special level-number 66 must be specified for data description entries that
contain the RENAMES clause. Level-number 66 and data-name-1 are not part of
the RENAMES clause itself, and are included in the format only for clarity.
One or more RENAMES entries can be written for a logical record. All RENAMES
entries associated with one logical record must immediately follow that record's
last data description entry.
data-name-1
Identifies an alternative grouping of data items.
A level-66 entry cannot rename a level-01, level-77, level-88, or another level-66
entry.
Data-name-1 cannot be used as a qualifier; it can be qualified only by the
names of level indicator entries or level-01 entries.
Can specify a DBCS data item if data-name-2 specifies a DBCS data item and
the THROUGH phrase is not specified.
data-name-2, data-name-3
Identify the original grouping of elementary data items; that is, they must
name elementary or group items within the associated level-01 entry, and must
not be the same data-name. Both data-names can be qualified.
The OCCURS clause must not be specified in the data entries for data-name-2
and data-name-3, or for any group entry to which they are subordinate. In
addition, the OCCURS DEPENDING ON clause must not be specified for any
item defined between data-name-2 and data-name-3.
When data-name-3 is specified, data-name-1 is treated as a group item that
includes all elementary items:
Starting with data-name-2 (if it is an elementary item) or the first
elementary item within data-name-2 (if it is a group item).
Ending with data-name-3 (if it is an elementary item) or the last
elementary item within data-name-3 (if it is a group item).
The key words THROUGH and THRU are equivalent.
The leftmost character in data-name-3 must not precede the leftmost character
in data-name-2; the rightmost character in data-name-3 must not precede the
rightmost character in data-name-2. This means that data-name-3 cannot be
totally subordinate to data-name-2.
When data-name-3 is not specified, all of the data attributes of data-name-2
become the data attributes for data-name-1. That is:
When data-name-2 is a group item, data-name-1 is treated as a group item.
SIGN clause
The SIGN clause specifies the position and mode of representation of the
operational sign for a numeric entry.
The SIGN clause can be specified only for a signed numeric data description entry
(that is, one whose PICTURE character-string contains an S), or for a group item
that contains at least one such elementary entry. USAGE IS DISPLAY must be
specified, explicitly or implicitly.
If a SIGN clause is specified in either an elementary or group entry subordinate to
a group item for which a SIGN clause is specified, the SIGN clause for the
subordinate entry takes precedence for the subordinate entry.
If you specify the CODE-SET clause in an FD entry, any signed numeric data
description entries associated with that file description entry must be described
with the SIGN IS SEPARATE clause.
The SIGN clause is required only when an explicit description of the properties
and/or position of the operational sign is necessary.
When specified, the SIGN clause defines the position and mode of representation
of the operational sign for the numeric data description entry to which it applies,
or for each signed numeric data description entry subordinate to the group to
which it applies.
If the SEPARATE CHARACTER phrase is not specified, then:
The operational sign is presumed to be associated with the LEADING or
TRAILING digit position, whichever is specified, of the elementary numeric
data item. (In this instance, specification of SIGN IS TRAILING is the
equivalent of the standard action of the compiler.)
The character S in the PICTURE character string is not counted in determining
the size of the item (in terms of standard data format characters).
If the SEPARATE CHARACTER phrase is specified, then:
The operational sign is presumed to be the LEADING or TRAILING character
position, whichever is specified, of the elementary numeric data item. This
character position is not a digit position.
The character S in the PICTURE character string is counted in determining the
size of the data item (in terms of standard data format characters).
+ is the character used for the positive operational sign.
- is the character used for the negative operational sign.
The SEPARATE CHARACTER phrase cannot be specified for a date field.
Every numeric data description entry whose PICTURE contains the symbol S is a
signed numeric data description entry. If the SIGN clause is also specified for
such an entry, and conversion is necessary for computations or comparisons, the
conversion takes place automatically.
The SIGN clause is treated as documentation for external floating-point items. For
internal floating-point items, the SIGN clause must not be specified.
SYNCHRONIZED clause
The SYNCHRONIZED clause specifies the alignment of an elementary item on a
natural boundary in storage.
Format
──┬─SYNCHRONIZED─┬──┬───────┬────────────────────────────────────────────
└─SYNC─────────┘ ├─LEFT──┤
└─RIGHT─┘
In the File Section, the compiler assumes that all level-01 records containing
SYNCHRONIZED items are aligned on doubleword boundaries in the buffer. You
must provide the necessary slack bytes between records to ensure alignment when
there are multiple records in a block.
In the Working-Storage Section, the compiler aligns all level-01 entries on a
doubleword boundary.
For the purposes of aligning binary items in the Linkage Section, all level-01 items
are assumed to begin on doubleword boundaries. Therefore, if you issue a CALL
statement, such operands of any USING phrase within it must be aligned
correspondingly.
?1 FIELD-L.
?5 FIELD-M PICTURE X(5).
?5 FIELD-N PICTURE XX.
[?5 SLACK-BYTES PICTURE X. INSERTED BY COMPILER]
?5 FIELD-O.
1? FIELD-P COMPUTATIONAL PICTURE S9(6) SYNC.
Slack bytes can also be added by the compiler when a group item is defined with
an OCCURS clause and contains within it a SYNCHRONIZED binary data item.
To determine whether slack bytes are to be added, the following action is taken:
In order to align COMP-PAY and COMP-HRS upon their proper boundaries, the
compiler has added two slack bytes within the record.
In the example previous, without further adjustment, the second occurrence of
COMP-TABLE would begin one byte before a doubleword boundary, and the
alignment of COMP-PAY and COMP-HRS would not be valid for any occurrence of the
table after the first. Therefore, the compiler must add slack bytes at the end of the
group, as though the record had been written as follows:
?1 WORK-RECORD.
?5 WORK-CODE PICTURE X.
?5 COMP-TABLE OCCURS 1? TIMES.
1? COMP-TYPE PICTURE X.
[1? SLACK-BYTES PIC XX. INSERTED BY COMPILER ]
1? COMP-PAY PICTURE S9(4)V99 COMP SYNC.
1? COMP-HRS PICTURE S9(3) COMP SYNC.
1? COMP-NAME PICTURE X(5).
[1? SLACK-BYTES PIC XX. INSERTED BY COMPILER]
In this example, the second (and each succeeding) occurrence of COMP-TABLE begins
one byte beyond a doubleword boundary. The storage layout for the first
occurrence of COMP-TABLE will now appear as shown in Figure 9.
Each succeeding occurrence within the table will now begin at the same relative
position as the first.
The number of bytes in A-1, A-2, and A-3 totals 11. B-1 is a 4-digit
COMPUTATIONAL item and 1 slack byte must therefore be added before B-1.
With this byte added, the number of bytes preceding B-2 totals 14. Because B-2 is
a COMPUTATIONAL item of 5 digits in length, two slack bytes must be added
before it. No slack bytes are needed before B-3.
The revised record description entry now appears as:
There is a total of 22 bytes in COMP-RECORD, but, from the rules given in the
preceding discussion, it appears that m = 4 and r = 2. Therefore, to attain proper
alignment for blocked records, you must add 2 slack bytes at the end of the record.
The final record description entry appears as:
?1 COMP-RECORD.
?5 A-1 PICTURE X(5).
?5 A-2 PICTURE X(3).
?5 A-3 PICTURE X(3).
[?5 SLACK-BYTE-1 PICTURE X. INSERTED BY COMPILER]
?5 B-1 PICTURE S9999 USAGE COMP SYNCHRONIZED.
[?5 SLACK-BYTE-2 PICTURE XX. INSERTED BY COMPILER]
?5 B-2 PICTURE S99999 USAGE COMP SYNCHRONIZED.
?5 B-3 PICTURE S9999 USAGE COMP SYNCHRONIZED.
?5 FILLER PICTURE XX. [SLACK BYTES YOU ADD]
USAGE clause
The USAGE clause specifies the format of a data item in computer storage.
Format 1
──┬───────────────┬──┬─BINARY──┬──────────┬──────────┬───────────────────
└─USAGE──┬────┬─┘ │ (1) ┘
└─NATIVE─── │
└─IS─┘ ├─COMP──────────────────────────┤
├─COMP-1──┬──────────┬──────────┤
│ (1) ┘
└─NATIVE─── │
├─COMP-2──┬──────────┬──────────┤
│ (1)
└─NATIVE───┘ │
├─COMP-3────────────────────────┤
├─COMP-4──┬──────────┬──────────┤
│ (1) ┘
└─NATIVE─── │
| ├─COMP-5────────────────────────┤
├─COMPUTATIONAL─────────────────┤
├─COMPUTATIONAL-1──┬──────────┬─┤
│ └─NATIVE─── (1) ┘ │
├─COMPUTATIONAL-2──┬──────────┬─┤
│ └─NATIVE─── (1) ┘ │
├─COMPUTATIONAL-3───────────────┤
├─COMPUTATIONAL-4──┬──────────┬─┤
│ └─NATIVE─── (1) ┘ │
| ├─COMPUTATIONAL-5───────────────┤
├─DISPLAY──┬──────────┬─────────┤
│ (1) ┘
└─NATIVE─── │
├─DISPLAY-1──┬──────────┬───────┤
│ └─NATIVE─── (1) ┘ │
├─INDEX─────────────────────────┤
├─┤ objref phrase ├─────────────┤
├─PACKED-DECIMAL────────────────┤
├─POINTER───────────────────────┤
└─PROCEDURE-POINTER─────────────┘
objref phrase
├──OBJECT REFERENCE──┬─────────────────────────────────────┬────────────────┤
└─┬───────────────────┬──class-name-1─┘
└─METACLASS──┬────┬─┘
└─OF─┘
Note:
1 The NATIVE phrase is treated as a comment for COMP-3,
COMPUTATIONAL-3, COMP-5, COMPUTATIONAL-5, and
PACKED-DECIMAL data items. Under OS/390 and VM, NATIVE has no
effect.
The USAGE clause can be specified for a data description entry with a
level-number other than 66 or 88. However, if it is specified at the group level, it
applies to each elementary item in the group. The usage of an elementary item
must not contradict the usage of a group to which the elementary item belongs.
The USAGE clause specifies the format in which data is represented in storage.
The format can be restricted if certain Procedure Division statements are used.
When the USAGE clause is not specified at either the group or elementary level, it
is assumed that the usage is DISPLAY.
For data items defined with the DATE FORMAT clause, only usage DISPLAY and
COMP-3 (or its equivalents, COMPUTATIONAL-3 and PACKED-DECIMAL) are
allowed. For details, see “Combining the DATE FORMAT clause with other
clauses” on page 150.
The operational sign for “big-endian” binary data (such as OS/390 and VM) is
contained in the left most bit of the binary data. The operational sign for
“little-endian” binary data is contained in the left most bit of the right most
byte of the binary data.
| Note: The TRUNC(BIN) compiler option causes all binary data items (USAGE
| COMP, COMP-4) to be handled as if they were declared with USAGE
| COMP-5.
| The picture for a COMP-5 data item can specify a scaling factor (that is,
| decimal positions or implied integer positions). In this case, the maximal
| capacities listed in the table above must be scaled appropriately. For example,
| a data item with description PICTURE S99V99 COMP-5 is represented in
| storage as a binary half-word, and supports a range of values from -327.68 to
| +327.67.
DISPLAY-1 phrase
The DISPLAY-1 phrase defines an item as DBCS.
INDEX phrase
A data item defined with the INDEX phrase is an index data item.
An index data item is a 4-byte elementary item (not necessarily connected with
any table) that can be used to save index-name values for future reference.
Through a SET statement, an index data item can be assigned an index-name
value; such a value corresponds to the occurrence number in a table.
POINTER phrase
A data item defined with USAGE IS POINTER is a pointer data item. A pointer
data item is a 4-byte elementary item,
You can use pointer data items to accomplish limited base addressing. Pointer
data items can be compared for equality or moved to other pointer items.
A pointer data item can only be used:
In a SET statement (format 5 only)
In a relation condition
In the USING phrase of a CALL statement, an ENTRY statement, or the
Procedure Division header.
The USAGE IS POINTER clause can be written at any level except level 88. If a
group item is described with the USAGE IS POINTER clause, the elementary items
within the group are pointer data items; the group itself is not a pointer data item
and cannot be used in the syntax where a pointer data item is allowed. The
USAGE clause of an elementary item cannot contradict the USAGE clause of a
group to which the item belongs.
PROCEDURE-POINTER phrase
A procedure-pointer data item can contain the address of a procedure entry point.
Procedure-pointer data items can be compared for equality or moved to other
procedure-pointer data items.
Under OS/390 and VM, a procedure-pointer data item is an 8-byte
elementary item.
NATIVE phrase
Under OS/390 and VM, the NATIVE phrase is treated as a comment.
Using the NATIVE phrase, you can mix characters, floating point, and binary data
as represented on the S390 and native platform. The NATIVE phrase overrides the
CHAR(EBCDIC), FLOAT(HEX), and BINARY(S390) compiler options, which
indicate host data type usages. (Note, the BINARY compiler option is applicable
only to Windows programs.)
Using both host and native data types within a program (ASCII and EBCDIC, Hex
Floating point and IEEE floating point, and/or big endian and little endian binary)
is only valid for those data items specifically defined with the NATIVE phrase.
Specifying NATIVE does not change the class or the category of the data item.
Numeric data items are treated in arithmetic operations (numeric comparisons,
arithmetic expressions, assignment to numeric targets, arithmetic statement) based
on their logical numeric values, regardless of their internal representations.
Characters are converted to the representation of the target item prior to an
assignment.
Comparisons are done based on the collating sequence rules applicable to the
operands. If native and non-native characters are compared, the comparison is
based on the COLLSEQ option in effect.
VALUE clause
The VALUE clause specifies the initial contents of a data item or the value(s)
associated with a condition name. The use of the VALUE clause differs depending
on the Data Division section in which it is specified.
In the class Working-Storage Section, the VALUE clause can only be used in
condition-name entries.
As an IBM extension, in the File and Linkage Sections, if the VALUE clause is used
in entries other than condition-name entries, the VALUE clause is treated as a
comment.
In the Working-Storage Section, the VALUE clause can be used in condition-name
entries, or in specifying the initial value of any data item. The data item assumes
the specified value at the beginning of program execution. If the initial value is
not explicitly specified, it is unpredictable.
Format 1
Format 1—literal value
──VALUE──┬────┬──literal─────────────────────────────────────────────────
└─IS─┘
Format 2
Format 2—condition-name value
──88──condition-name-1──┬─VALUE──┬────┬───┬───────────────────────────────
│ └─IS─┘ │
└─VALUES──┬─────┬─┘
└─ARE─┘
┌──
───────────────────────────────────────┐
───/─literal-1──┬────────────────────────┬─┴──.────────────────────────────
└─┬─THROUGH─┬──literal-2─┘
└─THRU────┘
Format 3
Format 3—NULL value
──VALUE──┬────┬──┬─NULL──┬───────────────────────────────────────────────
└─IS─┘ └─NULLS─┘
This format assigns an invalid address as the initial value of an item defined as
USAGE IS POINTER or USAGE IS PROCEDURE-POINTER. It also assigns an
invalid object reference as the initial value of an item defined as USAGE IS
OBJECT REFERENCE.
VALUE IS NULL can only be specified for elementary items described implicitly
or explicitly as USAGE IS POINTER, USAGE IS PROCEDURE-POINTER, or
USAGE IS OBJECT REFERENCE.
can be omitted.
2 Priority-numbers are not valid for methods, recursive programs, or (under AIX and Windows)
USING
The USING phrase makes data items defined in a calling program available to
a called subprogram or an invoked method.
Only specify the USING phrase if the program is invoked by a CALL
statement or a method is invoked by the INVOKE statement and the CALL or
INVOKE statement includes a USING phrase.
The USING phrase is valid in the Procedure Division header of a called
subprogram entered at the beginning of the nondeclaratives portion; each
USING identifier must be defined as a level-01 or level-77 item in the Linkage
Section of the called subprogram or invoked method; it must not contain a
REDEFINES clause.
A data item in the USING phrase of the Procedure Division header can have a
REDEFINES clause in its data description entry.
In a called subprogram entered at the first executable statement following an
ENTRY statement, the USING option is valid in the ENTRY statement; each
USING identifier must be defined as a level-01 or level-77 item in the Linkage
Section of the called subprogram or invoked method. In a calling program, the
USING phrase is valid for the CALL or INVOKE statement; each USING
identifier must be defined as a level-01, level-77, or an elementary item in the
Data Division.
Each USING identifier in a calling program can be a data item of any level in
the Data Division.
It is possible to call from non-COBOL programs or pass user parameters from
a system command to a COBOL main program.
Data items defined in the Linkage Section of the called program or invoked
method, can be referenced within the Procedure Division of that program if, and
only if, they satisfy one of the following conditions:
They are operands of the USING phrase of the Procedure Division header or
the ENTRY statement
They are operands of SET ADDRESS OF, CALL...BY REFERENCE ADDRESS
OF, or INVOKE...BY REFERENCE ADDRESS OF
Declaratives
Declaratives provide one or more special-purpose sections that are executed when
an exceptional condition occurs.
When Declarative Sections are specified, they must be grouped at the beginning of
the Procedure Division, and the entire Procedure Division must be divided into
sections.
Each Declarative Section starts with a USE statement that identifies the section's
function; the series of procedures that follow specify what actions are to be taken
when the exceptional condition occurs. Each Declarative Section ends with
another section-name followed by a USE statement, or with the key words END
DECLARATIVES. See “USE statement” on page 482 for more information on the
USE statement.
The entire group of Declarative Sections is preceded by the key word
DECLARATIVES, written on the line after the Procedure Division header; the
group is followed by the key words END DECLARATIVES. The key words
DECLARATIVES and END DECLARATIVES must each begin in Area A and be
followed by a separator period. No other text can appear on the same line.
In the declaratives part of the Procedure Division, each section header must be
followed by a separator period, and must be followed by a USE statement,
followed by a separator period. No other text can appear on the same line.
The USE statement has three formats:
1. EXCEPTION declarative (see “USE statement” on page 482)
2. DEBUGGING declarative (see “USE statement” on page 482)
3. LABEL declarative (see “USE statement” on page 482)
The USE statement itself is never executed; instead, the USE statement defines the
conditions that execute the succeeding procedural paragraphs, which specify the
actions to be taken. After the procedure is executed, control is returned to the
routine that activated it.
Within a declarative procedure, except for the USE statement itself, there must be
no reference to any nondeclarative procedure.
As IBM extensions, the following apply to declarative procedures:
Under AIX, Windows, OS/390, and VM:
A declarative procedure can be performed from a nondeclarative
procedure.
Additionally, under OS/390 and VM:
A nondeclarative procedure can be performed from a declarative
procedure.
A declarative procedure can be referenced in a GO TO statement in a
declarative procedure.
Procedures
Within the Procedure Division, a procedure consists of:
A section or a group of sections
A paragraph or group of paragraphs
A procedure-name is a user-defined name that identifies a section or a paragraph.
Section
A section-header optionally followed by one or more paragraphs.
Section-header
A section-name followed by the key word SECTION, optionally followed,
by a priority-number, followed by a separator period.
Section-headers are optional after the key words END DECLARATIVES or
if there are no declaratives.
Section-name
A user-defined word that identifies a section. A referenced
section-name, because it cannot be qualified, must be unique within
the program in which it is defined.
Priority-number
An integer or a positive signed numeric literal ranging in value from 0
through 99.
Sections in the declaratives portion must contain priority numbers in the
range of 0 through 49.
You cannot specify priority-numbers:
In a method definition
In a program that is declared with the RECURSIVE attribute
In a program that specifies the THREAD compiler option (Workstation
only)
A section ends immediately before the next section header, or at the end of
the Procedure Division, or, in the declaratives portion, at the key words
END DECLARATIVES.
Paragraph
A paragraph-name followed by a separator period, optionally followed by one
or more sentences.
Arithmetic expressions
Arithmetic expressions are used as operands of certain conditional and arithmetic
statements.
An arithmetic expression can consist of any of the following:
1. An identifier described as a numeric elementary item (including numeric
functions)
2. A numeric literal
3. The figurative constant ZERO
4. Identifiers and literals, as defined in items 1, 2, and 3, separated by arithmetic
operators
Arithmetic operators
Five binary arithmetic operators and two unary arithmetic operators (Table 14) can
be used in arithmetic expressions. They are represented by specific characters that
must be preceded and followed by a space.
For details on how a result is stored in a receiving field, see “Storing arithmetic
results that involve date fields” on page 213.
Table 18. Storing arithmetic results involving date fields when ON SIZE ERROR is specified
Sending field
Receiving field Non-date Date field
Non-date Non-windowed Not allowed
Windowed date field Windowed Windowed
Expanded date field Non-windowed Non-windowed
Conditional expressions
A conditional expression causes the object program to select alternative paths of
control, depending on the truth value of a test. Conditional expressions are
specified in EVALUATE, IF, PERFORM, and SEARCH statements.
A conditional expression can be specified in either simple conditions or complex
conditions. Both simple and complex conditions can be enclosed within any
number of paired parentheses; the parentheses do not change whether the
condition is simple or complex.
Simple conditions
There are five simple conditions:
Class condition
Condition-name condition
Relation condition
Sign condition
Switch-status condition
Class condition
The class condition determines whether the content of a data item is alphabetic,
alphabetic-lower, alphabetic-upper, numeric, or contains only the characters in the
set of characters specified by the CLASS clause as defined in the SPECIAL-NAMES
paragraph of the Environment Division.
The class condition determines whether the contents of a data item are DBCS or
KANJI.
Format
──identifier-1──┬────┬──┬─────┬──┬─NUMERIC──────────┬────────────────────
└─IS─┘ └─NOT─┘ ├─ALPHABETIC───────┤
├─ALPHABETIC-LOWER─┤
├─ALPHABETIC-UPPER─┤
├─class-name───────┤
├─DBCS─────────────┤
└─KANJI────────────┘
identifier-1
Must reference a data item whose usage is explicitly or implicitly DISPLAY.
Identifier-1 can reference a data item whose usage is explicitly or implicitly
DISPLAY-1.
If identifier-1 is a function-identifier, it must reference an alphanumeric
function.
NOT
When used, NOT and the next key word define the class test to be executed
for truth value. For example, NOT NUMERIC is a truth test for determining
that an identifier is nonnumeric.
NUMERIC
Identifier consists entirely of the characters 0 through 9, with or without an
operational sign.
If its PICTURE does not contain an operational sign, the identifier being tested
is determined to be numeric only if the contents are numeric and an
operational sign is not present.
If its PICTURE does contain an operational sign, the identifier being tested is
determined to be numeric only if the item is an elementary item, the contents
are numeric, and a valid operational sign is present.
The NUMERIC test cannot be used with an identifier described as alphabetic
or as a group item that contains one or more signed elementary items.
For numeric data items, the identifier being tested can be described as USAGE
DISPLAY or (as IBM extensions) USAGE COMPUTATIONAL-3, or USAGE
PACKED-DECIMAL.
ALPHABETIC
Identifier consists entirely of any combination of the lowercase or uppercase
alphabetic characters A through Z and the space.
The ALPHABETIC test cannot be used with an identifier described as numeric.
Table 19. Valid forms of the class test for different types of identifiers
Type of identifier Valid forms of the class test
Alphabetic ALPHABETIC NOT ALPHABETIC
ALPHABETIC-LOWER NOT ALPHABETIC-LOWER
ALPHABETIC-UPPER NOT ALPHABETIC-UPPER
class-name NOT class-name
Alphanumeric, ALPHABETIC NOT ALPHABETIC
alphanumeric-edited, or ALPHABETIC-LOWER NOT ALPHABETIC-LOWER
numeric-edited ALPHABETIC-UPPER NOT ALPHABETIC-UPPER
NUMERIC NOT NUMERIC
class-name NOT class-name
External-decimal NUMERIC NOT NUMERIC
or internal-decimal
DBCS DBCS NOT DBCS
KANJI NOT KANJI
Condition-name condition
A condition-name condition tests a conditional variable to determine whether its
value is equal to any value(s) associated with the condition-name.
Format
──condition-name─────────────────────────────────────────────────────────
because, in a comparison with a windowed date field, literals are treated as if they
are prefixed by “19”, regardless of the century window. So the above condition
effectively becomes:
IF 2??5122? = 19?5122?...
Relation condition
A relation condition compares two operands, either of which can be an identifier,
literal, arithmetic expression, or index-name. A nonnumeric literal can be enclosed
in parentheses within a relation condition.
Format 1
──operand-1──┬────┬──┬─┬─────┬──┬─GREATER──┬──────┬─┬──────┬──operand-2──
└─IS─┘ │ └─NOT─┘ │ └─THAN─┘ │ │
│ ├─>─────────────────┤ │
│ ├─LESS──┬──────┬────┤ │
│ │ └─THAN─┘ │ │
│ ├─<─────────────────┤ │
│ ├─EQUAL──┬────┬─────┤ │
│ │ └─TO─┘ │ │
│ └─=─────────────────┘ │
├─GREATER──┬──────┬──OR EQUAL──┬────┬─┤
│ └─THAN─┘ └─TO─┘ │
├─>=──────────────────────────────────┤
├─LESS──┬──────┬──OR EQUAL──┬────┬────┤
│ └─THAN─┘ └─TO─┘ │
└─<=──────────────────────────────────┘
Date fields
Date fields can be alphanumeric, external decimal, or internal decimal; the existing
rules for the validity and mode (numeric or nonnumeric) of comparing such items
still apply. For example, an alphanumeric date field cannot be compared with an
internal decimal date field. In addition to these rules, two date fields can be
compared only if they are compatible; they must have the same date format except
for the year part, which can be windowed or expanded.
For year-last date fields, the only comparisons that are supported are IS EQUAL
TO and IS NOT EQUAL TO between two year-last date fields with identical date
formats, or between a year-last date field and a non-date.
Table 21 on page 220 shows supported comparisons for non-year-last date fields.
This table uses the following terms to describe how the comparisons are
performed:
Non-windowed
The comparison is performed with no windowing, as if the operands were
both non-dates.
Windowed
The comparison is performed as if:
1. Any windowed date field in the relation were expanded according to
the century window specified by the YEARWINDOW compiler option,
as described under “Semantics of windowed date fields” on page 149.
Relation conditions can contain arithmetic expressions. For information about the
treatment of date fields in arithmetic expressions, see “Arithmetic with date fields”
on page 211.
DBCS items
Under OS/390 and VM, DBCS data items and literals can be used with
all relational operators. Comparisons are based on the binary collating sequence of
the hexadecimal values of the DBCS characters. If the DBCS items are not the
same length, the smaller item is padded on the right with DBCS spaces.
Format 2
──┬─ADDRESS OF──identifier-1─┬──┬────┬──┬─────┬──┬─EQUAL──┬────┬─┬────────
├─identifier-2─────────────┤ └─IS─┘ └─NOT─┘ │ └─TO─┘ │
├─NULL─────────────────────┤ └─=─────────────┘
└─NULLS────────────────────┘
──┬─ADDRESS OF──identifier-3─┬────────────────────────────────────────────
├─identifier-4─────────────┤
├─NULL─────────────────────┤
└─NULLS────────────────────┘
identifier-1
identifier-3
Can specify any level item defined in the Linkage Section, except 66 and 88.
identifier-2
identifier-4
Must be described as USAGE IS POINTER.
NULL(S)
As in this syntax diagram, can be used only if the other operand is defined as
USAGE IS POINTER. That is, NULL=NULL is not allowed.
Table 22 summarizes the permissible comparisons for USAGE IS POINTER,
NULL, and ADDRESS OF.
Format 3
──┬──────────────┬──┬────┬──┬─────┬──┬─EQUAL──┬────┬─┬────────────────────
├─identifier-1─┤ └─IS─┘ └─NOT─┘ │ └─TO─┘ │
├─NULL─────────┤ └─=─────────────┘
└─NULLS────────┘
──┬──────────────┬────────────────────────────────────────────────────────
├─identifier-2─┤
├─NULL─────────┤
└─NULLS────────┘
identifier-1
identifier-2
Must be described as USAGE IS PROCEDURE-POINTER.
NULL(S)
As in this syntax diagram, can be used only if the other operand is defined as
USAGE IS PROCEDURE-POINTER. That is, NULL=NULL is not allowed.
Table 25 (Page 1 of 2). Comparisons for index-names and index data items
Data-name Literal
(numeric (numeric
Operands Index data integer integer Arithmetic
compared Index-name item only) only) Expression
Index-name Compare Compare Compare Compare Compare
occurrence without occurrence occurrence occurrence
number conversion number number number with
with with literal arithmetic
data-name expression
Sign condition
The sign condition determines whether or not the algebraic value of a numeric
operand is greater than, less than, or equal to zero.
Format
──operand-1──┬────┬──┬─────┬──┬─POSITIVE─┬───────────────────────────────
└─IS─┘ └─NOT─┘ ├─NEGATIVE─┤
└─ZERO─────┘
operand-1
Must be defined as a numeric identifier, or it must be defined as an arithmetic
expression that contains at least one reference to a variable. Operand-1 can be
defined as a floating-point identifier.
The operand is:
POSITIVE if its value is greater than zero
NEGATIVE if its value is less than zero
ZERO if its value is equal to zero
An unsigned operand is either POSITIVE or ZERO.
NOT
One algebraic test is executed for the truth value of the sign condition. For
example, NOT ZERO is regarded as true when the operand tested is positive
or negative in value.
Under OS/390 and VM, if you are using the NUMPROC compiler
option, the results of the sign condition test can be affected. For details, see
the IBM COBOL for OS/390 & VM Programming Guide.
Switch-status condition
The switch-status condition determines the on or off status of an UPSI switch.
Format
──condition-name─────────────────────────────────────────────────────────
condition-name
Must be defined in the SPECIAL-NAMES paragraph as associated with the ON
or OFF value of an UPSI switch. (See “SPECIAL-NAMES paragraph” on
page 83.)
The switch-status condition tests the value associated with the condition-name.
(The value associated with the condition-name is considered to be alphanumeric.)
The result of the test is true if the UPSI switch is set to the value (0 or 1)
corresponding to condition-name. See “UPSI” in the IBM COBOL Programming
Guide for your platform.
Complex conditions
A complex condition is formed by combining simple conditions, combined
conditions, and/or complex conditions with logical operators, or negating these
conditions with logical negation.
Each logical operator must be preceded and followed by a space. The following
table shows the logical operators and their meanings.
Format
──NOT──condition-1───────────────────────────────────────────────────────
The negated simple condition gives the opposite truth value of the simple
condition. That is, if the truth value of the simple condition is true, then the truth
value of that same negated simple condition is false, and vice versa.
Placing a negated simple condition within parentheses does not change its truth
value. That is, the following two statements are equivalent:
NOT A IS EQUAL TO B.
Format
┌──
──────────────────────┐
──condition-1───/─┬─AND─┬──condition-2─┴──────────────────────────────────
└─OR──┘
Parentheses are never needed when either ANDs or ORs (but not both) are used
exclusively in one combined condition. However, parentheses can be needed to
modify the implicit precedence rules to maintain the correct logical relation of
operators and operands.
There must be a one-to-one correspondence between left and right parentheses,
with each left parenthesis to the left of its corresponding right parenthesis.
Table 28 illustrates the relationships between logical operators and conditions C1
and C2.
Order of evaluation:
1. (NOT (A IS GREATER THAN B)) is evaluated, giving some intermediate truth
value, t1. If t1 is true, the combined condition is true, and no further
evaluation takes place. If t1 is false, evaluation continues as follows.
2. (A + B) is evaluated, giving some intermediate result, x.
3. (x IS EQUAL TO C) is evaluated, giving some intermediate truth value, t2. If t2
is false, the combined condition is false, and no further evaluation takes place.
If t2 is true, the evaluation continues as follows.
4. (D IS POSITIVE) is evaluated, giving some intermediate truth value, t3. If t3 is
false, the combined condition is false. If t3 is true, the combined condition is
true.
Format
──relation-condition──────────────────────────────────────────────────────
┌──
───────────────────────────────────────────────────┐
───/─┬─AND─┬──┬─────┬──┬─────────────────────┬──object─┴───────────────────
└─OR──┘ └─NOT─┘ └─relational-operator─┘
Using parentheses
You can use parentheses in combined relation conditions to specify an intended
order of evaluation. Using parentheses can also help you to improve the
readability of conditional expressions.
The following rules govern the use of parentheses in abbreviated combined
relation conditions:
1. Parentheses can be used to change the order of evaluation of the logical
operators AND and OR.
2. The word NOT participates as part of the relational operator when it is
immediately followed by GREATER THAN, >, LESS THAN, <, EQUAL TO,
and =.
3. NOT in any other position is considered a logical operator and thus results in
a negated relation-condition. If you use NOT as a logical operator, only the
relation condition immediately following the NOT is negated; the negation is
not propagated through the abbreviated combined relation condition along
with the subject and relational operator.
4. The logical NOT operator can appear within a parenthetical expression that
immediately follows a relational operator.
5. When a left parenthesis appears immediately after the relational operator, the
relational operator is distributed to all objects enclosed in the parentheses. In
the case of a “distributed” relational operator, the subject and relational
operator remain current after the right parenthesis which ends the distribution.
The following three restrictions apply to cases where the relational operator is
distributed throughout the expression:
a. A simple condition cannot appear within the scope of the distribution.
b. Another relational operator cannot appear within the scope of the
distribution.
c. The logical operator NOT cannot appear immediately after the left
parenthesis, which defines the scope of the distribution.
6. Evaluation proceeds from the least to the most inclusive condition.
7. There must be a one-to-one correspondence between left and right parentheses,
with each left parenthesis to the left of its corresponding right parenthesis. If
the parentheses are unbalanced, the compiler inserts a parenthesis and issues
an E-level message. Note, however, that if the compiler-inserted parenthesis
results in the truncation of the expression, you will receive an S-level
diagnostic message.
8. The last stated subject is inserted in place of the missing subject.
9. The last stated relational operator is inserted in place of the missing relational
operator.
10. Insertion of the omitted subject and/or relational operator ends when:
a. Another simple condition is encountered,
b. A condition-name is encountered,
The following table summarizes the rules for forming an abbreviated combined
relation condition.
Statement categories
There are four categories of COBOL statements:
Imperative
Conditional
Delimited scope
Imperative statements
An imperative statement either specifies an unconditional action to be taken by
the program, or is a conditional statement terminated by its explicit scope
terminator (see “Delimited scope statements” on page 237). A series of imperative
statements can be specified whenever an imperative statement is allowed. A
conditional statement that is terminated by its explicit scope terminator is also
classified as an imperative statement (see “Delimited scope statements” on
page 237). Table 31 lists COBOL imperative statements.
ADD1
COMPUTE1
DIVIDE1
MULTIPLY1
SUBTRACT1
Data movement
ACCEPT (DATE,DAY,DAY-OF-WEEK,TIME)
INITIALIZE
INSPECT
MOVE
SET
STRING2
UNSTRING2
Ending
STOP RUN
EXIT PROGRAM
EXIT METHOD
GOBACK
Input-output
ACCEPT identifier
CLOSE
DELETE3
DISPLAY
OPEN
READ4
REWRITE3
START3
STOP literal
WRITE5
Ordering
MERGE
RELEASE
RETURN6
SORT
ALTER
EXIT
GO TO
PERFORM
Program or method linkage
CALL7
CANCEL
INVOKE
Table handling
SET
Note:
1 Without the ON SIZE ERROR and/or the NOT ON SIZE ERROR phrase.
2 Without the ON OVERFLOW and/or the NOT ON OVERFLOW phrase.
3 Without the INVALID KEY and/or the NOT INVALID KEY phrase.
4 Without the AT END, NOT AT END, INVALID KEY, and/or NOT INVALID KEY
phrases.
5 Without the INVALID KEY, NOT INVALID KEY, END-OF-PAGE, and/or NOT
END-OF-PAGE phrases.
6 Without the AT END and/or NOT AT END phrase.
7 Without the ON OVERFLOW phrase, and without the ON EXCEPTION and/or NOT
ON EXCEPTION phrase.
Conditional statements
A conditional statement specifies that the truth value of a condition is to be
determined, and that the subsequent action of the object program is dependent on
this truth value. (See “Conditional expressions” on page 214.) Table 32 lists
COBOL statements that become conditional when a condition (for example, ON
SIZE ERROR or ON OVERFLOW) is included, and when the statement is not
terminated by its explicit scope terminator.
STRING...ON OVERFLOW
STRING...NOT ON OVERFLOW
UNSTRING...ON OVERFLOW
UNSTRING...NOT ON OVERFLOW
IF
EVALUATE
Input-output
DELETE...INVALID KEY
DELETE...NOT INVALID KEY
READ...AT END
READ...NOT AT END
READ...INVALID KEY
READ...NOT INVALID KEY
REWRITE...INVALID KEY
REWRITE...NOT INVALID KEY
START...INVALID KEY
START...NOT INVALID KEY
WRITE...AT END-OF-PAGE
WRITE...NOT AT END-OF-PAGE
WRITE...INVALID KEY
WRITE...NOT INVALID KEY
Ordering
RETURN...AT END
RETURN...NOT AT END
Program or method linkage
CALL...ON OVERFLOW
CALL...ON EXCEPTION
CALL...NOT ON EXCEPTION
INVOKE...ON EXCEPTION
INVOKE...NOT ON EXCEPTION
Table handling
SEARCH
Compiler-directing statements
Statements that direct the compiler to take a specified action are discussed in
“Compiler-directing statements” on page 464.
Statement operations
COBOL statements perform the following types of operations:
Arithmetic
Data manipulation
Input/output
Procedure branching
There are several phrases common to arithmetic and data manipulation statements,
such as:
CORRESPONDING Phrase
GIVING Phrase
ROUNDED Phrase
SIZE ERROR Phrases
CORRESPONDING phrase
The CORRESPONDING phrase (CORR) allows ADD, SUBTRACT, and MOVE
operations to be performed on elementary data items of the same name if the
group items to which they belong are specified.
Both identifiers following the key word CORRESPONDING must name group
items. In this discussion, these identifiers are referred to as identifier-1 and
identifier-2.
A pair of data items (subordinate items), one from identifier-1 and one from
identifier-2, correspond if the following conditions are true:
In an ADD or SUBTRACT statement, both of the data items are elementary
numeric data items. Other data items are ignored.
GIVING phrase
The value of the identifier that follows the word GIVING is set equal to the
calculated result of the arithmetic operation. Because this identifier is not involved
in the computation, it can be a numeric-edited item.
ROUNDED phrase
| COMPUTE X ROUNDED = A + B
| COMPUTE Y ROUNDED = A - B
The size error occurs because the result of the subtraction, a windowed date
field, has an effective year value of 1930, which falls outside the century
window. For details on how windowed date fields are treated as if they were
converted to expanded date format, see “Subtraction involving date fields” on
page 212.
For more information on how size errors can occur when using date fields, see
“Storing arithmetic results that involve date fields” on page 213.
The size error condition applies only to final results, not to any intermediate
results.
If the resultant identifier is defined with USAGE IS BINARY, COMPUTATIONAL,
or COMPUTATIONAL-4, the largest value that can be contained in it is the
maximum value implied by its associated decimal PICTURE character-string.
If the ROUNDED phrase is specified, rounding takes place before size error
checking.
When a size error occurs, the subsequent action of the program depends on
whether or not the ON SIZE ERROR phrase is specified.
If the ON SIZE ERROR phrase is not specified and a size error condition occurs,
truncation rules apply and the value of the affected resultant identifier is
computed.
If the ON SIZE ERROR phrase is specified and a size error condition occurs, the
value of the resultant identifier affected by the size error is not altered—that is, the
error results are not placed in the receiving identifier. After completion of the
execution of the arithmetic operation, the imperative statement in the ON SIZE
ERROR phrase is executed, control is transferred to the end of the arithmetic
statement, and the NOT ON SIZE ERROR phrase, if specified, is ignored.
For ADD CORRESPONDING and SUBTRACT CORRESPONDING statements, if
an individual arithmetic operation causes a size error condition, the ON SIZE
ERROR imperative statement is not executed until all the individual additions or
subtractions have been completed.
If the NOT ON SIZE ERROR phrase has been specified and, after execution of an
arithmetic operation, a size error condition does not exist, the NOT ON SIZE
ERROR phrase is executed.
When both ON SIZE ERROR and NOT ON SIZE ERROR phrases are specified,
and the statement in the phrase that is executed does not contain any explicit
transfer of control, then, if necessary, an implicit transfer of control is made after
execution of the phrase to the end of the arithmetic statement.
Arithmetic statements
The arithmetic statements are used for computations. Individual operations are
specified by the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements. These
operations can be combined symbolically in a formula, using the COMPUTE
statement.
Size of operands
| If the ARITH(COMPAT) compiler option is in effect, then the maximum size of
| each operand is 18 decimal digits. If the ARITH(EXTEND) compiler option is in
| effect, then the maximum size of each operand is 31 decimal digits.
The composite of operands is a hypothetical data item resulting from aligning the
operands at the decimal point and then superimposing them on one another.
| The composite of operands must not contain more than 18 digits. As an IBM
| extension, the composite of operands can be more than 18 digits.
| The following table shows how the composite of operands is determined for
| arithmetic statements:
For example, assume that each item is defined as follows in the Data Division:
A PICTURE 9(7)V9(5).
B PICTURE 9(11)V99.
C PICTURE 9(12)V9(3).
Overlapping operands
When operands in an arithmetic statement share part of their storage (that is, when
the operands overlap), the result of the execution of such a statement is
unpredictable.
Overlapping operands
When the sending and receiving fields of a data manipulation statement share a
part of their storage (that is, when the operands overlap), the result of the
execution of such a statement is unpredictable.
Input-output statements
COBOL input-output statements transfer data to and from files stored on external
media, and also control low-volume data that is obtained from or sent to an
input/output device.
In COBOL, the unit of file data made available to the program is a record, and you
need only be concerned with such records. Provision is automatically made for
such operations as the movement of data into buffers and/or internal storage,
validity checking, error correction (where feasible), blocking and deblocking, and
volume switching procedures.
The description of the file in the Environment Division and Data Division governs
which input-output statements are allowed in the Procedure Division. Permissible
statements for each type of file organization are shown in Table 44 on page 330
and Table 45 on page 331.
Discussions in the following section use the terms volume and reel. The term
volume refers to all non-unit-record input-output devices. The term reel applies
only to tape devices. Treatment of direct access devices in the sequential access
mode is logically equivalent to the treatment of tape devices.
Status key
If the FILE STATUS clause is specified in the FILE-CONTROL entry, a value is
placed in the specified status key (the 2-character data item named in the FILE
STATUS clause) during execution of any request on that file; the value indicates
the status of that request. The value is placed in the status key before execution of
any EXCEPTION/ERROR declarative or INVALID KEY/AT END phrase
associated with the request.
There are two status key data-names. One is described by data-name-1 in the FILE
STATUS clause of the FILE-CONTROL entry. This is a two character data item
with the first character known as status key 1 and the second character known as
status key 2. The combinations of possible values and their meanings are shown
in Table 35.
The other status key is described by data-name-8 in the FILE STATUS clause of the
FILE-CONTROL entry. Data-name-8 does not apply to QSAM files (OS/390 and
VM only) or to line-sequential files (Workstation only). For more information on
data-name-8, see “FILE STATUS clause” on page 112.
Under AIX and Windows, file status 39 is not supported for line-sequential
files or Btrieve files.
For relative and indexed files in the sequential access mode, the last
input-output statement executed for the file prior to the execution of a
DELETE or REWRITE statement was not a successfully executed READ
statement.
4 A boundary violation exists because an attempt was made to rewrite a
record to a file and the record was not the same size as the record being
replaced, or an attempt was made to write or rewrite a record that was
larger than the largest or smaller than the smallest record allowed by the
RECORD IS VARYING clause of the associated file-name.
6 A sequential READ statement was attempted on a file open in the input or
I-O mode and no valid next record had been established because:
1. The preceding READ statement was unsuccessful but did not cause an at
end condition
2. The preceding READ statement caused an at end condition.
7 The execution of a READ statement was attempted on a file not open in the
input or I-O mode.
8 The execution of a WRITE statement was attempted on a file not open in the
I-O, output, or extend mode.
9 The execution of a DELETE or REWRITE statement was attempted on a file
not open in the I-O mode.
| For QSAM file under OS/390 and VM: An OPEN statement with the
| OUTPUT phrase was attempted, or an OPEN statement with the I-O or
| EXTEND phrase was attempted for an optional file, but no DD statement
| was specified for the file and the CBLQDA(OFF) run-time option was
| specified.
Format
──┬─┬─READ───┬──file-name-1──┬────────┬──┬────────────────────┬─┬────────
│ └─RETURN─┘ └─RECORD─┘ └─INTO──identifier-1─┘ │
└─┬─RELEASE─┬──record-name-1──┬────────────────────┬──────────┘
├─REWRITE─┤ └─FROM──identifier-1─┘
└─WRITE───┘
ACCEPT statement
The ACCEPT statement transfers data into the specified identifier. There is no
editing or error checking of the incoming data.
Data transfer
Format 1—data transfer
──ACCEPT──identifier-1──┬────────────────────────────┬───────────────────
└─FROM──┬─mnemonic-name-1──┬─┘
└─environment-name─┘
Format 1 transfers data from an input/output device into identifier-1. When the
FROM phrase is omitted, the system input device is assumed.
Format 1 is useful for exceptional situations in a program when operator
intervention (to supply a given message, code, or exception indicator) is required.
The operator must, of course, be supplied with the appropriate messages with
which to reply.
Under AIX and Windows, the input file must be a byte stream file
(for example, a file consisting of text data with records delimited by a record
terminator). You can create a byte stream file in your COBOL program using
line-sequential file I-O or with the DISPLAY statement. (Most text editors can be
used to create a byte stream file as well.)
The input file cannot be a VSAM, Btrieve, SFS, or STL file (including sequential,
relative, or indexed files).
If the source of the ACCEPT statement is a file and identifier-1 is filled without
using the full record delimited by the record terminator, the remainder of the
input record is used in the next ACCEPT statement for the file. The record
delimiter characters are removed from the input data before the input records are
moved into the ACCEPT receiving area.
If the source of the ACCEPT statement is a terminal, the data entered at the
terminal, followed by the enter key, is treated as the input data. If the input data
is shorter than identifier-1, the area is padded with spaces.
identifier-1
Can be any group item, or an elementary alphabetic, alphanumeric,
alphanumeric-edited, numeric-edited or external decimal item.
It can also be a DBCS data item or an external floating-point item.
mnemonic-name
Must be associated in the SPECIAL-NAMES paragraph with an input/output
device: either a system input device or a console. For more information on
acceptable values for mnemonic-name, see “SPECIAL-NAMES paragraph” on
page 83.
Console
Under OS/390 and VM:
1. A system-generated message code is automatically displayed, followed
by the literal AWAITING REPLY.
The maximum length of an input message is 114 characters.
2. Execution is suspended.
3. After the message code (the same code as in item 1) is entered from
the console and recognized by the system, ACCEPT statement
execution is resumed. The message is moved to identifier-1 and
left-justified, regardless of its PICTURE clause.
The ACCEPT statement is terminated after any of the following occurs:
— If no data is received from the console. For example, if the operator
hits the ENTER key
— The identifier is filled with data
— Fewer than 114 characters of data are entered
If 114 bytes of data are entered and the identifier is still not filled with
data, then more requests for data are issued to the console.
If more than 114 characters of data are entered, only the first 114
characters will be recognized by the system.
If the identifier is longer than the incoming message, the rightmost
characters are padded with spaces.
If the incoming message is longer than the identifier, the character
positions beyond the length of the identifier are truncated.
| For information about obtaining ACCEPT input from an HFS file or
| stdin, see the IBM COBOL Programming Guide for your platform.
Note: If the device is the same as that used for READ statements, results are
unpredictable.
identifier-2
Can be a group, elementary alphanumeric, alphanumeric-edited,
numeric-edited, external decimal, internal decimal, binary, internal
floating-point, or external floating-point item.
Note: The current date and time is also accessible via the date/time intrinsic
function CURRENT-DATE, which also supports 4-digit year values and provide
additional information (see “Intrinsic functions” on page 402).
ADD statement
The ADD statement sums two or more numeric operands and stores the result.
Format 1
┌──
──────────────────┐ ┌──
───────────────────────────┐
──ADD───/─┬─identifier-1─┬─┴──TO───/─identifier-2──┬─────────┬─┴────────────
└─literal-1────┘ └─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬─────────┬────────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-ADD─┘
└─ON─┘
All identifiers or literals preceding the key word TO are added together, and this
sum is added to and stored in identifier-2. This process is repeated for each
successive occurrence of identifier-2, in the left-to-right order in which identifier-2
is specified.
Format 2
┌──
──────────────────┐
──ADD───/─┬─identifier-1─┬─┴──┬────┬──┬─identifier-2─┬─────────────────────
└─literal-1────┘ └─TO─┘ └─literal-2────┘
┌──
───────────────────────────┐
──GIVING───/─identifier-3──┬─────────┬─┴────────────────────────────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬─────────┬────────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-ADD─┘
└─ON─┘
The values of the operands preceding the word GIVING are added together, and
the sum is stored as the new value of each data item referenced by identifier-3.
Format 3
──ADD──┬─CORRESPONDING─┬──identifier-1──TO──identifier-2──┬─────────┬─────
└─CORR──────────┘ └─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬─────────┬────────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-ADD─┘
└─ON─┘
Elementary data items within identifier-1 are added to and stored in the
corresponding elementary items within identifier-2.
ROUNDED phrase
For formats 1, 2, and 3, see “ROUNDED phrase” on page 239.
END-ADD phrase
This explicit scope terminator serves to delimit the scope of the ADD statement.
END-ADD permits a conditional ADD statement to be nested in another
conditional statement. END-ADD can also be used with an imperative ADD
statement.
For more information, see “Delimited scope statements” on page 237.
ALTER statement
The ALTER statement changes the transfer point specified in a GO TO statement.
The ALTER statement encourages the use of unstructured programming practices;
the EVALUATE statement provides the same function as the ALTER statement and
helps to ensure that your program will be well-structured.
┌──
────────────────────────────────────────────────────────┐
──ALTER───/─procedure-name-1──TO──┬────────────┬──procedure-name-2─┴──────
└─PROCEED TO─┘
CALL statement
The CALL statement transfers control from one object program to another within
the run unit.
The program containing the CALL statement is the calling program; the program
identified in the CALL statement is the called subprogram. Called programs can
contain CALL statements; however, a called program must not execute a CALL
statement that directly or indirectly calls the calling program.
Programs defined with the RECURSIVE attribute can execute a CALL statement
that directly or indirectly CALLs itself.
Do not specify the name of a class or a method in the CALL statement.
Format
──CALL──┬─identifier-1────┬──────────────────────────────────────────────────────────────────────────────────
├─literal-1───────┤
└─procedure-ptr-1─┘
──┬────────────────────────────────────────────────────────────────────────────┬──────────────────────────────
│ ┌──
─────────────────────────────────────────────────────────────────┐ │
│ │ ┌──
──────────────────────────────────┐ │ │
└─USING────┬─┬───────────────────┬───/─┬─┬────────────┬──identifier-2─┬─┴─┬─┴─┘
/
│ └─┬────┬──REFERENCE─┘ │ └─ADDRESS OF─┘ │ │
│ └─BY─┘ (1) ───────────────┤
├─file-name-1─── │
│ └─OMITTED──────────────────────┘ │
│ ┌──
──────────────────────────────────┐ │
├─┬────┬──CONTENT───/─┬─┬────────────┬──identifier-3─┬─┴───────┤
│ └─BY─┘ │ ├─ADDRESS OF─┤ │ │
│ │ └─LENGTH OF──┘ │ │
│ ├─literal-2────────────────────┤ │
│ └─OMITTED──────────────────────┘ │
│ ┌──
──────────────────────────────────┐ │
/
└─┬────┬──VALUE────┬─┬────────────┬──identifier-4─┬─┴─────────┘
└─BY─┘ │ ├─ADDRESS OF─┤ │
│ └─LENGTH OF──┘ │
└─literal-3────────────────────┘
──┬───────────────────────────┬───────────────────────────────────────────────────────────────────────────────
└──RETURNING──identifier-5──┘
──┬───────────────────────────────────────────────────────────────────────────────────────────────────┬───────
├─┬───────────────────────────────────────────┬──┬────────────────────────────────────────────────┬─┤
│ └─┬────┬──EXCEPTION──imperative-statement-1─┘ └─NOT──┬────┬──EXCEPTION──imperative-statement-2─┘ │
│ └─ON─┘ └─ON─┘ │
└─┬────┬──OVERFLOW──imperative-statement-3──────────────────────────────────────────────────────────┘
└─ON─┘
──┬──────────┬───────────────────────────────────────────────────────────────────────────────────────────────
└─END-CALL─┘
Note:
1 File-name-1 is supported under OS/390 and VM only.
identifier-1, literal-1
Literal-1 must be a nonnumeric literal. Identifier-1 must be an alphanumeric
data item such that its value can be a program name.
The rules of formation for program names are dependent on the PGMNAME
compiler option. For details, see the discussion of program names in
“PROGRAM-ID paragraph” on page 70 and also the description of the
PGMNAME compiler option in the IBM COBOL Programming Guide for your
platform.
Identifier-1 can be an alphabetic or zoned decimal data item. Identifier-1
cannot be a windowed date field.
USING phrase
The USING phrase specifies arguments that are passed to the target program.
Include the USING phrase in the CALL statement only if there is a USING phrase
in the Procedure Division header or the ENTRY statement through which the
called program is run. The number of operands in each USING phrase must be
identical.
For more information on the USING phrase see “The Procedure Division header”
on page 204.
The sequence of appearance of the identifiers in the USING phrase of the CALL
statement and in the corresponding USING phrase in the called subprogram's
Procedure Division header determines the correspondence between the identifiers
used by the calling and called programs. This correspondence is positional.
The sequence of appearance of the identifiers in the USING phrase of the CALL
statement and in the corresponding USING phrase in the called program's ENTRY
statement determines the correspondence between the identifiers used by the
calling and called programs.
The values of the parameters referenced in the USING phrase of the CALL
statement are made available to the called subprogram at the time the CALL
statement is executed. The description of the data item in the called program must
describe the same number of character positions as the description of the
corresponding data item in the calling program.
The BY CONTENT, BY REFERENCE and BY VALUE phrases apply to parameters
that follow them until another BY CONTENT, BY REFERENCE, or BY VALUE
phrase is encountered. BY REFERENCE is assumed if you do not specify a BY
CONTENT, BY REFERENCE, or BY VALUE phrase prior to the first parameter.
BY REFERENCE phrase
If the BY REFERENCE phrase is either specified or implied for a parameter, the
corresponding data item in the calling program occupies the same storage area as
the data item in the called program.
Note: If defined in the Linkage Section or File Section, you must have already
provided addressability for identifier-2 prior to invocation of the CALL
statement. You can do this by coding either one of the following: SET
ADDRESS OF identifier-2 TO pointer or PROCEDURE/ENTRY USING.
file-name-1 (OS/390 and VM only)
Under OS/390 and VM, a file-name for a QSAM file. See IBM
COBOL for OS/390 & VM Programming Guide for details on using file-name
with the CALL statement.
ADDRESS OF special register
For information on the ADDRESS OF special register, see “ADDRESS OF” on
page 9.
OMITTED
Indicates that no argument is passed.
BY CONTENT phrase
If the BY CONTENT phrase is specified or implied for a parameter, the called
program cannot change the value of this parameter as referenced in the CALL
statement's USING phrase, though the called program can change the value of the
data item referenced by the corresponding data-name in the called program's
Procedure Division header. Changes to the parameter in the called program do
not affect the corresponding argument in the calling program.
identifier-3
Can be a data item of any level in the Data Division. Identifier-3 cannot be a
function identifier.
Note: If defined in the Linkage Section or File Section, you must have already
provided addressability for identifier-3 prior to invocation of the CALL
statement. You can do this by coding either one of the following: SET
ADDRESS OF identifier-3 TO pointer or PROCEDURE/ENTRY USING.
literal-2
Can be:
A nonnumeric literal
A figurative constant (except ALL literal or NULL/NULLS)
A DBCS literal
LENGTH OF special register
For information on the LENGTH OF special register, see “LENGTH OF” on
page 11.
ADDRESS OF special register
For information on the ADDRESS OF special register, see “ADDRESS OF” on
page 9.
OMITTED
Indicates that no argument is passed.
For nonnumeric literals, the called subprogram should describe the parameter as
PIC X(n) USAGE DISPLAY, where "n" is the number of characters in the literal.
BY VALUE phrase
The BY VALUE phrase applies to all arguments that follow until overridden by
another BY REFERENCE or BY CONTENT phrase.
If the BY VALUE phrase is specified or implied for an argument, the value of the
argument is passed, not a reference to the sending data item. The called program
can modify the formal parameter corresponding to the BY VALUE argument, but
any such changes do not affect the argument since the called program has access
to a temporary copy of the sending data item.
While BY VALUE arguments are primarily intended for communication with
non-COBOL programs (such as C), they can also be used for COBOL-to-COBOL
invocations. In this case, BY VALUE must be specified or implied for both the
argument in the CALL USING phrase and the corresponding formal parameter in
the Procedure Division USING phrase.
identifier-4
Must be an elementary data item in the Data Division. It must be one of the
following:
Binary (USAGE BINARY, COMP, COMP-4, or COMP-5)
Floating point (USAGE COMP-1 or COMP-2)
Pointer (USAGE POINTER)
Procedure-pointer (USAGE PROCEDURE-POINTER)
Object reference (USAGE OBJECT REFERENCE)
Single-byte alphanumeric (such as PIC X or PIC A)
The following can also be passed BY VALUE:
Reference modified item with length one
SHIFT-IN and SHIFT-OUT special registers
LINAGE-COUNTER special register when it is usage binary
ADDRESS OF special register
An ADDRESS OF special register passed BY VALUE is treated as a pointer.
For information on the ADDRESS OF special register, see “ADDRESS OF” on
page 9.
LENGTH OF special register
A LENGTH OF special register passed BY VALUE is treated as a PIC 9(9)
binary. For information on the LENGTH OF special register, see “LENGTH
OF” on page 11.
literal-3
Must be one of the following:
Numeric literal
ZERO
1-character nonnumeric literal
Symbolic character
Single byte figurative constant
— SPACE
— QUOTE
— HIGH-VALUE
RETURNING phrase
identifier-5
The RETURNING data item, which must be defined in the DATA DIVISION.
The return value of the CALLed program is implicitly stored into identifier-5.
You can specify the RETURNING phrase for calls to functions written in COBOL,
C, or in other programming languages that use C linkage conventions. If you
specify the RETURNING phrase on a CALL to a COBOL subprogram:
The CALLed subprogram must specify the RETURNING phrase on its
Procedure Division header.
Identifier-5 and the corresponding Procedure Division RETURNING identifier
in the target program must have the same PICTURE, USAGE, SIGN,
SYNCHRONIZE, JUSTIFIED, and BLANK WHEN ZERO clauses (except that
PICTURE clause currency symbols can differ, and periods and commas can be
interchanged due to the DECIMAL POINT IS COMMA clause).
When the target returns, its return value is assigned to identifier-5, using either
the rules for SET statement, if identifier-6 is USAGE IS INDEX, USAGE IS
POINTER, USAGE IS PROCEDURE-POINTER, or USAGE IS OBJECT
REFERENCE; otherwise, the rules for the MOVE statement are used.
ON EXCEPTION phrase
An exception condition occurs when the called subprogram cannot be made
available. At that time, one of the following two actions will occur:
1. If the ON EXCEPTION phrase is specified, control is transferred to
imperative-statement-1. Execution then continues according to the rules for
each statement specified in imperative-statement-1. If a procedure branching
or conditional statement that causes explicit transfer of control is executed,
ON OVERFLOW phrase
The ON OVERFLOW phrase has the same effect as the ON EXCEPTION phrase.
END-CALL phrase
This explicit scope terminator serves to delimit the scope of the CALL statement.
END-CALL permits a conditional CALL statement to be nested in another
conditional statement. END-CALL can also be used with an imperative CALL
statement.
For more information, see “Delimited scope statements” on page 237.
CANCEL statement
The CANCEL statement ensures that the next time the referenced subprogram is
called it will be entered in its initial state.
Format
┌──
──────────────────┐
──CANCEL───/─┬─identifier-1─┬─┴───────────────────────────────────────────
└─literal-1────┘
identifier-1, literal-1
Literal-1 must be a nonnumeric literal. Identifier-1 must be an alphanumeric
data item such that its value can be a program name. The rules of formation
for program names are dependent on the PGMNAME compiler option. For
details, see the discussion of program names in “PROGRAM-ID paragraph” on
page 70 and also the description of the PGMNAME compiler option in the
IBM COBOL Programming Guide for your platform.
Identifier-1 can be alphabetic or zoned decimal data item. It cannot be a
windowed date field.
Each literal or contents of the identifier specified in the CANCEL statement
must be the same as the literal or contents of the identifier specified in an
associated CALL statement.
The program-name referenced in the CANCEL statement can be affected by
the PGMNAME compiler option. For details, see the IBM COBOL Programming
Guide for your platform.
Do not specify the name of a class or a method in the CANCEL statement.
After a CANCEL statement for a called subprogram has been executed, that
subprogram no longer has a logical connection to the program. The contents of
data items in external data records described by the subprogram are not changed
when that subprogram is canceled. If a CALL statement is executed later by any
program in the run unit naming the same subprogram, that subprogram will be
entered in its initial state.
When a CANCEL statement is executed, all programs contained within the
program referenced by the CANCEL statement are also canceled. The result is the
same as if a valid CANCEL were executed for each contained program in the
reverse order in which the programs appear in the separately compiled program.
A CANCEL statement closes all open files that are associated with an internal file
connector in the program named in the explicit CANCEL statement. Any USE
procedures associated with any of these files are not executed.
You can cancel a called subprogram by referencing it as the operand of a CANCEL
statement, by terminating the run unit of which the subprogram is a member, or
by executing an EXIT PROGRAM statement or GOBACK statement in the called
subprogram if that subprogram possesses the INITIAL attribute.
No action is taken when a CANCEL statement is executed, naming a program that
either:
1.
CLOSE statement
The CLOSE statement terminates the processing of volumes and files.
Format 1—sequential
┌──
───────────────────────────────────────────────────┐
──CLOSE───/─file-name-1──┬──────────────────────────────────┬─┴───────────
(1) ┬──┬──────────────────┬─┤
├─┬─REEL───
(1) ┘
│ └─UNIT─── ├─┬─────┬──REMOVAL─┤ │
│ │ └─FOR─┘ │ │
│ └─WITH NO REWIND───┘ │
(1)
└─┬──────┬──┬─NO REWIND───┬────────┘
└─WITH─┘ └─LOCK────────┘
Note:
1 Under OS/390, the REEL, UNIT, and NO REWIND phrases are not valid
for VSAM files. Under AIX and Windows, the UNIT, REEL, and NO
REWIND phases are treated as a comment. Although, the file status will
be set to 07, indicating a successful completion of a CLOSE for a
non-reel/unit medium.
└─WITH─┘ └─LOCK────────┘
Note:
1 Under AIX and Windows, the UNIT, REEL, and NO REWIND phases are
file-name-1
Designates the file upon which the CLOSE statement is to operate. If more
than one file-name is specified, the files need not have the same organization
or access. File-name-1 must not be a sort or merge file.
REEL/UNIT
Under OS/390 and VM, you can specify these phrases only for QSAM
multivolume or single volume files. The terms REEL and UNIT are
interchangeable.
| Under AIX and Windows, REEL and UNIT are syntax checked, but have no
| effect on the execution of the program.
WITH NO REWIND and FOR REMOVAL
Under OS/390 and VM, these phrases apply only to QSAM tape files. If they
are specified for storage devices to which they do not apply, they are ignored.
Table 37. Indexed and relative file types and CLOSE statement phrases
CLOSE statement phrases Action
CLOSE C
CLOSE WITH LOCK C,E
Table 39 (Page 1 of 2). Meanings of key letters for sequential file types
Key Actions taken
A Previous volumes unaffected
Input and input-output files—If the file is at its end, and label records are
specified, the standard ending label procedure is performed. Standard system
closing procedures are then performed.
If the file is at its end, and label records are not specified, label processing does
not take place, but standard system closing procedures are performed.
If the file is not at its end, standard system closing procedures are performed, but
there is no ending label processing.
Output files—If label records are specified, standard ending label procedures are
performed. Standard system closing procedures are then performed.
If label records are not specified, ending label procedures are not performed, but
standard system closing procedures are performed.
D Volume removal—Treated as a comment.
Input and input-output files—If the current reel/unit is the last and/or only
reel/unit for the file or if the reel is on a non-reel/unit medium, no volume
switching is performed. If another reel/unit exists for the file, the following
operations are performed: a volume switch, beginning volume label procedure,
and the first record on the new volume is made available for reading. If no data
records exist for the current volume, another volume switch occurs.
COMPUTE statement
The COMPUTE statement assigns the value of an arithmetic expression to one or
more data items.
With the COMPUTE statement, arithmetic operations can be combined without the
restrictions on receiving data items imposed by the rules for the ADD, SUBTRACT,
MULTIPLY, and DIVIDE statements.
When arithmetic operations are combined, the COMPUTE statement can be more
efficient than the separate arithmetic statements written in a series.
Format
┌──
───────────────────────────┐
──COMPUTE───/─identifier-1──┬─────────┬─┴──┬─=─────┬───────────────────────
└─ROUNDED─┘ └─EQUAL─┘
──arithmetic-expression──┬────────────────────────────────────────────┬────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬─────────────┬────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-COMPUTE─┘
└─ON─┘
identifier-1
Must name elementary numeric item(s) or elementary numeric-edited item(s).
Can name an elementary floating-point data item.
The word EQUAL can be used in place of =.
If identifier-1 or the result of the arithmetic expression (or both) are date fields,
see “Storing arithmetic results that involve date fields” on page 213 for details
on how the result is stored in identifier-1. If a year-last date field is specified
as identifier-1, then the result of the arithmetic expression must be a non-date.
arithmetic-expression
Can be any arithmetic expression, as defined in “Arithmetic expressions” on
page 209.
When the COMPUTE statement is executed, the value of the arithmetic
expression is calculated, and this value is stored as the new value of each data
item referenced by identifier-1.
An arithmetic expression consisting of a single identifier, numeric function, or
literal allows the user to set the value of the data item(s) referenced by
identifier-1 equal to the value of that identifier or literal.
A year-last date field must not be specified in the arithmetic expression.
ROUNDED phrase
For a discussion of the ROUNDED phrase, see “ROUNDED phrase” on page 239.
CONTINUE statement
The CONTINUE statement allows you to specify a no operation statement.
CONTINUE indicates that no executable instruction is present.
Format
──CONTINUE───────────────────────────────────────────────────────────────
DELETE statement
The DELETE statement removes a record from an indexed or relative file. For
indexed files, the key can then be reused for record addition. For relative files, the
space is then available for a new record with the same RELATIVE KEY value.
When the DELETE statement is executed, the associated file must be open in I-O
mode.
Format
──DELETE──file-name-1──┬────────┬─────────────────────────────────────────
└─RECORD─┘
──┬──────────────────────────────────────────┬─────────────────────────────
└─INVALID──┬─────┬──imperative-statement-1─┘
└─KEY─┘
──┬──────────────────────────────────────────────┬──┬────────────┬────────
└─NOT INVALID──┬─────┬──imperative-statement-2─┘ └─END-DELETE─┘
└─KEY─┘
file-name-1
Must be defined in an FD entry in the Data Division and must be the name of
an indexed or relative file.
After successful execution of a DELETE statement, the record is removed from the
file and can no longer be accessed.
Execution of the DELETE statement does not affect the contents of the record area
associated with file-name-1 or the content of the data item referenced by the
data-name specified in the DEPENDING ON phrase of the RECORD clause
associated with file-name-1.
If the FILE STATUS clause is specified in the File-Control entry, the associated
status key is updated when the DELETE statement is executed.
The file position indicator is not affected by execution of the DELETE statement.
END-DELETE phrase
This explicit scope terminator serves to delimit the scope of the DELETE statement.
END-DELETE permits a conditional DELETE statement to be nested in another
conditional statement. END-DELETE can also be used with an imperative
DELETE statement.
For more information, see “Delimited scope statements” on page 237.
DISPLAY statement
The DISPLAY statement transfers the contents of each operand to the output
device. The contents are displayed on the output device in the order, left to right,
in which the operands are listed.
Format
┌──
──────────────────┐
──DISPLAY───/─┬─identifier-1─┬─┴──┬──────────────────────────────┬─────────
└─literal-1────┘ └─UPON──┬─mnemonic-name-1────┬─┘
└─environment-name-1─┘
──┬────────────────────────┬──────────────────────────────────────────────
└─┬──────┬──NO ADVANCING─┘
└─WITH─┘
identifier-1
If it is numeric and is not described as an external decimal, the identifier-1 is
converted automatically to external format, as follows:
Binary or internal decimal items are converted to external decimal.
Negative signed values cause a low-order sign overpunch.
Internal floating-point numbers are converted to external floating-point
numbers for display, such that:
— A COMP-1 item will display as if it had an external floating-point
PICTURE clause of -.9(8)E-99
— A COMP-2 item will display as if it had an external floating-point
PICTURE clause of -.9(17)E-99
No other identifiers require conversion.
Data items defined with USAGE IS POINTER are converted to an external decimal
number that would have a PICTURE clause of PIC 9(10).
Data items defined with USAGE IS PROCEDURE-POINTER or USAGE IS OBJECT
REFERENCE cannot be specified in a DISPLAY statement.
Index names or data items defined with USAGE IS INDEX cannot be specified in a
DISPLAY statement.
Date fields are treated as non-dates when specified in a DISPLAY statement. That
is, the DATE FORMAT is ignored, and the content of the data item is transferred
to the output device as is.
DBCS data items, explicitly or implicitly defined as USAGE DISPLAY-1, are
transferred to the sending field of the output device. Under OS/390 and VM, for
proper results, the output device must have the capability to recognize DBCS
shift-out and shift-in control characters.
Note: On the system punch device, the last eight characters are used for
PROGRAM-ID name.
When the UPON phrase is omitted, the system's logical output device is
assumed. The list of valid environment-names in a DISPLAY statement is
contained in Table 8 on page 85.
| For details on routing DISPLAY output to stdout, see the IBM
| COBOL Programming Guide for your platform.
WITH NO ADVANCING
When specified, the positioning of the output device will not be changed in
any way following the display of the last operand. If the output device is
capable of positioning to a specific character position, it will remain positioned
at the character position immediately following the last character of the last
operand displayed. If the output device is not capable of positioning to a
specific character position, only the vertical position, if applicable, is affected.
This can cause overprinting.
If the WITH NO ADVANCING phrase is not specified, then after the last
operand has been transferred to the output device, the positioning of the
output device will be reset to the leftmost position of the next line of the
device.
Under OS/390 and VM, COBOL does not support output devices
that are capable of positioning to a specific character position. See the IBM
COBOL Programming Guide for your platform for more information about the
DISPLAY statement.
DIVIDE statement
The DIVIDE statement divides one numeric data item into or by other(s) and sets
the values of data items equal to the quotient and remainder.
Format 1
┌──
───────────────────────────┐
──DIVIDE──┬─identifier-1─┬──INTO───/─identifier-2──┬─────────┬─┴───────────
└─literal-1────┘ └─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬────────────┬─────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-DIVIDE─┘
└─ON─┘
Format 2
──DIVIDE──┬─identifier-1─┬──INTO──┬─identifier-2─┬────────────────────────
└─literal-1────┘ └─literal-2────┘
┌──
───────────────────────────┐
──GIVING───/─identifier-3──┬─────────┬─┴────────────────────────────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬────────────┬─────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-DIVIDE─┘
└─ON─┘
Format 3
──DIVIDE──┬─identifier-1─┬──BY──┬─identifier-2─┬──────────────────────────
└─literal-1────┘ └─literal-2────┘
┌──
───────────────────────────┐
──GIVING───/─identifier-3──┬─────────┬─┴────────────────────────────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬────────────┬─────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-DIVIDE─┘
└─ON─┘
Format 5
──DIVIDE──┬─identifier-1─┬──BY──┬─identifier-2─┬──────────────────────────
└─literal-1────┘ └─literal-2────┘
──GIVING──identifier-3──┬─────────┬──REMAINDER──identifier-4───────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬────────────┬─────
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-DIVIDE─┘
└─ON─┘
ROUNDED phrase
For formats 1, 2, and 3, see “ROUNDED phrase” on page 239.
REMAINDER phrase
The result of subtracting the product of the quotient and the divisor from the
dividend is stored in identifier-4. If identifier-3, the quotient, is a numeric-edited
item, the quotient used to calculate the remainder is an intermediate field that
contains the unedited quotient.
The REMAINDER phrase is invalid if the receiver or any of the operands is a
floating-point item.
Any subscripts for identifier-4 in the REMAINDER phrase are evaluated after the
result of the divide operation is stored in identifier-3 of the GIVING phrase.
END-DIVIDE phrase
This explicit scope terminator serves to delimit the scope of the DIVIDE statement.
END-DIVIDE permits a conditional DIVIDE statement to an imperative statement
so that it can be nested in another conditional statement. END-DIVIDE can also be
used with an imperative DIVIDE statement.
For more information, see “Delimited scope statements” on page 237.
ENTRY statement
The ENTRY statement establishes an alternate entry point into a COBOL called
subprogram.
The ENTRY statement cannot be used in:
Programs that specify a return value using the Procedure Division
RETURNING phrase. For details, see the discussion of the RETURNING
phrase under “The Procedure Division header” on page 204.
Nested program. See “Nested programs” on page 60 for a description of
nested programs.
When a CALL statement naming the alternate entry point is executed in a calling
program, control is transferred to the next executable statement following the
ENTRY statement.
Format
───ENTRY──literal-1───────────────────────────────────────────────────────
──┬────────────────────────────────────────────────────┬──.───────────────
│ ┌──
─────────────────────────────────────────┐ │
│ │ ┌──
────────────┐ │ │
└─USING─────┬───────────────────┬───/identifier-1┴──┴─┘
/
├─┬────┬──REFERENCE─┤
│ └─BY─┘ │
└─┬────┬──VALUE─────┘
└─BY─┘
literal
Must be nonnumeric and conform to the rules for the formation of a
program-name in the outermost program (see “PROGRAM-ID paragraph” on
page 70).
Must not match the program-id or any other ENTRY literal in this program.
Must not be a figurative constant.
Execution of the called program begins at the first executable statement following
the ENTRY statement whose literal corresponds to the CALL statement literal or
identifier.
The entry point name on the ENTRY statement can be affected by the PGMNAME
compiler option. For details, see the IBM COBOL Programming Guide for your
platform.
USING phrase
Do not specify the ENTRY statement in a program that contains a Procedure
Division ...RETURNING phrase.
For a discussion of the USING phrase, see “The Procedure Division header” on
page 204.
EVALUATE statement
The EVALUATE statement provides a shorthand notation for a series of nested IF
statements. It can evaluate multiple conditions. That is, the IF statements can be
made up of compound conditions. The subsequent action of the object program
depends on the results of these evaluations.
Format
──EVALUATE──┬─identifier-1─┬──┬─────────────────────────────┬────────────────────────────────────
├─literal-1────┤ │ ┌──
─────────────────────────┐ │
├─expression-1─┤ └──/─ ALSO──┬─identifier-2─┬─┴─┘
├─TRUE─────────┤ ├─literal-2────┤
└─FALSE────────┘ ├─expression-2─┤
├─TRUE─────────┤
└─FALSE────────┘
┌──
────────────────────────────────────────────────────────────────────────────┐
│ ┌──
────────────────────────────────────────────────┐ │
─────/─WHEN──┤ phrase 1 ├──┬────────────────────────┬─┴──imperative-statement-1─┴──────────────────
/
│ ┌──
────────────────────┐ │
└──/─ALSO──┤ phrase 2 ├─┴─┘
──┬────────────────────────────────────┬──┬──────────────┬───────────────────────────────────────
└─WHEN OTHER──imperative-statement-2─┘ └─END-EVALUATE─┘
phrase 1
├──┬─ANY────────────────────────────────────────────────────────────────────────────────┬──────────┤
├─condition-1────────────────────────────────────────────────────────────────────────┤
├─TRUE───────────────────────────────────────────────────────────────────────────────┤
├─FALSE──────────────────────────────────────────────────────────────────────────────┤
└─┬─────┬──┬─identifier-3────────────┬──┬──────────────────────────────────────────┬─┘
└─NOT─┘ ├─literal-3───────────────┤ └─┬─THROUGH─┬──┬─identifier-4────────────┬─┘
└─arithmetic-expression-1─┘ └─THRU────┘ ├─literal-4───────────────┤
└─arithmetic-expression-2─┘
phrase 2
├──┬─ANY────────────────────────────────────────────────────────────────────────────────┬──────────┤
├─condition-2────────────────────────────────────────────────────────────────────────┤
├─TRUE───────────────────────────────────────────────────────────────────────────────┤
├─FALSE──────────────────────────────────────────────────────────────────────────────┤
└─┬─────┬──┬─identifier-5────────────┬──┬──────────────────────────────────────────┬─┘
└─NOT─┘ ├─literal-5───────────────┤ └─┬─THROUGH─┬──┬─identifier-6────────────┬─┘
└─arithmetic-expression-3─┘ └─THRU────┘ ├─literal-6───────────────┤
└─arithmetic-expression-4─┘
END-EVALUATE phrase
This explicit scope terminator serves to delimit the scope of the EVALUATE
statement. END-EVALUATE permits a conditional EVALUATE statement to be
nested in another conditional statement.
For more information, see “Delimited scope statements” on page 237.
Determining values
The execution of the EVALUATE statement operates as if each selection subject
and selection object were evaluated and assigned a numeric or nonnumeric value,
a range of numeric or nonnumeric values, or a truth value. These values are
determined as follows:
Any selection subject specified by identifier-1, identifier-2, ... and any selection
object specified by identifier-3 and/or identifier-5 without the NOT or THRU
phrase, are assigned the value and class of the data item that they reference.
Any selection subject specified by literal-1, literal-2, ... and any selection object
specified by literal-3 and/or literal-5 without the NOT or THRU phrase, are
assigned the value and class of the specified literal. If literal-3 and/or literal-5
is the figurative constant ZERO, it is assigned the class of the corresponding
selection subject.
Any selection subject in which expression-1, expression-2, ... is specified as an
arithmetic expression, and any selection object without the NOT or THRU
phrase in which arithmetic-expression-1 and/or arithmetic-expression-3 is
specified, are assigned numeric values according to the rules for evaluating an
arithmetic expression. (See “Arithmetic expressions” on page 209.)
Any selection subject in which expression-1, expression-2, ... is specified as a
conditional expression, and any selection object in which condition-1 and/or
condition-2 is specified, are assigned a truth value according to the rules for
evaluating conditional expressions. (See “Conditional expressions” on
page 214.)
EXIT statement
The EXIT statement provides a common end point for a series of procedures.
Format
──paragraph-name.──EXIT.─────────────────────────────────────────────────
Format
──EXIT METHOD.───────────────────────────────────────────────────────────
You can specify EXIT METHOD only in the Procedure Division of a method. EXIT
METHOD causes the executing method to terminate, and control returns to the
invoking statement. If the containing method specifies the Procedure Division
RETURNING phrase, the value in the data item referred to by the RETURNING
phrase becomes the result of the method invocation.
If you need method-specific data to be in the last-used state on each invocation,
declare it in method Working-Storage. If you need method-specific data to be in
the initial state on each invocation, declare it in method Local-Storage.
If control reaches an EXIT METHOD statement in a method definition, control
returns to the point in the invoking program or method immediately following the
INVOKE statement. The state of the invoking program or method is identical to
that which existed at the time it executed the INVOKE statement.
The contents of data items and the contents of data files shared between the
invoking program or method and the invoked method could have changed. The
state of the invoked method is not altered except that the end of the ranges of all
PERFORM statement executed by the method are considered to have been reached.
The EXIT METHOD statement does not have to be the last statement in a sequence
of imperative statements, but the statements following the EXIT METHOD will not
be executed.
When there is no next executable statement in an invoked method, an implicit
EXIT METHOD statement is executed.
Format
──EXIT PROGRAM.──────────────────────────────────────────────────────────
GOBACK statement
The GOBACK statement functions like the EXIT PROGRAM statement when it is
coded as part of a called program (or the EXIT METHOD statement when it is
coded as part of an invoked method) and like the STOP RUN statement when
coded in a main program.
The GOBACK statement specifies the logical end of a called program or invoked
method.
Format
──GOBACK─────────────────────────────────────────────────────────────────
Termination
statement Main program Subprogram
GOBACK Return to calling program. (Can Return to calling program.
be the system and thus causes
the application to end.)
GO TO statement
The GO TO statement transfers control from one part of the Procedure Division to
another. The types of GO TO statements are:
Unconditional
Conditional
Altered
Unconditional GO TO
The unconditional GO TO statement transfers control to the first statement in the
paragraph or section named in procedure-name, unless the GO TO statement has
been modified by an ALTER statement. (See “ALTER statement” on page 258.)
Format 1—unconditional
──GO──┬────┬──procedure-name-1───────────────────────────────────────────
└─TO─┘
procedure-name-1
Must name a procedure or a section in the same Procedure Division as the GO
TO statement.
As an IBM extension, the unconditional GO TO statement does not have to be the
last statement in a sequence of imperative statements. However, any statements
following the GO TO are not executed.
When a paragraph is referred to by an ALTER statement, the paragraph must
consist of a paragraph-name followed by an unconditional or altered GO TO
statement.
Conditional GO TO
The conditional GO TO statement transfers control to one of a series of procedures,
depending on the value of the identifier.
Format 2—conditional
┌──
──────────────────┐
──GO──┬────┬───/─procedure-name-1─┴──DEPENDING──┬────┬──identifier-1──────
└─TO─┘ └─ON─┘
procedure-name-1
Must be a procedure or a section in the same Procedure Division as the GO
TO statement. The number of procedure-names must not exceed 255.
identifier-1
Must be a numeric elementary data item which is an integer. Identifier-1
cannot be a windowed date field.
If 1, control is transferred to the first statement in the procedure named by the
first occurrence of procedure-name-1.
If 2, control is transferred to the first statement in the procedure named by the
second occurrence of procedure-name-1, and so forth.
Altered GO TO
The altered GO TO statement transfers control to the first statement of the
paragraph named in the ALTER statement.
You cannot specify the altered GO TO statement in the following:
A program or method that has the RECURSIVE attribute.
A program compiled with the THREAD compiler option (Workstation only)
An ALTER statement referring to the paragraph containing an altered GO TO
statement must be executed before the GO TO statement is executed. Otherwise,
as an IBM extension, the GO TO statement acts like a CONTINUE statement.
Format 3—altered
──paragraph-name.──GO──┬────┬──.─────────────────────────────────────────
└─TO─┘
When an ALTER statement refers to a paragraph, the paragraph can consist only
of the paragraph-name followed by an unconditional or altered GO TO statement.
MORE-LABELS GO TO
Under AIX and Windows, GO TO MORE-LABELS is syntax checked,
but has no effect on the execution of the program.
The GO TO MORE-LABELS statement can only be specified in a LABEL
declarative.
Format 4—MORE-LABELS
──GO──┬────┬──MORE-LABELS────────────────────────────────────────────────
└─TO─┘
For more details, see the IBM COBOL for OS/390 & VM Programming Guide.
IF statement
The IF statement evaluates a condition and provides for alternative actions in the
object program, depending on the evaluation.
Format
┌──
─────────────┐
──IF──condition-1──┬──────┬──┬──/─statement-1─┴─┬──────────────────────────
└─THEN─┘ └─NEXT SENTENCE───┘
──┬───────────────────────────┬──┬──────────┬─────────────────────────────
│ ┌──
─────────────┐ │ └─END-IF───(1) ┘
└─ELSE──┬──/─statement-2─┴─┬─┘
└─NEXT SENTENCE───┘
Note:
1 END-IF can be specified with NEXT SENTENCE as an IBM extension.
condition
Can be any simple or complex condition, as described in “Conditional
expressions” on page 214.
statement-1, statement-2
Can be any one of the following:
An imperative statement
A conditional statement
An imperative statement followed by a conditional statement
NEXT SENTENCE
If the NEXT SENTENCE phrase is specified, then the END-IF phrase must not
be specified.
END-IF can be specified with NEXT SENTENCE. However, if the NEXT
SENTENCE phrase is executed, control will not pass to the next statement
following the END-IF but instead will pass to the statement after the closest
following period.
END-IF phrase
This explicit scope terminator serves to delimit the scope of the IF statement.
END-IF permits a conditional IF statement to be nested in another conditional
statement. For more information on explicit scope terminators, see “Delimited
scope statements” on page 237.
The scope of an IF statement can be terminated by any of the following:
An END-IF phrase at the same level of nesting
A separator period
If nested, by an ELSE phrase associated with an IF statement at a higher level
of nesting
Transferring control
If the condition tested is true, one of the following actions takes place:
If statement-1 is specified, it is executed. If statement-1 contains a procedure
branching or conditional statement, control is transferred, according to the
rules for that statement. If statement-1 does not contain a procedure-branching
Note: When the ELSE phrase is omitted, all statements following the condition
and preceding the corresponding END-IF or the separator period for the sentence
are considered to be part of statement-1.
Nested IF statements
When an IF statement appears as statement-1 or statement-2, or as part of
statement-1 or statement-2, it is nested.
Nested IF statements (when IF statements contain IF statements) are considered to
be matched IF, ELSE, and END-IF combinations proceeding from left to right.
Thus, any ELSE encountered is matched with the nearest preceding IF that either
has not been already matched with an ELSE, or has not been implicitly or
explicitly terminated. Any END-IF encountered is matched with the nearest
preceding IF that has not been implicitly or explicitly terminated.
INITIALIZE statement
The INITIALIZE statement sets selected categories of data fields to predetermined
values. It is functionally equivalent to one or more MOVE statements.
When the REPLACING phrase is not used:
SPACE is the implied sending field for alphabetic, alphanumeric,
alphanumeric-edited, and DBCS items.
ZERO is the implied sending field for numeric and numeric-edited items.
Format
┌──
──────────────┐
──INITIALIZE───/─identifier-1─┴──────────────────────────────────────────────────────
──┬────────────────────────────────────────────────────────────────────────┬────────
│ ┌──
─────────────────────────────────────────────────────────┐ │
└─REPLACING───/─┬─ALPHABETIC──────────┬──┬──────┬──BY──┬─identifier-2─┬─┴─┘
├─ALPHANUMERIC────────┤ └─DATA─┘ └─literal-1────┘
├─NUMERIC─────────────┤
├─ALPHANUMERIC-EDITED─┤
├─NUMERIC-EDITED──────┤
├─DBCS────────────────┤
└─EGCS────────────────┘
identifier-1
Receiving area(s).
identifier-2, literal-1
Sending area(s).
A subscripted item can be specified for identifier-1. A complete table can be
initialized only by specifying identifier-1 as a group that contains the complete
table.
The data description entry for identifier-1 or any items subordinate to identifier-1
cannot contain the DEPENDING ON phrase of the OCCURS clause. The data
description entry for identifier-1 can contain the DEPENDING phrase of the
OCCURS clause.
Note: You cannot use the INITIALIZE statement to initialize a variably located
item or group that follows a DEPENDING ON phrase of the OCCURS clause
within the same 01 level.
A floating-point data item or literal can be used anywhere a numeric identifier or
literal is specified.
A DBCS data item or literal can be used anywhere an identifier or literal is
specified.
The data description entry for identifier-1 must not contain a RENAMES clause.
An index data item cannot be an operand of INITIALIZE.
Special registers can be specified for identifier-1 and identifier-2 only if they are
valid receiving fields or sending fields, respectively, for the implied MOVE
statement(s).
INSPECT statement
The INSPECT statement specifies that characters, or groups of characters, in a data
item are to be counted (tallied) or replaced or both.
It counts the occurrence of a specific character (alphabetic, numeric, or special
character) in a data item (formats 1 and 3).
It fills all or portions of a data item with specified characters, such as spaces or
zeros (formats 2 and 3).
It converts all occurrences of specific characters in a data item to user-supplied
replacement characters (format 4).
Format 1
──INSPECT──identifier-1──TALLYING────────────────────────────────────────────────────────────────
┌──
────────────────────────────────────────────────────────────────────────────────────┐
│ ┌──
─────────────────────────────────────────────────────────────┐ │
│ │ ┌──
──────────────────┐ │ │
───/─identifier-2──FOR───/─┬─CHARACTERS───/─┬──────────────┬─┴────────────────────────┬─┴─┴─────────
│ └─┤ phrase 1 ├─┘ │
│ ┌──
────────────────────────────────────────┐ │
│ │ ┌──
──────────────────┐ │ │
└─┬─ALL─────┬───/─┬─identifier-3─┬───/─┬──────────────┬─┴─┴─┘
└─LEADING─┘ └─literal-1────┘ └─┤ phrase 1 ├─┘
phrase 1
├──┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬───────────────────────────────────────────────────────┤
└─AFTER──┘ └─INITIAL─┘ └─literal-2────┘
Format 2
──INSPECT──identifier-1──REPLACING───────────────────────────────────────────────────────────────
┌──
───────────────────────────────────────────────────────────────────────────────────┐
│ ┌──
──────────────────┐ │
────┬─CHARACTERS BY──┬─identifier-5─┬───/─┬──────────────┬─┴─────────────────────────┬─┴──────────
/
│ └─literal-3────┘ └─┤ phrase 1 ├─┘ │
│ ┌──
──────────────────────────────────────────────────────────────┐ │
│ │ ┌──
──────────────────┐ │ │
└─┬─ALL─────┬───/─┬─identifier-3─┬──BY──┬─identifier-5─┬───/─┬──────────────┬─┴─┴─┘
├─LEADING─┤ └─literal-1────┘ └─literal-3────┘ └─┤ phrase 1 ├─┘
└─FIRST───┘
phrase 1
├──┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬───────────────────────────────────────────────────────┤
└─AFTER──┘ └─INITIAL─┘ └─literal-2────┘
Format 4
──INSPECT──identifier-1──CONVERTING──┬─identifier-6─┬──TO──┬─identifier-7─┬──────────────────────
└─literal-4────┘ └─literal-5────┘
┌──
───────────────────────────────────────────┐
───/─┬─BEFORE─┬──┬─────────┬──┬─identifier-4─┬─┴──────────────────────────────────────────────────
└─AFTER──┘ └─INITIAL─┘ └─literal-2────┘
Effect of DBCS
All identifiers and literals (except identifier-2) must be DBCS items, either DBCS
literals or DBCS data items, if any are DBCS items. Identifier-2 cannot be a DBCS
item. DBCS characters, not bytes of data, are tallied in identifier-2.
Replacement rules
The following replacement rules apply:
When the subject field is a figurative constant, the single-character substitution
field (which must be 1 character in length) replaces each character in the
inspected item equivalent to the figurative constant.
When the substitution field is a figurative constant, the substitution field
replaces each non-overlapping occurrence of the subject field in the inspected
item.
When the subject and substitution fields are character-strings, the
character-string specified in the substitution field replaces each
non-overlapping occurrence of the subject field in the inspected item.
After replacement has occurred in a given character position in the inspected
item, no further replacement for that character position is made in this
execution of the INSPECT statement.
Data flow
Except when the BEFORE or AFTER phrase is specified, inspection begins at the
leftmost character position of the inspected item (identifier-1) and proceeds
character-by-character to the rightmost position.
The comparands of the following phrases are compared in the left-to-right order in
which they are specified in the INSPECT statement:
TALLYING (literal-1 or identifier-3, ... )
REPLACING (literal-3 or identifier-5, ... )
If any identifier is subscripted, reference modified, or is a function-identifier, the
subscript, reference-modifier, or function is evaluated only once as the first
operation in the execution of the INSPECT statement.
For examples of TALLYING and REPLACING, see the IBM COBOL Programming
Guide for your platform.
Comparison cycle
The comparison cycle consists of the following actions:
1. The first comparand is compared with an equal number of leftmost contiguous
characters in the inspected item. The comparand matches the inspected
characters only if both are equal, character-for-character.
If the CHARACTERS phrase is specified, an implied 1-character comparand is
used. The implied character is always considered to match the inspected
character in the inspected item.
2. If no match occurs for the first comparand and there are more comparands, the
comparison is repeated for each successive comparand until either a match is
found or all comparands have been acted upon.
3. Depending on whether a match is found, these actions are taken:
INVOKE statement
The INVOKE statement invokes a method defined in a class or a metaclass.
Methods can contain INVOKE statements, and a method can execute an INVOKE
statement that directly or indirectly invokes itself. Therefore, all methods are
implicitly recursive (unlike COBOL programs, which support recursion only if the
RECURSIVE attribute is specified in the PROGRAM-ID paragraph.)
The process for resolving the method name specified on the INVOKE statement to
a method implementation is as specified by the IBM SOM. The method resolution
is not case sensitive.
Format
──INVOKE──┬─identifier-1───────────────┬──┬─literal-1────┬───────────────────────────────────────
├─class-name-1───────────────┤ └─identifier-2─┘
├─SELF───────────────────────┤
└─┬─────────────────┬──SUPER─┘
└─class-name-2 OF─┘
──┬────────────────────────────────────────────────────────────────────────────┬──────────────────
│ ┌──
─────────────────────────────────────────────────────────────────┐ │
│ │ ┌──
──────────────────────────────────┐ │ │
└─USING───/─┬─┬───────────────────┬───/─┬─┬────────────┬──identifier-3─┬─┴─┬─┴─┘
│ └─┬────┬──REFERENCE─┘ │ └─ADDRESS OF─┘ │ │
│ └─BY─┘ └─OMITTED──────────────────────┘ │
│ ┌──
──────────────────────────────────┐ │
├─┬────┬──CONTENT───/─┬─┬────────────┬──identifier-4─┬─┴───────┤
│ └─BY─┘ │ ├─ADDRESS OF─┤ │ │
│ │ └─LENGTH OF──┘ │ │
│ ├─literal-2────────────────────┤ │
│ └─OMITTED──────────────────────┘ │
│ ┌──
──────────────────────────────────┐ │
└─┬────┬──VALUE───/─┬─┬────────────┬──identifier-5─┬─┴─────────┘
└─BY─┘ │ ├─ADDRESS OF─┤ │
│ └─LENGTH OF──┘ │
└─literal-3────────────────────┘
──┬───────────────────────────┬──┬─────────────────────────────────────────────┬──────────────────
└──RETURNING──identifier-6──┘ └──┬────┬──EXCEPTION──imperative-statement-1──┘
└─ON─┘
──┬──────────────────────────────────────────────────┬──┬────────────┬───────────────────────────
└──NOT──┬────┬──EXCEPTION──imperative-statement-2──┘ └─END-INVOKE─┘
└─ON─┘
identifier-1
Must be defined as USAGE OBJECT REFERENCE. The contents of identifier-1
specify the object on which a method is invoked.
The results of the INVOKE statement are undefined if:
identifier-1 does not contain a valid reference to an object or
identifier-1 contains NULL
class-name-1
If class-name-1 is specified, the method is invoked on the class object of
class-name-1.
You must specify class-name-1 in the REPOSITORY paragraph of the
Configuration Section of the class or program that contains the INVOKE
statement.
SELF
An implicit reference to the object upon which the currently executing method
was invoked. When SELF is specified, the INVOKE statement must appear
within the Procedure Division of a method.
USING phrase
The USING phrase specifies arguments that are passed to the target method. For
details on the USING phrase, see “The Procedure Division header” on page 204.
For conformance requirements for the USING phrase, see “Conformance
requirements for USING phrase” on page 310.
BY REFERENCE phrase
If the BY REFERENCE phrase is either specified or implied for a parameter, the
corresponding data item in the invoking method occupies the same storage area as
the data item in the invoked method.
identifier-3
Can be a data item of any level in the DATA DIVISION. Identifier-3 cannot be
a function-identifier.
If defined in the Linkage Section, you must have already provided
addressability for identifier-3 prior to execution of the INVOKE statement.
You can do this by coding either one of the following: SET ADDRESS OF
identifier-3 TO pointer or PROCEDURE/ENTRY USING.
ADDRESS OF special register
See “ADDRESS OF” on page 9.
BY CONTENT phrase
If the BY CONTENT phrase is specified or implied for a parameter, the invoked
method cannot change the value of this parameter as referenced in the INVOKE
statement's USING phrase. Although, the invoked method can change the value of
the data item referenced by the corresponding data-name in the invoked method's
Procedure Division header. Changes to the parameter in the invoked method do
not affect the corresponding argument in the invoking program.
identifier-4
Can be a data item of any level in the Data Division. Identifier-4 cannot be a
function-identifier.
If defined in the Linkage Section, you must have already provided
addressability for identifier-4 prior to execution of the INVOKE statement.
You can do this by coding either one of the following: SET ADDRESS OF
identifier-4 TO pointer or PROCEDURE/ENTRY USING.
literal-2
Can be:
A nonnumeric literal
A figurative constant (except ALL literal or NULL/NULLS)
A DBCS literal
ADDRESS OF special register
See “ADDRESS OF” on page 9.
LENGTH OF special register
See “LENGTH OF” on page 11.
OMITTED
Indicates that no argument is passed.
BY VALUE phrase
The BY VALUE phrase applies to all arguments that follow until overridden by
another BY REFERENCE or BY CONTENT phrase.
If the BY VALUE phrase is specified or implied for an argument, the value of the
argument is passed, not a reference to the sending data item. The invoked method
can modify the formal parameter corresponding to the BY VALUE argument, but
any changes do not affect the argument since the invoked method has access to a
temporary copy of the sending data item.
While BY VALUE arguments are primarily intended for communication with
non-COBOL programs (such as C), they can also be used for COBOL-to-COBOL
invocations. In this case, BY VALUE must be specified or implied for both the
argument in the INVOKE USING phrase and the corresponding formal parameter
in the Procedure Division USING phrase.
identifier-5
Must be an elementary data item in the DATA DIVISION. Identifier-5 must be
one of the following:
RETURNING phrase
You can specify the RETURNING phrase for invoking methods written in COBOL,
C, or in other programming languages that use C linkage conventions.
identifier-6
The RETURNING data item. Identifier-6:
Must be defined in the DATA DIVISION
Must not be reference-modified
Is not changed if an EXCEPTION occurs
Contains the return value of the invoked method
If identifier-6 is specified and the target method is written in COBOL, then the
target method must have a RETURNING phrase on its Procedure Division
statement. When the target returns, its return value is assigned to identifier-6,
using the rules for the SET statement if identifier-6 is USAGE IS INDEX,
USAGE IS POINTER, USAGE IS PROCEDURE-POINTER, or USAGE IS
OBJECT REFERENCE; otherwise, the rules for the MOVE statement are used.
ON EXCEPTION phrase
An exception condition occurs when invoked methods are not supported by the
method identified by literal-1 or identifier-2. When an exception condition occurs,
one of the following two actions occur:
1. If the ON EXCEPTION phrase is specified, control is transferred to
imperative-statement-1.
2. If the ON EXCEPTION phrase is not specified, then a condition is raised at
run time.
Exceptions can occur if conformance requirements are not met. Conformance
requirements include:
For the USING phrase, see “Conformance requirements for USING phrase” on
page 310
For the RETURNING phrase, see “Conformance requirements for
RETURNING phrase” on page 311
For the purpose of conformance checking, a fixed-length group data item is
considered to be equivalent to an elementary alphanumeric data item of the
same length.
A variable-length group conforms only to other variable-length groups that
have the same maximum length.
For an example, see “INVOKE parameter type conformance—example” on
page 313.
END-INVOKE phrase
This explicit scope terminator serves to delimit the scope of the INVOKE
statement. END-INVOKE permits a conditional INVOKE statement to be nested in
another conditional statement.
WORKING-STORAGE SECTION.
?1 anA USAGE OBJECT REFERENCE A.
?1 aB USAGE OBJECT REFERENCE B.
?1 aC USAGE OBJECT REFERENCE C.
..
.
PROCEDURE DIVISION
INVOKE anX "METHOD-1" USING BY REFERENCE anA.
BY VALUE aB.
RETURNING aC.
CLASS-ID. X.
..
.
METHOD-ID. METHOD-1.
..
.
LINKAGE SECTION.
?1 aP USAGE OBJECT REFERENCE P.
?1 aQ USAGE OBJECT REFERENCE Q.
?1 anR USAGE OBJECT REFERENCE R.
..
.
PROCEDURE DIVISION USING BY REFERENCE aP
BY VALUE aQ
RETURNING anR.
MERGE statement
The MERGE statement combines two or more identically sequenced files (that is,
files that have already been sorted according to an identical set of
ascending/descending keys) on one or more keys and makes records available in
merged order to an output procedure or output file.
A MERGE statement can appear anywhere in the Procedure Division except in a
Declarative Section.
| The MERGE statement is not supported under OS/390 Unix.
Format
┌──
──────────────────────────────────────────────────┐
│ ┌──
─────────────┐ │
──MERGE──file-name-1───/─┬────┬──┬─ASCENDING──┬──┬─────┬───/─data-name-1─┴─┴───────────────────────
└─ON─┘ └─DESCENDING─┘ └─KEY─┘
┌──
─────────────┐
──┬──────────────────────────────────────────────────┬──USING──file-name-2───/─file-name-3─┴───────
└─┬───────────┬──SEQUENCE──┬────┬──alphabet-name-1─┘
└─COLLATING─┘ └─IS─┘
──┬─OUTPUT PROCEDURE──┬────┬──procedure-name-1──┬───────────────────────────────┬─┬──────────────
│ └─IS─┘ └─┬─THROUGH─┬──procedure-name-2─┘ │
│ └─THRU────┘ │
│ ┌──
─────────────┐ │
/
└─GIVING────file-name-4─┴───────────────────────────────────────────────────────┘
file-name-1
The name given in the SD entry that describes the records to be merged.
No file-name can be repeated in the MERGE statement.
No pair of file-names in a MERGE statement can be specified in the same
SAME AREA, SAME SORT AREA, or SAME SORT-MERGE AREA clause.
As an IBM extension, any file-names in a MERGE statement can be specified in
the same SAME RECORD AREA clause.
When the MERGE statement is executed, all records contained in file-name-2,
file-name-3,..., are accepted by the merge program and then merged according to
the key(s) specified.
USING phrase
file-name-2, file-name-3, ...
Specifies the input files.
During the MERGE operation, all the records on file-name-2, file-name-3, ... (that
is, the input files) are transferred to file-name-1. At the time the MERGE statement
is executed, these files must not be open. The input files are automatically opened,
read, and closed, and if DECLARATIVE procedures are specified for these files for
input operations, the files will be driven for errors if errors occur.
All input files must specify sequential or dynamic access mode and be described in
FD entries in the Data Division.
If file-name-1 contains variable-length records, the size of the records contained in
the input files (file-name-2, file-name-3, ...) must not be less than the smallest
record nor greater than the largest record described for file-name-1. If file-name-1
GIVING phrase
file-name-4, ...
Specifies the output files.
When the GIVING phrase is specified, all the merged records in file-name-1 are
automatically transferred to the output files (file-name-4...).
All output files must specify sequential or dynamic access mode and be described
in FD entries in the DATA DIVISION.
If the output files (file-name-4,...) contain variable-length records, the size of the
records contained in file-name-1 must not be less than the smallest record nor
greater than the largest record described for the output files. If the output files
contain fixed-length records, the size of the records contained in file-name-1 must
not be greater than the largest record described for the output files. For more
information, see the IBM COBOL Programming Guide for your platform.
At the time the MERGE statement is executed, the output files (file-name-4,...) must
not be open. The output files are automatically opened, read, and closed, and if
DECLARATIVE procedures are specified for these files for output operations, the
files will be driven for errors if errors occur.
Segmentation considerations
If the MERGE statement appears in a section that is not in an independent
segment, then any output procedure referenced by that MERGE statement must
appear:
1. Totally within non-independent segments, or
2. Wholly contained in a single independent segment.
If a MERGE statement appears in an independent segment, then any output
procedure referenced by that MERGE statement must be contained:
1. Totally within non-independent segments, or
2. Wholly within the same independent segment as that MERGE statement.
MOVE statement
The MOVE statement transfers data from one area of storage to one or more other
areas.
Format 1
┌──
──────────────┐
──MOVE──┬─identifier-1─┬──TO───/─identifier-2─┴───────────────────────────
└─literal-1────┘
Format 2
──MOVE──┬─CORRESPONDING─┬──identifier-1──TO──identifier-2────────────────
└─CORR──────────┘
identifier-1, literal-1
Sending area
identifier-2
Receiving area(s)
When format 1 is specified, all identifiers can be either group or elementary items.
The data in the sending area is moved into the data item referenced by each
identifier-2 in the order in which it is specified. See “Elementary moves” on
page 321 and “Group moves” on page 324.
When format 2 is specified, both identifiers must be group items. CORR is an
abbreviation for, and is equivalent to, CORRESPONDING.
When CORRESPONDING is specified, selected items in identifier-1 are moved to
identifier-2, according to the rules for the CORRESPONDING phrase on on page
238. The results are the same as if each pair of CORRESPONDING identifiers
were referenced in a separate MOVE statement.
Do not specify a data item defined with USAGE IS POINTER, USAGE IS
PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE in a MOVE
statement.
A data item defined with USAGE IS POINTER, USAGE IS
PROCEDURE-POINTER, or USAGE IS OBJECT REFERENCE can be part of a
group that is referred to in a MOVE CORRESPONDING statement; however, no
movement of the data item will take place.
An index data item cannot be specified in a MOVE statement.
The evaluation of the length of the sending or receiving area can be affected by the
DEPENDING ON phrase of the OCCURS clause (see “OCCURS clause” on
page 154).
If the sending field (identifier-1) is reference-modified, subscripted, or is an
alphanumeric or alphabetic function-identifier, the reference-modifier, subscript, or
function is evaluated only once, immediately before data is moved to the first of
the receiving operands.
Any length evaluation, subscripting, or reference-modification associated with a
receiving field (identifier-2) is evaluated immediately before the data is moved into
that receiving field.
For example, the result of the statement:
Elementary moves
An elementary move is one in which the receiving item is an elementary item, and
the sending item is an elementary item or a literal. Any necessary conversion of
data from one form of internal representation to another takes place during the
move, along with any specified editing in, or de-editing implied by, the receiving
item. Each elementary item belongs to one of the following categories:
Alphabetic—includes alphabetic data items and the figurative constant SPACE.
Alphanumeric—includes alphanumeric data items, nonnumeric literals, and all
figurative constants except SPACE and ZERO (when ZERO is moved to a
numeric or numeric-edited item).
Alphanumeric-edited—includes alphanumeric-edited data items.
Numeric—includes numeric data items, numeric literals, and the figurative
constant ZERO (when ZERO is moved to a numeric or numeric-edited item).
Numeric-edited—includes numeric-edited data items.
Floating-point—includes internal floating-point items (defined as USAGE
COMP-1 or USAGE COMP-2), external floating-point items (defined as USAGE
DISPLAY), and floating-point literals.
DBCS—includes DBCS data items (defined explicitly or implicitly as USAGE
DISPLAY-1) and DBCS literals.
The following rules outline the execution of valid elementary moves. When the
receiving field is:
Alphabetic:
Alignment and any necessary space filling occur as described under
“Alignment rules” on page 128.
If the size of the sending item is greater than the size of the receiving item,
excess characters on the right are truncated after the receiving item is filled.
Alphanumeric or Alphanumeric-Edited:
Alignment and any necessary space filling take place, as described under
“Alignment rules” on page 128.
If the size of the sending item is greater than the size of the receiving item,
excess characters on the right are truncated after the receiving item is filled.
Group moves
A group move is one in which one or both of the sending and receiving fields are
group items. A group move is treated exactly as though it were an alphanumeric
elementary move, except that there is no conversion of data from one form of
internal representation to another. In a group move, the receiving area is filled
without consideration for the individual elementary items contained within either
the sending area or the receiving area, except as noted in the OCCURS clause.
(See “OCCURS clause” on page 154.) All group moves are valid.
MULTIPLY statement
The MULTIPLY statement multiplies numeric items and sets the values of data
items equal to the results.
Format 1
┌──
───────────────────────────┐
──MULTIPLY──┬─identifier-1─┬──BY───/─identifier-2──┬─────────┬─┴───────────
└─literal-1────┘ └─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬──────────────┬───
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-MULTIPLY─┘
└─ON─┘
Format 2
──MULTIPLY──┬─identifier-1─┬──BY──┬─identifier-2─┬────────────────────────
└─literal-1────┘ └─literal-2────┘
┌──
───────────────────────────┐
──GIVING───/─identifier-3──┬─────────┬─┴────────────────────────────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬──────────────┬───
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-MULTIPLY─┘
└─ON─┘
ROUNDED phrase
For formats 1 and 2, see “ROUNDED phrase” on page 239.
END-MULTIPLY phrase
This explicit scope terminator serves to delimit the scope of the MULTIPLY
statement. END-MULTIPLY permits a conditional MULTIPLY statement to be
nested in another conditional statement. END-MULTIPLY can also be used with
an imperative MULTIPLY statement.
For more information, see “Delimited scope statements” on page 237.
OPEN statement
The OPEN statement initiates the processing of files. It also checks and/or writes
labels.
valid for VSAM files. Under AIX and Windows, the REVERSED and
WITH NO REWIND phrases are syntax checked, but have no effect on the
execution of the program.
At least one of the phrases, INPUT, OUTPUT, I-O, or EXTEND, must be specified
with the OPEN key word. The INPUT, OUTPUT, I-O, and EXTEND phrases can
appear in any order.
INPUT
Permits opening the file for input operations.
OUTPUT
Permits opening the file for output operations. This phrase can be specified
when the file is being created.
General rules
If a file opened with the INPUT phrase is an optional file which is not present,
the OPEN statement sets the file position indicator to indicate that an optional
input file is not present.
Execution of an OPEN INPUT or OPEN I-O statement sets the file position
indicator:
Label records
Under AIX and Windows, label processing is not supported. A
warning message is issued if any of the following language elements are
encountered:
LABEL RECORDS IS data-name
USE...AFTER...LABEL PROCEDURE
GO TO MORE-LABELS
If label records are specified for the file when the OPEN statement is executed, the
labels are processed according to the standard label conventions, as follows:
INPUT files The beginning labels are checked.
OUTPUT files The beginning labels are written.
I-O files The labels are checked; new labels are then written.
EXTEND files The following procedures are executed:
Beginning file labels are processed only if this is a
single-volume file.
When label records are specified but not present, or are present but not specified,
execution of the OPEN statement is unpredictable.
2. The successful execution of the OPEN statement makes the associated record
area available to the program; it does not obtain or release the first data
record.
3. An OPEN statement must be successfully executed prior to the execution of
any of the permissible input-output statements, except a SORT or MERGE
statement with the USING or GIVING phrase. Table 44 shows the permissible
input-output statements for sequential files. An 'X' indicates that the
specified statement can be used with the open mode given at the top of the
column.
4. A file can be opened for INPUT, OUTPUT, I-O, or EXTEND (sequential and
line-sequential files only) in the same program. After the first OPEN statement
execution for a given file, each subsequent OPEN statement execution must be
preceded by a successful CLOSE file statement execution without the REEL or
UNIT phrase (for QSAM files only), or the LOCK phrase.
5. If the FILE STATUS clause is specified in the FILE-CONTROL entry, the
associated status key is updated when the OPEN statement is executed.
6. If an OPEN statement is issued for a file already in the open status, the
EXCEPTION/ERROR procedure (if specified) for this file is executed.
PERFORM statement
The PERFORM statement transfers control explicitly to one or more procedures
and implicitly returns control to the next executable statement after execution of
the specified procedure(s) is completed.
The PERFORM statement can be:
An out-of-line PERFORM statement
Procedure-name-1 is specified.
An in-line PERFORM statement
Procedure-name-1 is omitted.
An in-line PERFORM must be delimited by the END-PERFORM phrase.
The in-line and out-of-line formats cannot be combined. For example, if
procedure-name-1 is specified, the imperative-statement and the
END-PERFORM phrase must not be specified.
The PERFORM statement formats are:
Basic PERFORM
TIMES phrase PERFORM
UNTIL phrase PERFORM
VARYING phrase PERFORM
Format 1
──PERFORM──┬─procedure-name-1──┬───────────────────────────────┬─┬───────
│ └─┬─THROUGH─┬──procedure-name-2─┘ │
│ └─THRU────┘ │
(1) ─END-PERFORM───────────────┘
└─imperative-statement-1───
Note:
1 Imperative-statement-1 is optional as an IBM extension.
procedure-name-1, procedure-name-2
Must name a section or paragraph in the Procedure Division.
When both procedure-name-1 and procedure-name-2 are specified, if either is a
procedure-name in a declarative procedure, both must be procedure-names in
the same declarative procedure.
If procedure-name-1 is specified, imperative-statement-1 and the
END-PERFORM phrase must not be specified.
If procedure-name-1 is omitted, imperative-statement and the END-PERFORM
phrase must be specified.
END-PERFORM
Delimits the scope of the in-line PERFORM statement. Execution of an in-line
PERFORM is completed after the last statement contained within it has been
executed.
Format 4
──PERFORM──┬─procedure-name-1──┬───────────────────────────────┬──┤ phrase 1 ├──┤ phrase 2 ├─┬──
│ └─┬─THROUGH─┬──procedure-name-2─┘ │
│ └─THRU────┘ │
(1) ─END-PERFORM─────────────────────────────┘
└─┤ phrase 1 ├──imperative-statement-1───
phrase 1
├──┬────────────────────────────┬──VARYING──┬─identifier-2─┬──FROM──┬─identifier-3─┬──BY───────────
└─┬──────┬──TEST──┬─BEFORE─┬─┘ └─index-name-1─┘ ├─index-name-2─┤
└─WITH─┘ └─AFTER──┘ └─literal-1────┘
──┬─identifier-4─┬──UNTIL──condition-1────────────────────────────────────────────────────────────┤
└─literal-2────┘
phrase 2
├──┬─────────────────────────────────────────────────────────────────────────────────────────┬─────┤
│ ┌──
─────────────────────────────────────────────────────────────────────────────────────┐ │
└──/─AFTER──┬─identifier-5─┬──FROM──┬─identifier-6─┬──BY──┬─identifier-7─┬──┤ phrase 3 ├─┴─┘
└─index-name-3─┘ ├─index-name-4─┤ └─literal-4────┘
└─literal-3────┘
phrase 3
├──UNTIL──condition-2──────────────────────────────────────────────────────────────────────────────┤
Note:
1 Imperative-statement-1 is optional as an IBM extension.
Figure 15 on page 340 illustrates the logic of the PERFORM statement when two
identifiers are varied with TEST AFTER.
The actions are the same as those for two identifiers, except that identifier-8 goes
through the complete cycle each time identifier-5 is augmented by identifier-7,
which, in turn, goes through a complete cycle each time identifier-2 is varied.
At the end of PERFORM statement execution:
identifier-5 and identifier-8
Contain the current values of identifier-6 and identifier-9, respectively.
identifier-2
Has a value exceeding its last-used setting by one increment/decrement value
(unless condition-1 was true at the beginning of PERFORM statement
execution, in which case, identifier-2 contains the current value of identifier-3).
READ statement
For sequential access, the READ statement makes the next logical record from a
file available to the object program. For random access, the READ statement
makes a specified record from a direct-access file available to the object program.
When the READ statement is executed, the associated file must be open in INPUT
or I-O mode.
file-name-1
Must be defined in a Data Division FD entry.
NEXT RECORD
Reads the next record in the logical sequence of records. NEXT is optional
when ACCESS MODE IS SEQUENTIAL; it has no effect on READ statement
execution.
Under OS/390 and VM, you must specify the NEXT RECORD
phrase for files in dynamic access mode, which are retrieved sequentially.
Under AIX and Windows, you must specify either the NEXT or
PREVIOUS phrase for files in dynamic access mode, which are retrieved
sequentially.
PREVIOUS RECORD (workstation only)
Reads the previous record in the logical sequence of records.
PREVIOUS applies to indexed and relative files with DYNAMIC access mode.
You must specify either the NEXT or PREVIOUS phrase for files in dynamic
access mode, which are retrieved sequentially.
KEY IS phrase
The KEY IS phrase can be specified only for indexed files. Data-name-1 must
identify a record key associated with file-name-1. Data-name-1 can be qualified; it
cannot be subscripted.
Data-name-1 (the record key) can be defined as a DBCS data item.
When the RECORD KEY clause specifies a DBCS data item, a KEY specified on the
READ statement must be a DBCS data item.
AT END phrases
For sequential access, the AT END phrase must be specified if no applicable USE
AFTER STANDARD EXCEPTION procedure is specified for file-name-1.
The AT END phrase does not have to be specified if no applicable USE AFTER
STANDARD EXCEPTION procedure is specified for file-name-1.
For information on at-end condition processing, see “AT END condition” on
page 345.
END-READ phrase
This explicit scope terminator serves to delimit the scope of the READ statement.
END-READ permits a conditional READ statement to be nested in another
conditional statement. END-READ can also be used with an imperative READ
statement. For more information, see “Delimited scope statements” on page 237.
Sequential files
The NEXT RECORD is the next record in a logical sequence of records. The NEXT
phrase need not be specified; it has no effect on READ statement execution.
If SELECT OPTIONAL is specified in the FILE-CONTROL entry for this file, and
the file is absent during this execution of the object program, execution of the first
READ statement causes an at end condition; however, since no file is present, the
system-defined end-of-file processing is not performed.
AT END condition: If the file position indicator indicates that no next logical
record exists, or that an optional input file is not present, the following occurs in
the order specified:
1. A value, derived from the setting of the file position indicator, is placed into
the I-O status associated with file-name-1 to indicate the at end condition.
2. If the AT END phrase is specified in the statement causing the condition,
control is transferred to imperative-statement-1 in the AT END phrase. Any
USE AFTER STANDARD EXCEPTION procedure associated with file-name-1
is not executed.
AT END condition: If the file position indicator indicates that no next logical
record exists, (or alternatively for AIX and Windows, no previous record exists), or
that an optional input file is not present.
Under OS/390 and VM, the same procedure occurs as for sequential
files (see “AT END condition” on page 345).
Sequentially accessed relative files: If the RELATIVE KEY clause is specified for
this file, READ statement execution updates the RELATIVE KEY data item to
indicate the relative record number of the record being made available.
Indexed files
Execution of a format 2 READ statement causes the value of the key of reference to
be compared with the value of the corresponding key data item in the file records,
until the first record having an equal value is found. The file position indicator is
positioned to this record, which is then made available. If no record can be so
identified, an INVALID KEY condition exists, and READ statement execution is
unsuccessful. (See “Invalid key condition” under “Common processing facilities”
on page 244.)
Relative files
Execution of a format 2 READ statement sets the file position indicator pointer to
the record whose relative record number is contained in the RELATIVE KEY data
item, and makes that record available.
If the file does not contain such a record, the INVALID KEY condition exists, and
READ statement execution is unsuccessful. (See “Invalid key condition” under
“Common processing facilities” on page 244.)
The KEY phrase must not be specified for relative files.
RELEASE statement
The RELEASE statement transfers records from an input/output area to the initial
phase of a sorting operation.
The RELEASE statement can only be used within the range of an INPUT
PROCEDURE associated with a SORT statement.
Format
──RELEASE──record-name-1──┬────────────────────┬─────────────────────────
└─FROM──identifier-1─┘
The MOVE is performed according to the rules for the MOVE statement
without the CORRESPONDING phrase.
identifier-1
Identifier-1 must be one of the following:
The name of an entry in the Working-Storage Section or the Linkage
Section
The name of a record description for another previously opened file
The name of an alphanumeric function identifier
Identifier-1 and record-name-1 must not refer to the same storage area.
Identifier-1 can be a floating-point data item or a DBCS data item.
After the RELEASE statement is executed, the information is still available in
identifier-1. (See “INTO/FROM Identifier Phrase” under “Common processing
facilities” on page 244.)
If the RELEASE statement is executed without specifying the SD entry for
file-name-1 in a SAME RECORD AREA clause, the information in record-name-1 is
no longer available.
If the SD entry is specified in a SAME RECORD AREA clause, record-name-1 is
still available as a record of the other files named in that clause.
RETURN statement
The RETURN statement transfers records from the final phase of a sorting or
merging operation to an OUTPUT PROCEDURE.
The RETURN statement can be used only within the range of an OUTPUT
PROCEDURE associated with a SORT or MERGE statement.
Format
──RETURN──file-name-1──┬────────┬──┬────────────────────┬─────────────────
└─RECORD─┘ └─INTO──identifier-1─┘
──┬─────────────────────────────────────┬──────────────────────────────────
| └─┬────┬──END──imperative-statement-1─┘
| └─AT─┘
──┬──────────────────────────────────────────┬──┬────────────┬────────────
└─NOT──┬────┬──END──imperative-statement-2─┘ └─END-RETURN─┘
└─AT─┘
The record areas associated with file-name-1 and identifier-1 must not be the same
storage area.
The INTO phrase can be specified in a RETURN statement if one or both of the
following are true:
If only one record description is subordinate to the sort-merge file description
entry
AT END phrases
The imperative-statement specified on the AT END phrase executes after all
records have been returned from file-name-1. No more RETURN statements can
be executed as part of the current output procedure.
If an at end condition does not occur during the execution of a RETURN
statement, then after the record is made available and after executing any implicit
move resulting from the presence of an INTO phrase, control is transferred to the
imperative statement specified by the NOT AT END phrase, otherwise control is
passed to the end of the RETURN statement.
END-RETURN phrase
This explicit scope terminator serves to delimit the scope of the RETURN
statement. END-RETURN permits a conditional RETURN statement to be nested
in another conditional statement. END-RETURN can also be used with an
imperative RETURN statement.
For more information, see “Delimited scope statements” on page 237.
REWRITE statement
The REWRITE statement logically replaces an existing record in a direct-access file.
When the REWRITE statement is executed, the associated direct-access file must be
open in I-O mode.
| The REWRITE statement is not supported for line-sequential files.
Format
──REWRITE──record-name-1──┬────────────────────┬──────────────────────────
└─FROM──identifier-1─┘
──┬──────────────────────────────────────────┬─────────────────────────────
└─INVALID──┬─────┬──imperative-statement-1─┘
└─KEY─┘
──┬──────────────────────────────────────────────┬──┬─────────────┬───────
└─NOT INVALID──┬─────┬──imperative-statement-2─┘ └─END-REWRITE─┘
└─KEY─┘
record-name-1
Must be the name of a logical record in a Data Division FD entry. The
record-name can be qualified.
Record-name-1 can define a floating-point data item or DBCS data item.
Identifier-1 must be a DBCS data item if record-name-1 is a DBCS data item.
FROM phrase
The result of the execution of the REWRITE statement with the FROM
identifier-1 phrase is equivalent to the execution of the following statements in
the order specified.
MOVE identifier-1 TO record-name-1.
REWRITE record-name-1
The MOVE is performed according to the rules for the MOVE statement
without the CORRESPONDING phrase.
identifier-1
Identifier-1 can be one of the following:
The name of an entry in the Working-Storage Section or Linkage Section
The name of a record description for another previously opened file
The name of an alphanumeric function identifier
A floating-point data item or a DBCS data item.
Identifier-1 and record-name-1 must not refer to the same storage area.
After the REWRITE statement is executed, the information is still available in
identifier-1 (See “INTO/FROM Identifier Phrase” under “Common processing
facilities” on page 244).
END-REWRITE phrase
This explicit scope terminator serves to delimit the scope of the REWRITE
statement. END-REWRITE permits a conditional REWRITE statement to be nested
in another conditional statement. END-REWRITE can also be used with an
imperative REWRITE statement.
For more information, see “Delimited scope statements” on page 237.
Sequential files
For files in the sequential access mode, the last prior input/output statement
executed for this file must be a successfully executed READ statement. When the
REWRITE statement is executed, the record retrieved by that READ statement is
logically replaced.
The number of character positions in record-name-1 must equal the number of
character positions in the record being replaced.
The INVALID KEY phrase must not be specified for a file with sequential
organization. An EXCEPTION/ERROR procedure can be specified.
Indexed files
The number of character positions in record-name-1 must equal the number of
character positions in the record being replaced.
The number of character positions in record-name-1 can be different from the
number of character positions in the record being replaced.
When the access mode is sequential, the record to be replaced is specified by the
value contained in the prime RECORD KEY. When the REWRITE statement is
executed, this value must equal the value of the prime record key data item in the
last record read from this file.
The INVALID KEY phrase must be specified if an applicable USE AFTER
STANDARD EXCEPTION procedure is not specified for the associated file-name.
Relative files
The number of character positions in record-name-1 must equal the number of
character positions in the record being replaced.
The number of character positions in record-name-1 can be different from the
number of character positions in the record being replaced.
For relative files in sequential access mode, the INVALID KEY phrase must not be
specified. An EXCEPTION/ERROR procedure can be specified.
The INVALID KEY phrase must be specified in the REWRITE statement for
relative files in the random or dynamic access mode, and for which an appropriate
USE AFTER STANDARD EXCEPTION procedure is not specified.
The INVALID KEY phrase does not have to be specified if an appropriate USE
AFTER STANDARD EXCEPTION procedure is not specified.
When the access mode is random or dynamic, the record to be replaced is
specified in the RELATIVE KEY data item. If the file does not contain the record
specified, an invalid key condition exists, and, if specified, the INVALID KEY
imperative-statement is executed. (See “Invalid key condition” under “Common
processing facilities” on page 244.) The updating operation does not take place,
and the data in record-name is unaffected.
SEARCH statement
The SEARCH statement searches a table for an element that satisfies the specified
condition, and adjusts the associated index to indicate that element.
Format 1—serial search
──SEARCH──identifier-1──┬───────────────────────────┬──┬─────────────────────────────────────┬───
└─VARYING──┬─identifier-2─┬─┘ └─┬────┬──END──imperative-statement-1─┘
└─index-name-1─┘ └─AT─┘
┌──
───────────────────────────────────────────────┐
───/─WHEN──condition-1──┬─imperative-statement-2─┬─┴──┬────────────┬──────────────────────────────
└─NEXT-SENTENCE──────────┘ └─END-SEARCH─┘
identifier-1
Can be:
A data item subordinate to a data item that contains an OCCURS clause;
that is, it can be a part of a multidimensional table. In this case, the data
description entry must specify an INDEXED BY phrase for each dimension
of the table.
An index data item.
A DBCS data item or a floating-point data item.
Identifier-1 must refer to all occurrences within the table element; that is, it
must not be subscripted or reference-modified.
The Data Division description of identifier-1 must contain an OCCURS clause
with the INDEXED BY phrase. For format 2, the Data Division description
must also contain the KEY IS phrase in its OCCURS clause.
SEARCH statement execution modifies only the value in the index-name
associated with identifier-1 (and, if present, of index-name-1 or identifier-2).
Therefore, to search an entire 2- to 7-dimensional table, it is necessary to
execute a SEARCH statement for each dimension. Before each execution, SET
statements must be executed to reinitialize the associated index-names.
AT END/WHEN phrases
After imperative-statement-1 or imperative-statement-2 is executed, control passes
to the end of the SEARCH statement, unless imperative-statement-1 or
imperative-statement-2 ends with a GO TO statement.
END-SEARCH phrase
This explicit scope terminator serves to delimit the scope of the SEARCH
statement. END-SEARCH permits a conditional SEARCH statement to be nested
in another conditional statement.
For more information, see “Delimited scope statements” on page 237.
Serial search
The format 1 SEARCH statement executes a serial search beginning at the current
index setting. When the search begins, if the value of the index-name associated
with identifier-1 is not greater than the highest possible occurrence number, the
following actions take place:
The condition(s) in the WHEN phrase are evaluated in the order in which they
are written.
If none of the conditions is satisfied, the index-name for identifier-1 is
increased to correspond to the next table element, and step 1 is repeated.
If upon evaluation, one of the WHEN conditions is satisfied, the search is
terminated immediately, and the imperative-statement associated with that
condition is executed. The index-name points to the table element that
satisfied the condition. If NEXT SENTENCE is specified, control passes to the
statement following the closest period.
If the end of the table is reached (that is, the incremented index-name value is
greater than the highest possible occurrence number) without the WHEN
condition being satisfied, the search is terminated, as described in the next
paragraph.
If, when the search begins, the value of the index-name associated with identifier-1
is greater than the highest possible occurrence number, the search immediately
ends, and, if specified, the AT END imperative-statement is executed. If the AT
END phrase is omitted, control passes to the next statement after the SEARCH
statement.
VARYING phrase
index-name-1
One of the following actions applies:
If index-name-1 is an index for identifier-1, this index is used for the
search. Otherwise, the first (or only) index-name is used.
If index-name-1 is an index for another table element, then the first (or
only) index-name for identifier-1 is used for the search; the occurrence
Binary search
The format 2 SEARCH ALL statement executes a binary search. The search index
need not be initialized by SET statements, because its setting is varied during the
search operation so that its value is at no time less than the value of the first table
element, nor ever greater than the value of the last table element. The index used
is always that associated with the first index-name specified in the OCCURS
clause.
The results of a SEARCH ALL operation are predictable only when:
The data in the table is ordered in ASCENDING/DESCENDING KEY order
SET statement
The SET statement is used to perform one of the following operations:
Placing values associated with table elements into indexes associated with
index-names
Incrementing or decrementing an occurrence number
Setting the status of an external switch to ON or OFF
Moving data to condition names to make conditions true
Setting USAGE IS POINTER data items to a data address
Setting USAGE IS PROCEDURE-POINTER data items to an entry address
Setting USAGE OBJECT REFERENCE data items to refer to an object instance
Index-names are related to a given table through the INDEXED BY phrase of the
OCCURS clause; they are not further defined in the program.
When the sending and receiving fields in a SET statement share part of their
storage (that is, the operands overlap), the result of the execution of such a SET
statement is undefined.
index-name-1, identifier-1
Receiving fields.
Must name either index data items or elementary numeric integer items. The
receiving fields cannot be windowed date fields.
index-name-2
Sending field.
The value before the SET statement is executed must correspond to the
occurrence number of its associated table.
identifier-2
Sending field.
Must name either an index data item or an elementary numeric integer item.
The sending field cannot be a windowed date field.
integer-1
Sending field.
Must be a positive integer.
Table 47 shows valid combinations of sending and receiving fields in a format 1
SET statement.
Receiving fields are acted upon in the left-to-right order in which they are
specified. Any subscripting or indexing associated with an identifier's receiving
field is evaluated immediately before the field is acted upon.
The value used for the sending field is the value at the beginning of SET statement
execution.
The value for an index-name after execution of a SEARCH or PERFORM statement
can be undefined; therefore, a format 1 SET statement should reinitialize such
index-names before other table-handling operations are attempted.
If index-name-2 is for a table that has a subordinate item that contains an OCCURS
DEPENDING ON clause, then undefined values can be received into identifier-1.
For more information on complex OCCURS DEPENDING ON, see the IBM
COBOL Programming Guide for your platform.
The receiving field can be specified by index-name-3. This index-name value both
before and after the SET statement execution must correspond to the occurrence
numbers in an associated table.
The sending field can be specified as identifier-3, which must be an elementary
integer data item, or as integer-2, which must be a nonzero integer. Identifier-3
cannot be a windowed date field.
When the format 2 SET statement is executed, the contents of the receiving field
are increased (UP BY) or decreased (DOWN BY) by a value that corresponds to the
number of occurrences represented by the value of identifier-3 or integer-2.
Receiving fields are acted upon in the left-to-right order in which they are
specified. The value of the incrementing or decrementing field at the beginning of
SET statement execution is used for all receiving fields.
If index-name-3 is for a table that has a subordinate item that contains an OCCURS
DEPENDING ON clause, and if the ODO object is changed before executing a
mnemonic-name
Must be associated with an external switch, the status of which can be altered.
condition-name-1
Must be associated with a conditional variable.
If more than one literal is specified in the VALUE clause of condition-name-1, its
associated conditional variable is set equal to the first literal.
If multiple condition-names are specified, the results are the same as if a separate
SET statement had been written for each condition-name in the same order in
which they are specified in the SET statement.
Table 48. Sending and receiving fields for format 5 SET statement
Receiving field
Sending field USAGE IS
ADDRESS OF NULL/NULLS
POINTER
USAGE IS POINTER Valid Valid -
ADDRESS OF Valid Valid -
NULL/NULLS Valid Valid -
procedure-pointer-data-item-1, procedure-pointer-data-item-2
Must be described as USAGE IS PROCEDURE-POINTER.
Procedure-pointer-data-item-1 is the receiving field.
identifier-8
Must be defined as an alphanumeric item such that the value can be a
program name. For more information, see “PROGRAM-ID paragraph” on
page 70. For entry points in non-COBOL programs, identifier-8 can contain
the characters @, #, and, $.
literal-1
Must be nonnumeric and must conform to the rules for formation of
program-names. For details on formation rules, see the discussion of
program-name under “PROGRAM-ID paragraph” on page 70.
Identifier-8 or literal-1 must refer to one of the following types of entry points:
The primary entry point of a COBOL program as defined by the
PROGRAM-ID statement. The PROGRAM-ID must reference the
outermost program of a compilation unit; it must not reference a nested
program.
An alternate entry point of a COBOL program as defined by a COBOL
ENTRY statement.
An entry point in a non-COBOL program.
The program-name referenced by the SET...TO ENTRY statement can be
affected by the PGMNAME compiler option. For details, see the IBM COBOL
Programming Guide for your platform.
NULL
NULLS
Sets the receiving field to contain the value of an invalid address.
pointer-data-item-3
Must be defined with USAGE POINTER. You must set pointer-data-item-3 in
a non-COBOL program, to point to a valid program entry point.
SORT statement
The SORT statement accepts records from one or more files, sorts them according
to the specified key(s), and makes the sorted records available either through an
OUTPUT PROCEDURE or in an output file. See also “MERGE statement” on
page 314. The SORT statement can appear anywhere in the Procedure Division
except in the declarative portion.
| The SORT statement is not supported under OS/390 Unix.
Format
┌──
──────────────────────────────────────────────────┐
│ ┌──
─────────────┐ │
──SORT──file-name-1───/─┬────┬──┬─ASCENDING──┬──┬─────┬───/─data-name-1─┴─┴────────────────────────
└─ON─┘ └─DESCENDING─┘ └─KEY─┘
──┬─────────────────────────────────────────┬─────────────────────────────────────────────────────
└─┬──────┬──DUPLICATES──┬────┬──┬───────┬─┘
└─WITH─┘ └─IN─┘ └─ORDER─┘
──┬──────────────────────────────────────────────────┬────────────────────────────────────────────
└─┬───────────┬──SEQUENCE──┬────┬──alphabet-name-1─┘
└─COLLATING─┘ └─IS─┘
┌──
─────────────┐
──┬─USING───/─file-name-2─┴───────────────────────────────────────────────────────┬────────────────
└─INPUT PROCEDURE──┬────┬──procedure-name-1──┬───────────────────────────────┬─┘
└─IS─┘ └─┬─THROUGH─┬──procedure-name-2─┘
└─THRU────┘
┌──
─────────────┐
──┬─GIVING───/─file-name-3─┴───────────────────────────────────────────────────────┬──────────────
└─OUTPUT PROCEDURE──┬────┬──procedure-name-3──┬───────────────────────────────┬─┘
└─IS─┘ └─┬─THROUGH─┬──procedure-name-4─┘
└─THRU────┘
file-name-1
The name given in the SD entry that describes the records to be sorted.
No pair of file-names in a SORT statement can be specified in the same SAME
SORT AREA, or SAME SORT-MERGE AREA clause. File-names associated with
the GIVING clause (file-name-3...) cannot be specified in the SAME AREA clause.
File-names associated with the GIVING clause (file-name-3...) can be specified in
the SAME AREA clause.
If the KEY is an external floating-point item, the compiler will treat the data
item as character data, rather than numeric data. The sequence in which the
records are sorted depends on the collating sequence used.
If the KEY data item is internal floating-point, the sequence of key values will
be in numeric order.
The key comparisons are performed according to the rules for comparison of
operands in a relation condition (see “Relation Condition” under “Conditional
expressions” on page 214).
DUPLICATES phrase
If the DUPLICATES phrase is specified, and the contents of all the key elements
associated with one record are equal to the corresponding key elements in one or
more other records, the order of return of these records is as follows:
The order of the associated input files as specified in the SORT statement.
Within a given file the order is that in which the records are accessed from
that file.
The order in which these records are released by an input procedure, when an
input procedure is specified.
If the DUPLICATES phrase is not specified, the order of these records is
undefined. For more information about use of the DUPLICATES phrase, see the
related discussion of alternate indexes in the IBM COBOL Programming Guide for
your platform.
USING phrase
file-name-2,...
The input files.
When the USING phrase is specified, all the records in file-name-2,..., (that is,
the input files) are transferred automatically to file-name-1. At the time the
SORT statement is executed, these files must not be open; the compiler opens,
reads, makes records available, and closes these files automatically. If
EXCEPTION/ERROR procedures are specified for these files, the compiler
makes the necessary linkage to these procedures.
All input files must be described in FD entries in the Data Division.
If the USING phrase is specified and if file-name-1 contains variable-length
records, the size of the records contained in the input files (file-name-2,...)
must not be less than the smallest record nor greater than the largest record
described for file-name-1. If file-name-1 contains fixed-length records, the size
GIVING phrase
file-name-3,...
The output files.
When the GIVING phrase is specified, all the sorted records in file-name-1 are
automatically transferred to the output files (file-name-3,...).
All output files must be described in FD entries in the Data Division.
If the output files (file-name-3,...) contain variable-length records, the size of
the records contained in file-name-1 must not be less than the smallest record
nor greater than the largest record described for the output files. If the output
files contain fixed-length records, the size of the records contained in
file-name-1 must not be greater than the largest record described for the
output files. For more information, see the IBM COBOL Programming Guide for
your platform.
At the time the SORT statement is executed, the output files (file-name-3,...)
must not be open. For each of the output files, the execution of the SORT
statement causes the following actions to be taken:
The processing of the file is initiated. The initiation is performed as if an
OPEN statement with the OUTPUT phrase had been executed.
Note: The INPUT and OUTPUT PROCEDURE phrases are similar to those for
a basic PERFORM statement. For example, if you name a procedure in an
OUTPUT PROCEDURE, that procedure is executed during the sorting
operation just as if it were named in a PERFORM statement. As with the
PERFORM statement, execution of the procedure is terminated after the last
Note: If you use a sort control file to specify control statements, the values
specified in the sort control file take precedence over those in the special register.
SORT-MESSAGE special register
See “SORT-MESSAGE” on page 15.
SORT-CORE-SIZE special register
See “SORT-CORE-SIZE” on page 15.
SORT-FILE-SIZE special register
See “SORT-FILE-SIZE” on page 15.
SORT-MODE-SIZE special register
See “SORT-MODE-SIZE” on page 16.
SORT-CONTROL special register
See “SORT-CONTROL” on page 14.
SORT-RETURN special register
See “SORT-RETURN” on page 16.
Segmentation considerations
If the SORT statement appears in a section that is not in an independent segment,
then any input or output procedure referenced by that SORT statement must
appear:
Totally within non-independent segments, or
Wholly contained in a single independent segment.
If a SORT statement appears in an independent segment, then any input or output
procedure referenced by that SORT statement must be contained:
Totally within non-independent segments, or
Wholly within the same independent segment as that SORT statement.
START statement
The START statement provides a means of positioning within an indexed or
relative file for subsequent sequential record retrieval.
When the START statement is executed, the associated indexed or relative file
must be open in either INPUT or I-O mode.
Format
──START──file-name-1──┬───────────────────────────────────────────────────────────────────┬──────
└─KEY──┬────┬──┬─EQUAL──┬────┬───────────────────────┬──data-name-1─┘
└─IS─┘ │ └─TO─┘ │
├─=───────────────────────────────────┤
├─LESS──┬──────┬──────────────────────┤
│ └─THAN─┘ │
├─<───────────────────────────────────┤
├─GREATER──┬──────┬───────────────────┤
│ └─THAN─┘ │
├─>───────────────────────────────────┤
├─NOT LESS──┬──────┬──────────────────┤
│ └─THAN─┘ │
├─NOT <───────────────────────────────┤
├─NOT GREATER──┬──────┬───────────────┤
│ └─THAN─┘ │
├─NOT >───────────────────────────────┤
├─LESS──┬──────┬──OR EQUAL──┬────┬────┤
│ └─THAN─┘ └─TO─┘ │
├─<=──────────────────────────────────┤
├─GREATER──┬──────┬──OR EQUAL──┬────┬─┤
│ └─THAN─┘ └─TO─┘ │
└─>=──────────────────────────────────┘
──┬──────────────────────────────────────────┬────────────────────────────────────────────────────
└─INVALID──┬─────┬──imperative-statement-1─┘
└─KEY─┘
──┬──────────────────────────────────────────────┬──┬───────────┬────────────────────────────────
└─NOT INVALID──┬─────┬──imperative-statement-2─┘ └─END-START─┘
└─KEY─┘
file-name-1
Must name a file with sequential or dynamic access. File-name-1 must be
defined in an FD entry in the Data Division, and must not name a sort file.
KEY phrase
When the KEY phrase is specified, the file position indicator is positioned at the
logical record in the file whose key field satisfies the comparison.
When the KEY phrase is not specified, KEY IS EQUAL (to the prime record key) is
implied.
If you specify the KEY to be 'less than', or 'less than or equal to' the data item, the
file position indicator is positioned to the last logical record currently existing in
the file satisfying the comparison.
For an indexed file, if the key that satisfies the comparison has duplicate entries,
the file position indicator is positioned to the last of these entries.
END-START phrase
This explicit scope terminator serves to delimit the scope of the START statement.
END-START permits a conditional START statement to be nested in another
conditional statement. END-START can also be used with an imperative START
statement.
For more information, see “Delimited scope statements” on page 237.
Indexed files
When the KEY phrase is specified, the key data item used for the comparison is
data-name-1.
When the KEY phrase is not specified, the key data item used for the EQUAL TO
comparison is the prime RECORD KEY.
When START statement execution is successful, the RECORD KEY or
ALTERNATE RECORD KEY with which data-name-1 is associated becomes the
key of reference for subsequent READ statements.
data-name-1
Can be any of the following:
The prime RECORD KEY
Any ALTERNATE RECORD KEY
An alphanumeric data item within a record description for a file whose
leftmost character position corresponds to the leftmost character position of
that record key; it can be qualified. The data item must be less than or
equal to the length of the record key for the file.
Data-name-1 need not be an alphanumeric item. However, for purposes of
the I/O operation, it will be treated as an alphanumeric item.
Relative files
When the KEY phrase is specified, data-name-1 must specify the RELATIVE KEY.
Whether or not the KEY phrase is specified, the key data item used in the
comparison is the RELATIVE KEY data item. The file position indicator points to
the logical record in the file whose key satisfies the comparison.
STOP statement
The STOP statement halts execution of the object program either permanently or
temporarily.
Format
──STOP──┬─RUN─────┬──────────────────────────────────────────────────────
└─literal─┘
literal
Can be numeric or nonnumeric, and can be any figurative constant except ALL
literal. If the literal is numeric, it must be an unsigned integer.
Can be a signed numeric integer or non-integer literal, but cannot be a
floating-point literal.
When STOP literal is specified, the literal is communicated to the operator, and
object program execution is suspended. Program execution is resumed only after
operator intervention, and continues at the next executable statement in sequence.
The STOP literal statement is useful for special situations (a special tape or disk
must be mounted, a specific daily code must be entered, and so forth) when
operator intervention is needed during program execution. However, the ACCEPT
and DISPLAY statements are preferred when operator intervention is needed.
Under AIX and Windows, do not use the STOP RUN or STOP literal
statement in programs compiled with the THREAD compiler option.
When STOP RUN is specified, execution of the object program is terminated, and
control is returned to the system. If a STOP RUN statement appears in a sequence
of imperative statements within a sentence, it must be the last or only statement in
the sequence.
The STOP RUN statement does not have to be the last statement in a sequence, but
the statements following the STOP RUN will not be executed.
The STOP RUN statement closes all files defined in any of the programs
comprising the run unit.
For use of the STOP RUN statement in calling and called programs, see the table
below.
STRING statement
The STRING statement strings together the partial or complete contents of two or
more data items or literals into one single data item.
One STRING statement can be written instead of a series of MOVE statements.
Format
┌──
───────────────────────────────────────────────────────────┐
│ ┌────────────────────┐ │
──STRING───/──/─┬─identifier-1─┬─┴──DELIMITED──┬────┬──┬─identifier-2─┬─┴───
└─literal-1────┘ └─BY─┘ ├─literal-2────┤
└─SIZE─────────┘
──INTO──identifier-3──┬─────────────────────────────────┬──────────────────
└─┬──────┬──POINTER──identifier-4─┘
└─WITH─┘
──┬──────────────────────────────────────────┬─────────────────────────────
└─┬────┬──OVERFLOW──imperative-statement-1─┘
└─ON─┘
──┬───────────────────────────────────────────────┬──┬────────────┬───────
└─NOT──┬────┬──OVERFLOW──imperative-statement-2─┘ └─END-STRING─┘
└─ON─┘
All identifiers (except identifier-4, the POINTER item) must have USAGE
DISPLAY, explicitly or implicitly.
None of the identifiers in a STRING statement can be windowed date fields.
identifier-1
Represents the sending field(s).
When the sending field or any of the delimiters is an elementary numeric item,
it must be described as an integer, and its PICTURE character-string must not
contain the symbol P.
literal-1
Represents the sending field(s).
All literals must be nonnumeric literals; each can be any figurative constant except
the ALL literal. When a figurative constant is specified, it is considered a
1-character nonnumeric literal.
identifier-1 through identifier-3
Can be DBCS data items. If one of these identifiers is a DBCS item, then all of
them, and all literals, must be DBCS items. Cannot be external floating-point
items.
literal-1 and literal-2
Can be DBCS literals. If one of these is a DBCS literal, then all of them must
be DBCS literals, and identifier-1 through identifier-3 must be DBCS items.
SPACE is the only figurative constant allowed for DBCS items.
DELIMITED BY phrase
The DELIMITED BY phrase sets the limits of the string.
INTO phrase
identifier-3
Represents the receiving field.
It must not represent an edited data item or external floating-point item and
must not be described with the JUSTIFIED clause. As an IBM extension,
identifier-3 can be reference-modified.
If identifier-3 and identifier-4 occupy the same storage area, undefined results
will occur, even if the identifiers are defined by the same data description
entry.
POINTER phrase
identifier-4
Represents the pointer field, which points to a character position in the
receiving field.
It must be an elementary integer data item large enough to contain a value
equal to the length of the receiving area plus 1. The pointer field must not
contain the symbol P in its PICTURE character-string.
When identifier-3 (the receiving field) is a DBCS data item, identifier-4
indicates the relative DBCS character position (not the relative byte position) in
the receiving field.
ON OVERFLOW phrases
imperative-statement-1
Executed when the pointer value (explicit or implicit):
Is less than 1
Exceeds a value equal to the length of the receiving field.
When either of the above conditions occurs, an overflow condition exists, and
no more data is transferred. Then the STRING operation is terminated, the
NOT ON OVERFLOW phrase, if specified, is ignored, and control is
transferred to the end of the STRING statement or, if the ON OVERFLOW
phrase is specified, to imperative-statement-1.
If control is transferred to imperative-statement-1, execution continues
according to the rules for each statement specified in imperative-statement-1.
If a procedure branching or conditional statement that causes explicit transfer
of control is executed, control is transferred according to the rules for that
END-STRING phrase
This explicit scope terminator serves to delimit the scope of the STRING statement.
END-STRING permits a conditional STRING statement to be nested in another
conditional statement. END-STRING can also be used with an imperative STRING
statement.
For more information, see “Delimited scope statements” on page 237.
Data flow
When the STRING statement is executed, data is transferred from the sending
fields to the receiving field. The order in which sending fields are processed is the
order in which they are specified. The following rules apply:
Characters from the sending fields are transferred to the receiving field,
according to the rules for alphanumeric to alphanumeric elementary moves,
except that no space filling is provided (see “MOVE statement” on page 320).
When DELIMITED BY identifier/literal is specified, the contents of each
sending item are transferred, character-by-character, beginning with the
leftmost character and continuing until either:
— A delimiter for this sending field is reached (the delimiter itself is not
transferred), or
— The rightmost character of this sending field has been transferred.
When DELIMITED BY SIZE identifier is specified, each entire sending field is
transferred to the receiving field.
When the receiving field is filled, or when all the sending fields have been
processed, the operation is ended.
When the POINTER phrase is specified, an explicit pointer field is available to
the COBOL user to control placement of data in the receiving field. The user
must set the explicit pointer's initial value, which must not be less than 1 and
not more than the character count of the receiving field. (Note that the pointer
field must be defined as a field large enough to contain a value equal to the
length of the receiving field plus 1; this precludes arithmetic overflow when
the system updates the pointer at the end of the transfer.)
SUBTRACT statement
The SUBTRACT statement subtracts one numeric item, or the sum of two or more
numeric items, from one or more numeric items, and stores the result.
Format 1
┌──
──────────────────┐ ┌──
───────────────────────────┐
──SUBTRACT───/─┬─identifier-1─┬─┴──FROM───/─identifier-2──┬─────────┬─┴─────
└─literal-1────┘ └─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬──────────────┬───
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-SUBTRACT─┘
└─ON─┘
All identifiers or literals preceding the key word FROM are added together and
this sum is subtracted from and stored immediately in identifier-2. This process is
repeated for each successive occurrence of identifier-2, in the left-to-right order in
which identifier-2 is specified.
Format 2
┌──
──────────────────┐
──SUBTRACT───/─┬─identifier-1─┬─┴──FROM──┬─identifier-2─┬──────────────────
└─literal-1────┘ └─literal-2────┘
┌──
───────────────────────────┐
──GIVING───/─identifier-3──┬─────────┬─┴────────────────────────────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬──────────────┬───
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-SUBTRACT─┘
└─ON─┘
All identifiers or literals preceding the key word FROM are added together and
this sum is subtracted from identifier-2 or literal-2. The result of the subtraction is
stored as the new value of each data item referenced by identifier-3.
Format 3
──SUBTRACT──┬─CORRESPONDING─┬──identifier-1──FROM─────────────────────────
└─CORR──────────┘
──identifier-2──┬─────────┬────────────────────────────────────────────────
└─ROUNDED─┘
──┬────────────────────────────────────────────┬───────────────────────────
└─┬────┬──SIZE ERROR──imperative-statement-1─┘
└─ON─┘
──┬─────────────────────────────────────────────────┬──┬──────────────┬───
└─NOT──┬────┬──SIZE ERROR──imperative-statement-2─┘ └─END-SUBTRACT─┘
└─ON─┘
Elementary data items within identifier-1 are subtracted from, and the results are
stored in, the corresponding elementary data items within identifier-2.
The composite of operands must not contain more than 18 digits.
ROUNDED phrase
For information on the ROUNDED phrase, and for operand considerations, see
“ROUNDED phrase” on page 239.
END-SUBTRACT phrase
This explicit scope terminator serves to delimit the scope of the SUBTRACT
statement. END-SUBTRACT permits a conditional SUBTRACT statement to be
nested in another conditional statement. END-SUBTRACT can also be used with
an imperative SUBTRACT statement.
For more information, see “Delimited scope statements” on page 237.
UNSTRING statement
The UNSTRING statement causes contiguous data in a sending field to be
separated and placed into multiple receiving fields.
Format
──UNSTRING──identifier-1─────────────────────────────────────────────────────────────────────────
──┬─────────────────────────────────────────────────────────────────────────────────────┬─────────
└─DELIMITED──┬────┬──┬─────┬──┬─identifier-2─┬──┬───────────────────────────────────┬─┘
└─BY─┘ └─ALL─┘ └─literal-1────┘ │ ┌── ───────────────────────────────┐ │
└──/─OR──┬─────┬──┬─identifier-3─┬─┴─┘
└─ALL─┘ └─literal-2────┘
┌──
────────────────────────────────────────────────────────────────────────────────────┐
──INTO───/─identifier-4──┬─────────────────────────────────┬──┬─────────────────────────────┬─┴────
└─DELIMITER──┬────┬──identifier-5─┘ └─COUNT──┬────┬──identifier-6─┘
└─IN─┘ └─IN─┘
──┬─────────────────────────────────┬──┬────────────────────────────────┬─────────────────────────
└─┬──────┬──POINTER──identifier-7─┘ └─TALLYING──┬────┬──identifier-8─┘
└─WITH─┘ └─IN─┘
──┬──────────────────────────────────────────┬────────────────────────────────────────────────────
└─┬────┬──OVERFLOW──imperative-statement-1─┘
└─ON─┘
──┬───────────────────────────────────────────────┬──┬──────────────┬────────────────────────────
└─NOT──┬────┬──OVERFLOW──imperative-statement-2─┘ └─END-UNSTRING─┘
└─ON─┘
DELIMITED BY phrase
This phrase specifies delimiters within the data that control the data transfer.
If the DELIMITED BY phrase is not specified, the DELIMITER IN and COUNT IN
phrases must not be specified.
identifier-2
identifier-3
Each represents one delimiter.
Each can be either of the following:
An alphanumeric data item
INTO phrase
This phrase specifies the fields where the data is to be moved.
POINTER phrase
When the POINTER phrase is specified, the value of the pointer field behaves as if
it were increased by 1 for each examined character in the sending field. When
execution of the UNSTRING statement is completed, the pointer field contains a
value equal to its initial value, plus the number of characters examined in the
sending field.
When this phrase is specified, the user must initialize identifier-7 before execution
of the UNSTRING statement begins.
identifier-7
Is the pointer field. This field contains a value that indicates a relative
position in the sending field.
Identifier-7 must be an integer data item defined without the symbol P in the
PICTURE string.
It must be described as a data item of sufficient size to contain a value equal to
1 plus the size of the data item referenced by identifier-1.
TALLYING IN phrase
When the TALLYING phrase is specified, the field-count field contains (at the end
of execution of the UNSTRING statement) a value equal to the initial value, plus
the number of data receiving areas acted upon.
When this phrase is specified, the user must initialize identifier-8 before execution
of the UNSTRING statement begins.
identifier-8
Is the field-count field. This field is increased by the number of data
receiving fields acted upon in this execution of the UNSTRING statement.
It must be an integer data item defined without the symbol P in the PICTURE
string.
ON OVERFLOW phrases
An overflow condition exists when:
The pointer value (explicit or implicit) is less than 1.
The pointer value (explicit or implicit) exceeds a value equal to the length of
the sending field.
All data receiving fields have been acted upon, and the sending field still
contains unexamined characters.
END-UNSTRING phrase
This explicit scope terminator serves to delimit the scope of the UNSTRING
statement. END-UNSTRING permits a conditional UNSTRING statement to be
nested in another conditional statement. END-UNSTRING can also be used with
an imperative UNSTRING statement.
For more information, see “Delimited scope statements” on page 237.
Data flow
When the UNSTRING statement is initiated, data is transferred from the sending
field to the current data receiving field, according to the following rules:
Stage 1: Examine
1. If the POINTER phrase is specified, the field is examined, beginning at the
relative character position specified by the value in the pointer field.
If the POINTER phrase is not specified, the sending field character-string is
examined, beginning with the leftmost character.
2. If the DELIMITED BY phrase is specified, the examination proceeds from left
to right, character-by-character, until a delimiter is encountered. If the end of
the sending field is reached before a delimiter is found, the examination ends
with the last character in the sending field. If there are more receiving fields,
the next one is selected; otherwise, an overflow condition occurs.
If the DELIMITED BY phrase is not specified, the number of characters
examined is equal to the size of the current data receiving field, which
depends on its data category, as shown in Table 40 on page 304.
Stage 2: Move
3. The examined characters (excluding any delimiter characters) are treated as an
alphanumeric elementary item, and are moved into the current data receiving
field, according to the rules for the MOVE statement (see “MOVE statement”
on page 320).
4. If the DELIMITER IN phrase is specified, the delimiting characters in the
sending field are treated as an elementary alphanumeric item and are moved
to the current delimiter receiving field, according to the rules for the MOVE
statement. If the delimiting condition is the end of the sending field, the
current delimiter receiving field is filled with spaces.
5. If the COUNT IN phrase is specified, a value equal to the number of examined
characters (excluding any delimiters) is moved into the data count field,
according to the rules for an elementary move.
Stage 3: Successive Iterations
6. If the DELIMITED BY phrase is specified, the sending field is further
examined, beginning with the first character to the right of the delimiter.
If the DELIMITED BY phrase is not specified, the sending field is further
examined, beginning with the first character to the right of the last character
examined.
7. For each succeeding data receiving field, this process of examining and moving
is repeated until either of the following occurs:
All the characters in the sending field have been transferred.
There are no more unfilled data receiving fields.
WRITE statement
The WRITE statement releases a logical record for an output or input/output file.
When the WRITE statement is executed:
The associated sequential file must be open in OUTPUT or EXTEND mode.
The associated indexed or relative file must be open in OUTPUT, I-O, or
EXTEND mode.
Format 1—sequential files
──WRITE──record-name-1──┬──────────────────────┬─────────────────────────────────────────────────────────────
(1) ┘
└─FROM──identifier-1───
──┬─┬────────────────────────────────────────────────────────────┬──┤ phrase 1 ├───────────────────┬──────────
│ └─┬─BEFORE─┬──┬───────────┬──┬─┬─identifier-2─┬──┬───────┬─┬─┘ │
│ └─AFTER──┘ └─ADVANCING─┘ │ └─integer-1────┘ ├─LINE──┤ │ │
│ │ └─LINES─┘ │ │
│ ├─mnemonic-name-1─────────────┤ │
│ └─PAGE────────────────────────┘ │
└─┬──────────────────────────────────────────┬──┬──────────────────────────────────────────────┬─┘
└─INVALID──┬─────┬──imperative-statement-1─┘ └─NOT INVALID──┬─────┬──imperative-statement-2─┘
└─KEY─┘ └─KEY─┘
──┬───────────┬──────────────────────────────────────────────────────────────────────────────────────────────
└─END-WRITE─┘
phrase 1
├──┬─────────────────────────────────────────────────┬─────────────────────────────────────────────────────────
└─┬────┬──┬─END-OF-PAGE─┬──imperative-statement-3─┘
└─AT─┘ └─EOP─────────┘
──┬──────────────────────────────────────────────────────┬────────────────────────────────────────────────────┤
└─NOT──┬────┬──┬─END-OF-PAGE─┬──imperative-statement-4─┘
└─AT─┘ └─EOP─────────┘
Note:
1 The BEFORE, AFTER, INVALID KEY, and AT END OF PAGE phrases are not valid for STL
record-name-1
Must be defined in a Data Division FD entry. Record-name-1 can be qualified.
It must not be associated with a sort or merge file.
If record-name-1 is defined as a DBCS data item, Identifier-1 must be a DBCS
data item.
For relative files, as an IBM extension, the number of character positions in the
record-name can be different from the number of character positions in the
record being replaced.
The MOVE is performed according to the rules for the MOVE statement
without the CORRESPONDING phrase.
identifier-1
Identifier-1 can be any of the following:
The name of an entry in the Working-Storage Section or the LINKAGE
SECTION
The name of a record description for another previously opened file
The name of an alphanumeric function identifier
A floating-point data item or a DBCS data item
Identifier-1 and record-name-1 must not refer to the same storage area.
After the WRITE statement is executed, the information is still available in
identifier-1. (See “INTO/FROM Identifier Phrase” under “Common processing
facilities” on page 244.)
identifier-2
Must be an integer data item.
ADVANCING phrase
The ADVANCING phrase controls positioning of the output record on the page.
LINAGE-COUNTER rules
If the LINAGE clause is specified for this file, the associated LINAGE-COUNTER
special register is modified during the execution of the WRITE statement,
according to the following rules:
1. If ADVANCING PAGE is specified, LINAGE-COUNTER is reset to 1.
2. If ADVANCING identifier-2 or integer is specified, LINAGE-COUNTER is
increased by the value in identifier-2 or integer.
3. If the ADVANCING phrase is omitted, LINAGE-COUNTER is increased by 1.
4. When the device is repositioned to the first available line of a new page,
LINAGE-COUNTER is reset to 1.
Note: If you use the ADV compiler option, the compiler adds 1 byte
to the record length in order to allow for the control character. If in your record
definition you already reserve the first byte for the control character, you should
use the NOADV option. For files defined with the LINAGE clause, the NOADV
option has no effect. The compiler processes these files as if the ADV option were
specified.
END-WRITE phrase
This explicit scope terminator serves to delimit the scope of the WRITE statement.
END-WRITE permits a conditional WRITE statement to be nested in another
conditional statement. END-WRITE can also be used with an imperative WRITE
statement.
For more information, see “Delimited scope statements” on page 237.
Multivolume files
When end-of-volume is recognized for a multivolume OUTPUT file
(tape or sequential direct-access file), the WRITE statement performs the following
operations:
The standard ending volume label procedure
A volume switch
The standard beginning volume label procedure
Intrinsic functions
Data processing problems often require the use of values that are not directly
accessible in the data storage associated with the object program, but instead must
be derived through performing operations on other data. An intrinsic function is a
function that performs a mathematical, character, or logical operation, and thereby
allows you to make reference to a data item whose value is derived automatically
during the execution of the object program.
The functions can be grouped into six categories, based on the type of service
performed: mathematical, statistical, date/time, financial, character-handling, and
general.
You can reference a function by specifying its name, along with any required
arguments, in a Procedure Division statement.
Functions are elementary data items, and return alphanumeric, numeric or integer
values. Functions cannot serve as receiving operands.
Specifying a function
The general format of a function-identifier is:
Format
──FUNCTION──function-name-1──┬──────────────────────┬─────────────────────
│ ┌──
────────────┐ │
└─(───/─argument-1─┴──)─┘
──┬────────────────────┬──────────────────────────────────────────────────
└─reference-modifier─┘
function-name-1
Function-name-1 must be one of the intrinsic function names.
argument-1
Argument-1 must be an identifier, literal (other than a figurative constant), or
arithmetic expression. Argument-1 cannot be a windowed date field, except in
the UNDATE intrinsic function.
reference-modifier
Can be specified only for functions of the category alphanumeric
Below, we will show examples of an intrinsic function invocation for an
alphanumeric source statement and a numeric source statement.
The alphanumeric source statement:
MOVE FUNCTION UPPER-CASE("hello") TO DATA-NAME.
replaces each lowercase letter in the argument with the corresponding uppercase
letter, resulting in the movement of HELLO into DATA-NAME.
The numeric source statement,
COMPUTE NUM-ITEM = FUNCTION SUM(A B C)
Adds the values of A, B, and C and places the result in NUM-ITEM.
Types of functions
There are three types of functions:
Alphanumeric
Numeric
Integer
Alphanumeric functions are of the class and category alphanumeric. The value
returned has an implicit usage of DISPLAY and is in standard data format
characters. The number of character positions in the value returned is determined
by the function definition.
Numeric functions are of the class and category numeric. The returned value is
always considered to have an operational sign and is a numeric intermediate
result. For more information, see the IBM COBOL Programming Guide for your
platform.
Integer functions are of the class and category numeric. The returned value is
always considered to have an operational sign and is an integer intermediate
result. The number of digit positions in the value returned is determined by the
function definition. For more information, see the IBM COBOL Programming
Guide for your platform.
Arguments
The values returned by some functions are determined by the arguments specified
in the function-identifier when the functions are evaluated. Some functions require
no arguments; others require a fixed number of arguments, and still others allow a
variable number of arguments.
An argument must be one of the following:
An identifier
An arithmetic expression
A function-identifier
A literal other than a figurative constant.
A special-register
The argument to a function can be any function or an expression containing a
function, including another evaluation of the same function, whose result meets
the category requirement for the argument.
An argument cannot be a DBCS literal or data item. See “Function definitions” on
page 408 for function specific argument specifications.
ALL subscripting
When a function allows an argument to be repeated a variable number of times,
you can refer to a table by specifying the data-name and any qualifiers that
identify the table. This can be followed immediately by subscripting where one or
more of the subscripts is the word ALL.
In these function invocations the subscript ALL is used to reference all elements of
the PAYROLL-HOURS array (depending on the execution time value of the
PAYROLL-WEEK field).
Function definitions
Table 51 on page 409 provides an overview of the argument type, function type
and value returned for each of the intrinsic functions. Argument types and
function types are abbreviated as follows:
A = alphabetic
I = integer
N = numeric
X = alphanumeric
The behavior of functions marked “DP” depends on whether the DATEPROC or
NODATEPROC compiler option is in effect:
If the DATEPROC compiler option is in effect, the following intrinsic functions
return date fields:
Returned value has implicit DATE FORMAT...
DATE-OF-INTEGER YYYYXXXX
DATE-TO-YYYYMMDD YYYYXXXX
DAY-OF-INTEGER YYYYXXX
DAY-TO-YYYYDDD YYYYXXX
YEAR-TO-YYYY YYYY
DATEVAL Depends on the format specified by DATEVAL
YEARWINDOW YYYY
If the NODATEPROC compiler option is in effect:
— The following intrinsic functions return the same values as when
DATEPROC is in effect, but their returned values are non-dates:
DAY-OF-INTEGER
DATE-TO-YYYYMMDD
DAY-TO-YYYYDDD
YEAR-TO-YYYY
— The DATEVAL and UNDATE intrinsic functions have no effect, and
simply return their (first) arguments unchanged
— The YEARWINDOW intrinsic function returns 0 unconditionally
Each intrinsic function is described in detail on the pages following the table.
The following pages define each of the intrinsic functions summarized in the
previous table.
ACOS
The ACOS function returns a numeric value in radians that approximates the
arccosine of the argument specified.
The function type is numeric.
Format
──FUNCTION ACOS──(argument-1)────────────────────────────────────────────
argument-1
Must be class numeric. The value of argument-1 must be greater than or equal
to -1 and less than or equal to +1.
The returned value is the approximation of the arccosine of the argument and is
greater than or equal to zero and less than or equal to Pi.
ANNUITY
The ANNUITY function returns a numeric value that approximates the ratio of an
annuity paid at the end of each period, for a given number of periods, at a given
interest rate, to an initial value of one. The number of periods is specified by
argument-2; the rate of interest is specified by argument-1. For example, if
argument-1 is zero and argument-2 is four, the value returned is the
approximation of the ratio 1 / 4.
The function type is numeric.
Format
──FUNCTION ANNUITY──(argument-1 argument-2)──────────────────────────────
argument-1
Must be class numeric. The value of argument-1 must be greater than or equal
to zero.
argument-2
Must be a positive integer.
When the value of argument-1 is zero, the value returned by the function is the
approximation of:1 / ARGUMENT-2
When the value of argument-1 is not zero, the value of the function is the
approximation of:
ARGUMENT-1 / (1 - (1 + ARGUMENT-1) VV (- ARGUMENT-2))
ASIN
The ASIN function returns a numeric value in radians that approximates the
arcsine of the argument specified.
The function type is numeric.
Format
──FUNCTION ASIN──(argument-1)────────────────────────────────────────────
argument-1
Must be class numeric. The value of argument-1 must be greater than or equal
to -1 and less than or equal to +1.
The returned value is the approximation of the arcsine of argument-1 and is
greater than or equal to -Pi/2 and less than or equal to +Pi/2.
ATAN
The ATAN function returns a numeric value in radians that approximates the
arctangent of the argument specified.
The function type is numeric.
Format
──FUNCTION ATAN──(argument-1)────────────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the approximation of the arctangent of argument-1 and is
greater than -Pi/2 and less than +Pi/2.
CHAR
The CHAR function returns a 1-character alphanumeric value that is a character in
the program collating sequence having the ordinal position equal to the value of
the argument specified.
The function type is alphanumeric.
Format
──FUNCTION CHAR──(argument-1)────────────────────────────────────────────
argument-1
Must be an integer. The value must be greater than zero and less than or
equal to the number of positions in the collating sequence.
If more than one character has the same position in the program collating
sequence, the character returned as the function value is that of the first literal
specified for that character position in the ALPHABET clause.
If the current program collating sequence was not specified by an ALPHABET
clause:
Under OS/390 and VM, the EBCDIC collating sequence is used. (See
Appendix B, “EBCDIC and ASCII collating sequences” on page 498.)
Under AIX and Windows, the COLLSEQ compiler option indicates the
collating sequence used. For example, if COLLSEQ(EBCDIC) is specified and
the PROGRAM COLLATING SEQUENCE is not specified (or is NATIVE), the
EBCDIC collating sequence is applied.
COS
The COS function returns a numeric value that approximates the cosine of the
angle or arc specified by the argument in radians.
The function type is numeric.
Format
──FUNCTION COS──(argument-1)─────────────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the approximation of the cosine of the argument and is
greater than or equal to -1 and less than or equal to +1.
CURRENT-DATE
The CURRENT-DATE function returns a 21-character alphanumeric value that
represents the calendar date, time of day, and time differential from Greenwich
Mean Time provided by the system on which the function is evaluated.
The function type is alphanumeric.
Format
──FUNCTION CURRENT-DATE──────────────────────────────────────────────────
Reading from left to right, the 21 character positions in the value returned can be
interpreted as follows:
Character
Positions Contents
1-4 Four numeric digits of the year in the Gregorian calendar.
5-6 Two numeric digits of the month of the year, in the range 01 through 12.
7-8 Two numeric digits of the day of the month, in the range 01 through 31.
9-10 Two numeric digits of the hours past midnight, in the range 00 through 23.
11-12 Two numeric digits of the minutes past the hour, in the range 00 through
59.
13-14 Two numeric digits of the seconds past the minute, in the range 00
through 59.
15-16 Two numeric digits of the hundredths of a second past the second, in the
range 00 through 99. The value 00 is returned if the system on which the
function is evaluated does not have the facility to provide the fractional
part of a second.
17 Either the character '-' or the character '+'. The character '-' is returned if
the local time indicated in the previous character positions is behind
Greenwich Mean Time. The character '+' is returned if the local time
indicated is the same as or ahead of Greenwich Mean Time. The character
'0' is returned if the system on which this function is evaluated does not
have the facility to provide the local time differential factor.
18-19 If character position 17 is '-', two numeric digits are returned in the range
00 through 12 indicating the number of hours that the reported time is
behind Greenwich Mean Time. If character position 17 is '+', two numeric
digits are returned in the range 00 through 13 indicating the number of
hours that the reported time is ahead of Greenwich Mean Time. If
character position 17 is '0', the value 00 is returned.
20-21 Two numeric digits are returned in the range 00 through 59 indicating the
number of additional minutes that the reported time is ahead of or behind
Greenwich Mean Time, depending on whether character position 17 is '+'
or '-', respectively. If character position 17 is '0', the value 00 is returned.
For more information, see the IBM COBOL Programming Guide for your platform.
DATE-OF-INTEGER
The DATE-OF-INTEGER function converts a date in the Gregorian calendar from
integer date form to standard date form (YYYYMMDD).
The function type is integer.
The function result is an 8-digit integer.
If the DATEPROC compiler option is in effect, then the returned value is an
expanded date field with implicit DATE FORMAT YYYYXXXX.
Format
──FUNCTION DATE-OF-INTEGER──(argument-1)─────────────────────────────────
argument-1
A positive integer that represents a number of days succeeding December 31,
1600, in the Gregorian calendar. The valid range is 1 to 3,067,671, which
corresponds to dates ranging from January 1, 1601 thru December 31, 9999.
Under OS/390 and VM, the INTDATE compiler option affects the
starting date for the integer date functions. For details, see the IBM COBOL for
OS/390 & VM Programming Guide.
The returned value represents the International Standards Organization (ISO)
standard date equivalent to the integer specified as argument-1.
The returned value is an integer of the form YYYYMMDD where YYYY represents
a year in the Gregorian calendar; MM represents the month of that year; and DD
represents the day of that month.
DATE-TO-YYYYMMDD
The DATE-TO-YYYYMMDD function converts argument-1 from a date with a
2-digit year (YYnnnn) to a date with a 4-digit year (YYYYnnnn). Argument-2,
when added to the year at the time of execution, defines the ending year of a
100-year interval, or sliding century window, into which the year of argument-1
falls.
The function type is integer.
If the DATEPROC compiler option is in effect, then the returned value is an
expanded date field with implicit DATE FORMAT YYYYXXXX.
Format
──FUNCTION DATE-TO-YYYYMMDD──(argument-1─┬────────────┬─)────────────────
└─argument-2─┘
argument-1
Must be zero or a positive integer less than 1,000,000.
argument-2
Must be an integer. If argument-2 is omitted, the function is evaluated
assuming the value 50 was specified.
The sum of the year at the time of execution and the value of argument-2 must be
less than 10,000 and greater than 1,699.
Example
Some examples of returned values from the DATE-TO-YYYYMMDD function
follow:
DATE-TO-YYYYMMDD
Current year Argument-1 value Argument-2 value return value
2002 851003 120 20851003
2002 851003 -20 18851003
2002 851003 10 19851003
1994 981002 -10 18981002
DATEVAL
The DATEVAL function converts a non-date to a date field, for unambiguous use
with date fields.
If the DATEPROC compiler option is in effect, the returned value is a date field
containing the value of argument-1 unchanged. For information on using the
resulting date field:
In arithmetic, see “Arithmetic with date fields” on page 211
In conditional expressions, see “Date fields” on page 219
If the NODATEPROC compiler option is in effect, the DATEVAL function has no
effect, and returns the value of argument-1 unchanged.
The function type depends on the type of argument-1:
Argument-1 type Function type
Alphanumeric Alphanumeric
Integer Integer
Format
──FUNCTION DATEVAL──(──argument-1──argument-2──)─────────────────────────
argument-1
Must be one of the following:
A class alphanumeric item with the same number of characters as the date
format specified by argument-2.
An integer. This can be used to specify values outside the range specified
by argument-2, including negative values.
The value of argument-1 represents a date of the form specified by
argument-2.
Note: You can use apostrophes as the literal delimiters instead of quotes
(independent of the APOST/QUOTE compiler option).
DAY-OF-INTEGER
The DAY-OF-INTEGER function converts a date in the Gregorian calendar from
integer date form to Julian date form (YYYYDDD).
The function type is integer.
The function result is a 7-digit integer.
If the DATEPROC compiler option is in effect, then the returned value is an
expanded date field with implicit DATE FORMAT YYYYXXX.
Format
──FUNCTION DAY-OF-INTEGER──(argument-1)──────────────────────────────────
argument-1
A positive integer that represents a number of days succeeding December 31,
1600, in the Gregorian calendar. The valid range is 1 to 3,067,671, which
corresponds to dates ranging from January 1, 1601 thru December 31, 9999.
Under OS/390 and VM, the INTDATE compiler option affects the
starting date for the integer date functions. For details, see the IBM COBOL for
OS/390 & VM Programming Guide.
The returned value represents the Julian equivalent of the integer specified as
argument-1. The returned value is an integer of the form YYYYDDD where YYYY
represents a year in the Gregorian calendar and DDD represents the day of that
year.
DAY-TO-YYYYDDD
The DAY-TO-YYYYDDD function converts argument-1 from a date with a 2-digit
year (YYnnn) to a date with a 4-digit year (YYYYnnn). Argument-2, when added
to the year at the time of execution, defines the ending year of a 100-year interval,
or sliding century window, into which the year of argument-1 falls.
The function type is integer.
If the DATEPROC compiler option is in effect, then the returned value is an
expanded date field with implicit DATE FORMAT YYYYXXX.
Format
──FUNCTION DAY-TO-YYYYDDD──(argument-1─┬────────────┬─)──────────────────
└─argument-2─┘
argument-1
Must be zero or a positive integer less than 100,000.
argument-2
Must be an integer. If argument-2 is omitted, the function is evaluated
assuming the value 50 was specified.
The sum of the year at the time of execution and the value of argument-2 must be
less than 10,000 and greater than 1,699.
Example
Some examples of returned values from the DAY-TO-YYYYDDD function follow:
DAY-TO-YYYYDDD
Current year Argument-1 value Argument-2 value return value
2002 10004 -20 1910004
2002 10004 -120 1810004
2002 10004 20 2010004
2013 95005 -10 1995005
FACTORIAL
The FACTORIAL function returns an integer that is the factorial of the argument
specified.
The function type is integer.
Format
──FUNCTION FACTORIAL──(argument-1)───────────────────────────────────────
argument-1
INTEGER
The INTEGER function returns the greatest integer value that is less than or equal
to the argument specified.
The function type is integer.
Format
──FUNCTION INTEGER──(argument-1)─────────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the greatest integer less than or equal to the value of
argument-1. For example,
FUNCTION INTEGER (2.5)
will return a value of 2; and
FUNCTION INTEGER (-2.5)
will return a value of -3.
INTEGER-OF-DATE
The INTEGER-OF-DATE function converts a date in the Gregorian calendar from
standard date form (YYYYMMDD) to integer date form.
The function type is integer.
The function result is a 7-digit integer with a range from 1 to 3,067,671.
Format
──FUNCTION INTEGER-OF-DATE──(argument-1)─────────────────────────────────
argument-1
Must be an integer of the form YYYYMMDD, whose value is obtained from
the calculation (YYYY * 10,000) + (MM * 100) + DD.
YYYY represents the year in the Gregorian calendar. It must be an integer
greater than 1600, but not greater than 9999.
MM represents a month and must be a positive integer less than 13.
DD represents a day and must be a positive integer less than 32, provided
that it is valid for the specified month and year combination.
The returned value is an integer that is the number of days the date represented
by argument-1, succeeds December 31, 1600 in the Gregorian calendar.
Under OS/390 and VM, the INTDATE compiler option affects the
starting date for the integer date functions. For details, see the IBM COBOL for
OS/390 & VM Programming Guide.
INTEGER-OF-DAY
The INTEGER-OF-DAY function converts a date in the Gregorian calendar from
Julian date form (YYYYDDD) to integer date form.
The function type is integer.
The function result is a 7-digit integer.
Format
──FUNCTION INTEGER-OF-DAY──(argument-1)──────────────────────────────────
argument-1
Must be an integer of the form YYYYDDD whose value is obtained from the
calculation (YYYY * 1000) + DDD.
YYYY represents the year in the Gregorian calendar. It must be an integer
greater than 1600, but not greater than 9999.
DDD represents the day of the year. It must be a positive integer less than
367, provided that it is valid for the year specified.
Under OS/390 and VM, the INTDATE compiler option affects the
starting date for the integer date functions. For details, see the IBM COBOL for
OS/390 & VM Programming Guide.
The returned value is an integer that is the number of days the date represented
by argument-1, succeeds December 31, 1600 in the Gregorian calendar.
INTEGER-PART
The INTEGER-PART function returns an integer that is the integer portion of the
argument specified.
The function type is integer.
Format
──FUNCTION INTEGER-PART──(argument-1)────────────────────────────────────
argument-1
Must be class numeric.
If the value of argument-1 is zero, the returned value is zero. If the value of
argument-1 is positive, the returned value is the greatest integer less than or equal
to the value of argument-1. If the value of argument-1 is negative, the returned
value is the least integer greater than or equal to the value of argument-1.
LENGTH
The LENGTH function returns an integer equal to the length of the argument in
bytes. The function type is integer.
The function result is a 9-digit integer.
Format
──FUNCTION LENGTH──(argument-1)──────────────────────────────────────────
argument-1
Can be a nonnumeric literal or a data item of any class or category (except
DBCS).
If argument-1, or any data item subordinate to argument-1, is described with
the DEPENDING phrase of the OCCURS clause, the contents of the data item
referenced by the data-name specified in the DEPENDING phrase are used at
the time the LENGTH function is evaluated.
A data item described with USAGE IS POINTER or USAGE IS
PROCEDURE-POINTER can be used as argument-1 to the LENGTH function.
The ADDRESS OF special register can be used as argument-1 to the LENGTH
function.
If the ADDRESS OF special register or LENGTH OF special register is used as
argument-1 to the LENGTH function, the result will always be 4, independent of
the ADDRESS OF or LENGTH OF object.
If argument-1 is a nonnumeric literal, an elementary data item, or a group data
item that does not contain a variable occurrence data item, the value returned is an
integer equal to the length of argument-1 in character positions.
If argument-1 is a group data item containing a variable occurrence data item, the
returned value is an integer determined by evaluation of the data item specified in
the DEPENDING phrase of the OCCURS clause for that variable occurrence data
item. This evaluation is accomplished according to the rules in the OCCURS
clause regarding the data item as a sending data item. For more information, see
the discussions of the OCCURS clause and USAGE clause.
If argument-1 is a null-terminated nonnumeric literal, then the returned value is
the number of characters in the literal excluding the null character that is added at
the end of the literal.
The returned value includes implicit FILLER characters, if any.
LOG
The LOG function returns a numeric value that approximates the logarithm to the
base e (natural log) of the argument specified.
The function type is numeric.
Format
──FUNCTION LOG──(argument-1)─────────────────────────────────────────────
argument-1
Must be class numeric. The value of argument-1 must be greater than zero.
The returned value is the approximation of the logarithm to the base e of
argument-1.
LOG10
The LOG10 function returns a numeric value that approximates the logarithm to
the base 10 of the argument specified.
The function type is numeric.
Format
──FUNCTION LOG1?──(argument-1)───────────────────────────────────────────
argument-1
Must be class numeric. The value of argument-1 must be greater than zero.
The returned value is the approximation of the logarithm to the base 10 of
argument-1.
LOWER-CASE
The LOWER-CASE function returns a character string that is the same length as
the argument specified with each uppercase letter replaced by the corresponding
lowercase letter.
The function type is alphanumeric.
Format
──FUNCTION LOWER-CASE──(argument-1)──────────────────────────────────────
argument-1
Must be class alphabetic or alphanumeric and must be at least one character in
length.
The same character string as argument-1 is returned, except that each uppercase
letter is replaced by the corresponding lowercase letter.
The character string returned has the same length as argument-1.
MAX
The MAX function returns the content of the argument that contains the maximum
value.
The function type depends on the argument types, as follows:
Argument type Function type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
All arguments integer Integer
Numeric (some arguments can be integer) Numeric
Format
┌──
────────────┐
──FUNCTION MAX──(───/─argument-1─┴──)─────────────────────────────────────
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and
alphanumeric arguments is allowed.
The returned value is the content of argument-1 having the greatest value. The
comparisons used to determine the greatest value are made according to the rules
for simple conditions. For more information, see “Conditional expressions” on
page 214.
If more than one argument has the same greatest value, the leftmost argument
having that value is returned.
If the type of the function is alphanumeric, the size of the returned value is the
same as the size of the selected argument.
MEAN
The MEAN function returns a numeric value that approximates the arithmetic
average of its arguments.
The function type is numeric.
Format
┌──
────────────┐
──FUNCTION MEAN──(───/─argument-1─┴──)────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the arithmetic mean of the argument-1 series. The returned
value is defined as the sum of the argument-1 series divided by the number of
occurrences referenced by argument-1.
MEDIAN
The MEDIAN function returns the content of the argument whose value is the
middle value in the list formed by arranging the arguments in sorted order.
The function type is numeric.
Format
┌──
────────────┐
──FUNCTION MEDIAN──(───/─argument-1─┴──)──────────────────────────────────
argument-1
Must be class numeric.
The returned value is the content of argument-1 having the middle value in the list
formed by arranging all argument-1 values in sorted order.
If the number of occurrences referenced by argument-1 is odd, the returned value
is such that at least half of the occurrences referenced by argument-1 are greater
than or equal to the returned value and at least half are less than or equal. If the
number of occurrences referenced by argument-1 is even, the returned value is the
arithmetic mean of the values referenced by the two middle occurrences.
The comparisons used to arrange the argument values in sorted order are made
according to the rules for simple conditions. For more information, see
“Conditional expressions” on page 214.
MIDRANGE
The MIDRANGE function returns a numeric value that approximates the
arithmetic average of the values of the minimum argument and the maximum
argument.
The function type is numeric.
Format
┌──
────────────┐
──FUNCTION MIDRANGE──(───/─argument-1─┴──)────────────────────────────────
argument-1
Must be class numeric.
The returned value is the arithmetic mean of the value of the greatest argument-1
and the value of the least argument-1. The comparisons used to determine the
greatest and least values are made according to the rules for simple conditions.
For more information, see “Conditional expressions” on page 214.
MIN
The MIN function returns the content of the argument that contains the minimum
value.
The function type depends on the argument types, as follows:
Argument type Function type
Alphabetic Alphanumeric
Alphanumeric Alphanumeric
All arguments integer Integer
Numeric (some arguments can be integer) Numeric
Format
┌──
────────────┐
──FUNCTION MIN──(───/─argument-1─┴──)─────────────────────────────────────
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and
alphanumeric arguments is allowed.
The returned value is the content of argument-1 having the least value. The
comparisons used to determine the least value are made according to the rules for
simple conditions. For more information, see “Conditional expressions” on
page 214.
If more than one argument-1 has the same least value, the leftmost argument-1
having that value is returned.
If the type of the function is alphanumeric, the size of the returned value is the
same as the size of the selected argument-1.
MOD
The MOD function returns an integer value that is argument-1 modulo
argument-2.
The function type is integer.
The function result is an integer with as many digits as the shorter of argument-1
and argument-2.
Format
──FUNCTION MOD──(argument-1 argument-2)──────────────────────────────────
argument-1
Must be an integer.
argument-2
Must be an integer. Must not be zero.
The returned value is argument-1 modulo argument-2. The returned value is
defined as:
argument-1 - (argument-2 * FUNCTION INTEGER (argument-1 / argument-2))
The following table illustrates the expected results for some values of argument-1
and argument-2.
NUMVAL
The NUMVAL function returns the numeric value represented by the
alphanumeric character string specified in an argument. The function strips away
any leading or trailing blanks in the string, producing a numeric value that can be
used in an arithmetic expression.
The function type is numeric.
Format
──FUNCTION NUMVAL──(argument-1)──────────────────────────────────────────
argument-1
must be a nonnumeric literal or an alphanumeric data item whose content has
either of the following formats:
──┬───────┬──┬───┬──┬───────┬──┬─digit──┬──────────────┬─┬──┬───────┬────
└─space─┘ ├─+─┤ └─space─┘ │ └─.──┬───────┬─┘ │ └─space─┘
└─-─┘ │ └─digit─┘ │
└─.──digit────────────────┘
──┬───────┬──┬─digit──┬──────────────┬─┬──┬───────┬──┬────┬──┬───────┬───
└─space─┘ │ └─.──┬───────┬─┘ │ └─space─┘ ├─+──┤ └─space─┘
│ └─digit─┘ │ ├─-──┤
└─.──digit────────────────┘ ├─CR─┤
└─DB─┘
space
A string of one or more spaces.
digit
A string of one or more digits.
| If the ARITH(COMPAT) compiler option is in effect, then the total number of
| digits must not exceed 18. If the ARITH(EXTEND) compiler option is in effect,
| then the total number of digits must not exceed 31.
If the DECIMAL-POINT IS COMMA clause is specified in the SPECIAL-NAMES
paragraph, a comma must be used in argument-1 rather than a decimal point.
The returned value is an approximation of the numeric value represented by
argument-1.
NUMVAL-C
The NUMVAL-C function returns the numeric value represented by the
alphanumeric character string specified as argument-1. Any optional currency sign
specified by argument-2 and any optional commas preceding the decimal point are
stripped away, producing a numeric value that can be used in an arithmetic
expression.
The function type is numeric.
The NUMVAL-C function cannot be used if any of the following are true:
The program contains more than one CURRENCY SIGN clause in the
SPECIAL-NAMES paragraph of the Environment Division.
Literal-6 in the CURRENCY SIGN clause is a lowercase letter.
The PICTURE SYMBOL paragraph is specified in the CURRENCY SIGN
clause.
Format
──FUNCTION NUMVAL-C──(argument-1─┬────────────┬─)────────────────────────
└─argument-2─┘
argument-1
Must be a nonnumeric literal or an alphanumeric data item whose content has
either of the following formats:
──┬───────┬──┬───┬──┬───────┬──┬────┬──┬───────┬──────────────────────────
└─space─┘ ├─+─┤ └─space─┘ └─cs─┘ └─space─┘
└─-─┘
──┬─digit──┬──────────────┬──┬──────────────┬─┬──┬───────┬────────────────
│ │ ┌──
──────────┐ │ └─.──┬───────┬─┘ │ └─space─┘
│ └──/─,──digit─┴─┘ └─digit─┘ │
└─.──digit──────────────────────────────────┘
──┬───────┬──┬────┬──┬───────┬────────────────────────────────────────────
└─space─┘ └─cs─┘ └─space─┘
──┬─digit──┬──────────────┬──┬──────────────┬─┬──┬───────┬──┬────┬─────────
│ │ ┌──
──────────┐ │ └─.──┬───────┬─┘ │ └─space─┘ ├─+──┤
│ └──/─,──digit─┴─┘ └─digit─┘ │ ├─-──┤
└─.──digit──────────────────────────────────┘ ├─CR─┤
└─DB─┘
──┬───────┬───────────────────────────────────────────────────────────────
└─space─┘
space
A string of one or more spaces.
cs The string of one or more characters specified by argument-2. At most, one
copy of the characters specified by cs can occur in argument-1.
digit
A string of one or more digits.
| If the ARITH(COMPAT) compiler option is in effect, then the total number of
ORD
The ORD function returns an integer value that is the ordinal position of its
argument in the collating sequence for the program. The lowest ordinal position is
1.
The function type is integer.
The function result is a 3-digit integer.
Format
──FUNCTION ORD──(argument-1)─────────────────────────────────────────────
argument-1
Must be one character in length and must be class alphabetic or alphanumeric.
The returned value is the ordinal position of argument-1 in the collating sequence
for the program; it ranges from 1 to 256 depending on the collating sequence.
ORD-MAX
The ORD-MAX function returns a value that is the ordinal number position, in the
argument list, of the argument that contains the maximum value.
The function type is integer.
Format
┌──
────────────┐
──FUNCTION ORD-MAX──(───/─argument-1─┴──)─────────────────────────────────
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and
alphanumeric arguments is allowed.
The returned value is the ordinal number that corresponds to the position of
argument-1 having the greatest value in the argument-1 series.
The comparisons used to determine the greatest valued argument-1 are made
according to the rules for simple conditions. For more information, see
“Conditional expressions” on page 214.
If more than one argument-1 has the same greatest value, the number returned
corresponds to the position of the leftmost argument-1 having that value.
ORD-MIN
The ORD-MIN function returns a value that is the ordinal number of the argument
that contains the minimum value.
The function type is integer.
Format
┌──
────────────┐
──FUNCTION ORD-MIN──(───/─argument-1─┴──)─────────────────────────────────
argument-1
Must be class numeric, alphanumeric, or alphabetic.
If more than one argument-1 is specified, the combination of alphabetic and
alphanumeric arguments is allowed.
The returned value is the ordinal number that corresponds to the position of the
argument-1 having the least value in the argument-1 series.
The comparisons used to determine the least valued argument-1 are made
according to the rules for simple conditions. For more information, see
“Conditional expressions” on page 214.
If more than one argument-1 has the same least value, the number returned
corresponds to the position of the leftmost argument-1 having that value.
PRESENT-VALUE
The PRESENT-VALUE function returns a value that approximates the present
value of a series of future period-end amounts specified by argument-2 at a
discount rate specified by argument-1.
The function type is numeric.
Format
┌──
────────────┐
──FUNCTION PRESENT-VALUE──(argument-1───/─argument-2─┴──)─────────────────
argument-1
Must be class numeric. Must be greater than -1.
argument-2
Must be class numeric.
The returned value is an approximation of the summation of a series of
calculations with each term in the following form:
argument-2 / (1 + argument-1) ** n
There is one term for each occurrence of argument-2. The exponent, n, is
incremented from one by one for each term in the series.
RANDOM
The RANDOM function returns a numeric value that is a pseudorandom number
from a rectangular distribution.
The function type is numeric.
Format
──FUNCTION RANDOM──┬──────────────┬──────────────────────────────────────
└─(argument-1)─┘
argument-1
If argument-1 is specified, it must be zero or a positive integer, up to and
including (10**18)-1 which is the maximum value that can be specified in a
PIC9(18) fixed item; however, only those in the range from zero up to and
including 2,147,483,645 will yield a distinct sequence of pseudorandom
numbers.
If a subsequent reference specifies argument-1, a new sequence of pseudorandom
numbers is started.
If the first reference to this function in the run unit does not specify argument-1,
the seed value used will be zero.
In each case, subsequent references without specifying argument-1 return the next
number in the current sequence.
The returned value is exclusively between zero and one.
For a given seed value, the sequence of pseudorandom numbers will always be the
same.
RANGE
The RANGE function returns a value that is equal to the value of the maximum
argument minus the value of the minimum argument.
The function type depends on the argument types, as follows:
Argument type Function type
All arguments integer Integer
Numeric (some arguments can be integer) Numeric
Format
┌──
────────────┐
──FUNCTION RANGE──(───/─argument-1─┴──)───────────────────────────────────
argument-1
Must be class numeric.
The returned value is equal to argument-1 with the greatest value minus the
argument-1 with the least value. The comparisons used to determine the greatest
and least values are made according to the rules for simple conditions. For more
information, see “Conditional expressions” on page 214.
REM
The REM function returns a numeric value that is the remainder of argument-1
divided by argument-2.
The function type is numeric.
Format
──FUNCTION REM──(argument-1 argument-2)──────────────────────────────────
argument-1
Must be class numeric
argument-2
Must be class numeric. Must not be zero.
The returned value is the remainder of argument-1 divided by argument-2. It is
defined as the expression:
REVERSE
The REVERSE function returns a character string of exactly the same length of the
argument, whose characters are exactly the same as those specified in the
argument, except that they are in reverse order.
The function type is alphanumeric.
Format
──FUNCTION REVERSE──(argument-1)─────────────────────────────────────────
argument-1
Must be class alphabetic or alphanumeric and must be at least one character in
length.
If argument-1 is a character string of length n, the returned value is a character
string of length n such that, for 1 <= j <= n, the character in position j of the
returned value is the character from position n-j+1 of argument-1.
SIN
The SIN function returns a numeric value that approximates the sine of the angle
or arc specified by the argument in radians.
The function type is numeric.
Format
──FUNCTION SIN──(argument-1)─────────────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the approximation of the sine of argument-1 and is greater
than or equal to -1 and less than or equal to +1.
SQRT
The SQRT function returns a numeric value that approximates the square root of
the argument specified.
The function type is numeric.
Format
──FUNCTION SQRT──(argument-1)────────────────────────────────────────────
argument-1
Must be class numeric. The value of argument-1 must be zero or positive.
The returned value is the absolute value of the approximation of the square root of
argument-1.
STANDARD-DEVIATION
The STANDARD-DEVIATION function returns a numeric value that approximates
the standard deviation of its arguments.
The function type is numeric.
Format
┌──
────────────┐
──FUNCTION STANDARD-DEVIATION──(───/─argument-1─┴──)──────────────────────
argument-1
Must be class numeric.
The returned value is the approximation of the standard deviation of the
argument-1 series. The returned value is calculated as follows:
1. The difference between each argument-1 and the arithmetic mean of the
argument-1 series is calculated and squared.
2. The values obtained are then added together. This quantity is divided by the
number of values in the argument-1 series.
3. The square root of the quotient obtained is then calculated. The returned
value is the absolute value of this square root.
If the argument-1 series consists of only one value, or if the argument-1 series
consists of all variable occurrence data items and the total number of occurrences
for all of them is one, the returned value is zero.
SUM
The SUM function returns a value that is the sum of the arguments.
The function type depends on the argument types, as follows:
Argument type Function type
All arguments integer Integer
Numeric (some arguments can be integer) Numeric
Format
┌──
────────────┐
──FUNCTION SUM──(───/─argument-1─┴──)─────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the sum of the arguments. If the argument-1 series are all
integers, the value returned is an integer. If the argument-1 series are not all
integers, a numeric value is returned.
TAN
The TAN function returns a numeric value that approximates the tangent of the
angle or arc that is specified by the argument in radians.
The function type is numeric.
Format
──FUNCTION TAN──(argument-1)─────────────────────────────────────────────
argument-1
Must be class numeric.
The returned value is the approximation of the tangent of argument-1.
UNDATE
The UNDATE function converts a date field to a non-date for unambiguous use
with non-dates.
If the NODATEPROC compiler option is in effect, the UNDATE function has no
effect.
The function type depends on the type of argument-1:
Argument-1 type Function type
Alphanumeric Alphanumeric
Integer Integer
Format
──FUNCTION UNDATE──(argument-1)──────────────────────────────────────────
argument-1
A date field.
The returned value is a non-date that contains the value of argument-1 unchanged.
UPPER-CASE
The UPPER-CASE function returns a character string that is the same length as the
argument specified, with each lowercase letter replaced by the corresponding
uppercase letter.
The function type is alphanumeric.
Format
──FUNCTION UPPER-CASE──(argument-1)──────────────────────────────────────
argument-1
Must be class alphabetic or alphanumeric and must be at least one character in
length.
The same character string as argument-1 is returned, except that each lowercase
letter is replaced by the corresponding uppercase letter.
The character string returned has the same length as argument-1.
VARIANCE
The VARIANCE function returns a numeric value that approximates the variance
of its arguments.
The function type is numeric.
Format
┌──
────────────┐
──FUNCTION VARIANCE──(───/─argument-1─┴──)────────────────────────────────
argument-1
Must be class numeric.
The returned value is the approximation of the variance of the argument-1 series.
The returned value is defined as the square of the standard deviation of the
argument-1 series. This value is calculated as follows:
1. The difference between each argument-1 value and the arithmetic mean of the
argument-1 series is calculated and squared.
2. The values obtained are then added together. This quantity is divided by the
number of values in the argument series.
If the argument-1 series consists of only one value, or if the argument-1 series
consists of all variable occurrence data items and the total number of occurrences
for all of them is one, the returned value is zero.
WHEN-COMPILED
The WHEN-COMPILED function returns the date and time the program was
compiled as provided by the system on which the program was compiled.
The function type is alphanumeric.
Format
──FUNCTION WHEN-COMPILED─────────────────────────────────────────────────
Reading from left to right, the 21 character positions in the value returned can be
interpreted as follows:
Character
Positions Contents
1-4 Four numeric digits of the year in the Gregorian calendar.
5-6 Two numeric digits of the month of the year, in the range 01 through 12.
7-8 Two numeric digits of the day of the month, in the range 01 through 31.
9-10 Two numeric digits of the hours past midnight, in the range 00 through 23.
11-12 Two numeric digits of the minutes past the hour, in the range 00 through
59.
13-14 Two numeric digits of the seconds past the minute, in the range 00
through 59.
15-16 Two numeric digits of the hundredths of a second past the second, in the
range 00 through 99. The value 00 is returned if the system on which the
function is evaluated does not have the facility to provide the fractional
part of a second.
17 Either the character '-' or the character '+'. The character '-' is returned if
the local time indicated in the previous character positions is behind
Greenwich Mean Time. The character '+' is returned if the local time
indicated is the same as or ahead of Greenwich Mean Time. The character
'0' is returned if the system on which this function is evaluated does not
have the facility to provide the local time differential factor.
18-19 If character position 17 is '-', two numeric digits are returned in the range
00 through 12 indicating the number of hours that the reported time is
behind Greenwich Mean Time. If character position 17 is '+', two numeric
digits are returned in the range 00 through 13 indicating the number of
hours that the reported time is ahead of Greenwich Mean Time. If
character position 17 is '0', the value 00 is returned.
20-21 Two numeric digits are returned in the range 00 through 59 indicating the
number of additional minutes that the reported time is ahead of or behind
Greenwich Mean Time, depending on whether character position 17 is '+'
or '-', respectively. If character position 17 is '0', the value 00 is returned.
The returned value is the date and time of compilation of the source program that
contains this function. If the program is a contained program, the returned value
is the compilation date and time associated with the containing program.
YEAR-TO-YYYY
The YEAR-TO-YYYY function converts argument-1, a 2-digit year, to a 4-digit year.
Argument-2, when added to the year at the time of execution, defines the ending
year of a 100-year interval, or sliding century window, into which the year of
argument-1 falls.
The function type is integer.
If the DATEPROC compiler option is in effect, then the returned value is an
expanded date field with implicit DATE FORMAT YYYY.
Format
──FUNCTION YEAR-TO-YYYY──(argument-1─┬────────────┬─)────────────────────
└─argument-2─┘
argument-1
Must be a non-negative integer that is less than 100.
argument-2
Must be an integer. If argument-2 is omitted, the function is evaluated
assuming the value 50 was specified.
The sum of the year at the time of execution and the value of argument-2 must be
less than 10,000 and greater than 1,699.
Example
Two examples of return values from the YEAR-TO-YYYY function follow:
YEAR-TO-YYYY
Current year Argument-1 value Argument-2 value return value
1995 4 23 2004
1995 4 -15 1904
2008 98 23 1998
2008 98 -15 1898
YEARWINDOW
If the DATEPROC compiler option is in effect, the YEARWINDOW function
returns the starting year of the century window specified by the YEARWINDOW
compiler option. The returned value is an expanded date field with implicit DATE
FORMAT YYYY.
If the NODATEPROC compiler option is in effect, the YEARWINDOW function
returns 0.
The function type is integer.
Format
──FUNCTION YEARWINDOW────────────────────────────────────────────────────
Compiler-directing statements
A compiler-directing statement is a statement, beginning with a compiler directing
verb, that causes the compiler to take a specific action during compilation.
BASIS statement
The BASIS statement is an extended source program library statement. It provides
a complete COBOL program as the source for a compilation.
A complete program can be stored as an entry in a user's library and can be used
as the source for a compilation. Compiler input is a BASIS statement, optionally
followed by any number of INSERT and/or DELETE statements.
Format
──┬─────────────────┬──BASIS──┬─basis-name─┬─────────────────────────────
└─sequence-number─┘ └─literal-1──┘
sequence-number
Can optionally appear in columns 1 through 6, followed by a space. The
content of this field is ignored.
BASIS
Can appear anywhere in columns 1 through 72, followed by basis-name.
There must be no other text in the statement.
basis-name, literal-1
It is the name by which the library entry is known to the system environment.
For rules of formation and processing rules, see the description under literal-1
and text-name-1 of the “COPY statement” on page 468.
The source file remains unchanged after execution of the BASIS statement.
Note: If INSERT or DELETE statements are used to modify the COBOL source
program provided by a BASIS statement, the sequence field of the COBOL source
program must contain numeric sequence numbers in ascending order.
Format
──┬─CBL─────┬──┬──────────────┬──────────────────────────────────────────
└─PROCESS─┘ └─options-list─┘
options-list
A series of one or more compiler options, each one separated by a comma or a
space.
For more information on compiler options, see the IBM COBOL Programming
Guide for your platform.
The CBL (PROCESS) statement can be preceded by a sequence number in columns
1 through 6. The first character of the sequence number must be numeric, and
CBL or PROCESS can begin in column 8 or after; if a sequence number is not
specified, CBL or PROCESS can begin in column 1 or after.
The CBL (PROCESS) statement must end before or at column 72, and options
cannot be continued across multiple CBL (PROCESS) statements. However, you
can use more than one CBL (PROCESS) statement. If you use multiple CBL
(PROCESS) statements, they must follow one another with no intervening
statements of any other type.
The CBL (PROCESS) statement must be placed before any comment lines or other
compiler-directing statements.
Format
┌──
──────────────┐
──┬─VCONTROL─┬───/─┬─SOURCE───┬─┴──┬───┬──────────────────────────────────
└─VCBL─────┘ ├─NOSOURCE─┤ └─.─┘
├─LIST─────┤
├─NOLIST───┤
├─MAP──────┤
└─NOMAP────┘
For a complete discussion of the output produced by these options, see the IBM
COBOL Programming Guide for your platform.
The *CONTROL and *CBL statements are synonymous. Whenever *CONTROL is
used, *CBL is accepted as well.
The characters *CONTROL or *CBL can start in any column beginning with
column 7, followed by at least one space or comma and one or more option key
words. The option key words must be separated by one or more spaces or
commas. This statement must be the only statement on the line, and continuation
is not allowed. The statement can be terminated with a period.
The *CONTROL and *CBL statements must be embedded in a program source.
For example, in the case of batch applications, the *CONTROL and *CBL
statements must be placed between the PROCESS (CBL) statement and the end of
the program (or END PROGRAM header, if specified).
The source line containing the *CONTROL (*CBL) statement will not appear in the
source listing.
If an option is defined at installation as a fixed option, this fixed option takes
precedence over all of the following:
PARM (if available)
CBL statement
*CONTROL (*CBL) statement
The requested options are handled in the following manner:
1. If an option or its negation appears more than once in a *CONTROL
statement, the last occurrence of the option word is used.
2. If the CORRESPONDING option has been requested as a parameter to the
compiler, then a *CONTROL statement with the negation of the option word
must precede the portions of the source program for which listing output is to
be inhibited. Listing output then resumes when a *CONTROL statement with
the affirmative option word is encountered.
3. If the negation of the CORRESPONDING option has been requested as a
parameter to the compiler, then that listing is always inhibited.
4. The *CONTROL statement is in effect only within the source program in
which it is written, including any contained programs. It does not remain in
effect across batch compiles of two or more COBOL source programs.
COPY statement
The COPY statement is a library statement that places prewritten text in a COBOL
program.
Prewritten source program entries can be included in a source program at compile
time. Thus, an installation can use standard file descriptions, record descriptions,
or procedures without recoding them. These entries and procedures can then be
saved in user-created libraries; they can then be included in the source program by
means of the COPY statement.
Compilation of the source program containing COPY statements is logically
equivalent to processing all COPY statements before processing the resulting
source program.
The effect of processing a COPY statement is that the library text associated with
text-name is copied into the source program, logically replacing the entire COPY
statement, beginning with the word COPY and ending with the period, inclusive.
When the REPLACING phrase is not specified, the library text is copied
unchanged.
Format
──COPY──┬─text-name─┬──┬──────────────────────────┬──┬──────────┬─────────
└─literal-1─┘ └─┬─OF─┬──┬─library-name─┬─┘ └─SUPPRESS─┘
└─IN─┘ └─literal-2────┘
──┬─────────────────────────────────────────┬──.──────────────────────────
│ ┌──
──────────────────────────┐ │
└─REPLACING───/─operand-1──BY──operand-2─┴─┘
text-name, library-name
Text-name identifies the name of the copy text. Library-name identifies where
the copy text exists.
| Can be from 1-30 characters in length.
| Can contain characters: A-Z, a-z, 0-9, hyphen.
| The first character must be alphabetic.
| The last character must not be a hyphen.
| For OS/390 and VM, and compiling from JCL, TSO or VM/CMS,
| only the first eight characters are used as the identifying name. When
| compiling with the cob2 command and processing COPY text residing in the
| Hierarchical File System (HFS), all characters are significant.
literal-1, literal-2
Literal-1 identifies the name of the copy text. Literal-2 identifies where the
copy text exists.
| Under OS/390 and VM, when compiling from JCL, TSO or
| VM/CMS:
| Can be from 1-30 characters in length.
| Can contain characters: A-Z, a-z, 0-9, hyphen.
| The first character must be alphabetic.
| The last character must not be a hyphen.
| Only the first eight characters are used as the identifying name.
| When compiling with the cob2 command and processing COPY text residing
| in the HFS, the literal can be from 1-160 characters in length.
Note: Characters outside the standard COBOL character set must not appear in
library text or pseudo-text, other than as part of nonnumeric literals, comment
lines, or comment-entries.
DBCS words, DBCS literals, and EUC words are allowed in library text and
pseudo-text.
SUPPRESS phrase
The SUPPRESS phrase specifies that the library text is not to be printed on the
source program listing.
REPLACING phrase
In the discussion that follows, each operand can consist of one of the following:
Pseudo-text
An identifier
A literal
A COBOL word (except COPY)
Function identifier
When the REPLACING phrase is specified, the library text is copied, and each
properly matched occurrence of operand-1 within the library text is replaced by
the associated operand-2.
pseudo-text
A sequence of character-strings and/or separators bounded by, but not
including, pseudo-text-1 delimiters (==). Both characters of each pseudo-text-1
delimiter must appear on one line; however, character-strings within
pseudo-text-1 can be continued.
Any individual character-string within pseudo-text-1 can be up to 322
characters long. Keep in mind that a character-string must be delimited by
separators. For more information, see “Characters” on page 2.
Pseudo-text-1 refers to pseudo-text when used for operand-1, and
pseudo-text-2 refers to pseudo-text when used for operand-2.
Note: The colons serve as separators and make TAG a stand-alone operand.
9. When all operands have been compared and no match is found, the leftmost
library text word is copied into the source program.
10. The next successive uncopied library text word is then considered to be the
leftmost text word, and the comparison process is repeated, beginning with the
first operand-1. The process continues until the rightmost library text word
has been compared.
11. Comment lines or blank lines occurring in the library text and in pseudo-text-1
are ignored for purposes of matching; and the sequence of text words in the
library text and in pseudo-text-1 is determined by the rules for reference
format. Comment lines or blank lines appearing in pseudo-text-2 are copied
into the resultant program unchanged whenever pseudo-text-2 is placed into
the source program as a result of text replacement. Comment lines or blank
lines appearing in library text are copied into the resultant source program
unchanged with the following exception: a comment line or blank line in
library text is not copied if that comment line or blank line appears within the
sequence of text words that match pseudo-text-1.
12. Text words, after replacement, are placed in the source program according to
standard COBOL format rules.
13. COPY REPLACING does not affect the EJECT, SKIP1/2/3, or TITLE
compiler-directing statements. When text words are placed in the source
program, additional spaces are introduced only between text words where
there already exists a space (including the assumed space between source
lines).
Sequences of code (such as file and data descriptions, error and exception routines,
etc.) that are common to a number of programs can be saved in a library, and then
used in conjunction with the COPY statement. If naming conventions are
established for such common code, then the REPLACING phrase need not be
specified. If the names will change from one program to another, then the
REPLACING phrase can be used to supply meaningful names for this program.
The programmer can use the COPY statement in the Data Division of a program as
follows:
COPY PAYLIB.
In this program, the library text is copied; the resulting text is treated as if it had
been written as follows:
?1 A.
?2 B PIC S99.
?2 C PIC S9(5)V99.
?2 D PIC S9999 OCCURS 1 TO 52 TIMES
DEPENDING ON B OF A.
Example 2
To change some (or all) of the names within the library text, the programmer can
use the REPLACING phrase:
COPY PAYLIB REPLACING A BY PAYROLL
B BY PAY-CODE
C BY GROSS-PAY
D BY HOURS.
In this program, the library text is copied; the resulting text is treated as if it had
been written as follows:
?1 PAYROLL.
?2 PAY-CODE PIC S99.
?2 GROSS-PAY PIC S9(5)V99.
?2 HOURS PIC S9999 OCCURS 1 TO 52 TIMES
DEPENDING ON PAY-CODE OF PAYROLL.
The changes shown are made only for this program. The text, as it appears in the
library, remains unchanged.
Example 3
If the following conventions are followed in library text, then parts of names (for
example the prefix portion of data-names) can be changed with the REPLACING
phrase.
In this example, the library text PAYLIB consists of the following Data Division
entries:
?1 :TAG:.
?2 :TAG:-WEEK PIC S99.
?2 :TAG:-GROSS-PAY PIC S9(5)V99.
?2 :TAG:-HOURS PIC S999 OCCURS 1 TO 52 TIMES
DEPENDING ON :TAG:-WEEK OF :TAG:.
The programmer can use the COPY statement in the Data Division of a program as
follows:
COPY PAYLIB REPLACING ==:TAG:== BY ==Payroll==.
The changes shown are made only for this program. The text, as it appears in the
library, remains unchanged.
Example 4
This example shows how to selectively replace level numbers without replacing
the numbers in the PICTURE clause:
COPY xxx REPLACING ==(?1)== BY ==(?1)==
== ?1 == BY == ?5 ==.
DELETE statement
The DELETE statement is an extended source library statement. It removes
COBOL statements from the source program included by a BASIS statement.
Format
──┬─────────────────┬──DELETE──sequence-number-field─────────────────────
└─sequence-number─┘
sequence-number
Can optionally appear in columns 1 through 6, followed by a space. The
content of this field is ignored.
DELETE
Can appear anywhere within columns 1 through 72. It must be followed by a
space and the sequence-number-field. There must be no other text in the
statement.
sequence-number-field
Each number must be equal to a sequence-number in the BASIS source
program. This sequence-number is the 6-digit number the programmer assigns
in columns 1 through 6 of the COBOL coding form. The numbers referenced
in the sequence-number-fields of any INSERT or DELETE statements must
always be specified in ascending numeric order.
The sequence-number-field must be any one of the following:
A single number
A series of single numbers
A range of numbers (indicated by separating the two bounding numbers
of the range by a hyphen)
A series of ranges of numbers
Any combination of one or more single numbers and one or more ranges
of numbers
Note: If INSERT or DELETE statements are used to modify the COBOL source
program provided by a BASIS statement, the sequence field of the COBOL source
program must contain numeric sequence-numbers in ascending order. The source
file remains unchanged. Any INSERT or DELETE statements referring to these
sequence-numbers must occur in ascending order.
EJECT statement
The EJECT statement specifies that the next source statement is to be printed at the
top of the next page.
Format
──EJECT──┬───┬───────────────────────────────────────────────────────────
└─.─┘
The EJECT statement must be the only statement on the line. It can be written in
either Area A or Area B, and can be terminated with a separator period.
The EJECT statement must be embedded in a program source. For example, in the
case of batch applications, the EJECT statement must be placed between the CBL
(PROCESS) statement and the end of the program (or the END PROGRAM header,
if specified).
The EJECT statement has no effect on the compilation of the source program itself.
ENTER statement
The ENTER statement allows the use of more than one source language in the
same source program.
With COBOL for OS/390 & VM, COBOL Set for AIX, and VisualAge COBOL, only
COBOL is allowed in the source program.
Note: The ENTER statement is syntax checked during compilation but has no
effect on the execution of the program.
language-name-1
A system name that has no defined meaning. It must be either a correctly
formed user-defined word or the word "COBOL". At least one character must
be alphabetic.
routine-name-1
Must follow the rules for formation of a user-defined word. At least one
character must be alphabetic.
INSERT statement
The INSERT statement is a library statement that adds COBOL statements to the
source program included by a BASIS statement.
Format
──┬─────────────────┬──INSERT──sequence-number-field─────────────────────
└─sequence-number─┘
sequence-number
Can optionally appear in columns 1 through 6, followed by a space. The
content of this field is ignored.
INSERT
Can appear anywhere within columns 1 through 72, followed by a space and
the sequence-number-field. There must be no other text in the statement.
sequence-number-field
A number which must be equal to a sequence-number in the BASIS source
program. This sequence-number is the 6-digit number the programmer assigns
in columns 1 through 6 of the COBOL coding form.
The numbers referenced in the sequence-number-fields of any INSERT or
DELETE statements must always be specified in ascending numeric order.
The sequence-number-field must be a single number (for example, 000130). At
least one new source program statement must follow the INSERT statement for
insertion after the statement number specified by the sequence-number-field.
New source program statements following the INSERT statement can include
DBCS or EUC data items.
Note: If INSERT or DELETE statements are used to modify the COBOL source
program provided by a BASIS statement, the sequence field of the COBOL source
program must contain numeric sequence-numbers in ascending order. The source
file remains unchanged. Any INSERT or DELETE statements referring to these
sequence-numbers must occur in ascending order.
You can reproduce the function of READY TRACE by using the USE FOR
DEBUGGING declarative, DISPLAY statement, and DEBUG-ITEM special register.
For example:
.
.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-39? WITH DEBUGGING MODE.
.
DATA DIVISION.
.
WORKING-STORAGE SECTION.
?1 TRACE-SWITCH PIC 9 VALUE ?.
88 READY-TRACE VALUE 1.
88 RESET-TRACE VALUE ?.
.
PROCEDURE DIVISION.
DECLARATIVES.
COBOL-II-DEBUG SECTION.
USE FOR DEBUGGING ON ALL PROCEDURES.
COBOL-II-DEBUG-PARA.
IF READY-TRACE THEN
DISPLAY DEBUG-NAME
END-IF.
END DECLARATIVES.
MAIN-PROCESSING SECTION.
.
PARAGRAPH-3.
.
SET READY-TRACE TO TRUE.
PARAGRAPH-4.
.
PARAGRAPH-6.
.
SET RESET-TRACE TO TRUE.
PARAGRAPH-7.
where DEBUG-NAME is a field of the DEBUG-ITEM special register that displays
the procedure-name causing execution of the debugging procedure. (In this
example, the object program displays the names of procedures PARAGRAPH-4
through PARAGRAPH-6 as control reaches each procedure within the range.)
At run time, you must specify the DEBUG run-time option to activate this
debugging procedure. In this way, you have no need to recompile the program to
activate or deactivate the debugging declarative.
REPLACE statement
The REPLACE statement is used to replace source program text.
A REPLACE statement can occur anywhere in the source program where a
character-string can occur. It must be preceded by a separator period except when
it is the first statement in a separately compiled program. It must be terminated
by a separator period.
Format 1
┌──
──────────────────────────────────────────┐
──REPLACE───/─==pseudo-text-1==──BY──==pseudo-text-2==─┴──.───────────────
Format 2
──REPLACE OFF.───────────────────────────────────────────────────────────
Any text replacement currently in effect is discontinued with the format 2 form of
REPLACE. If format 2 is not specified, a given occurrence of the REPLACE
statement is in effect from the point at which it is specified until the next
occurrence of the statement or the end of the separately compiled program,
respectively.
pseudo-text-1
Must contain one or more text words. Character-strings can be continued.
As an IBM extension, pseudo-text-1 can consist entirely of a separator comma
or a separator semicolon.
pseudo-text-2
Can contain zero, one, or more text words. Character strings can be continued.
Any individual character-string within pseudo-text can be up to 322 characters
long.
Note: Characters outside the standard COBOL character set should not appear in
pseudo-text, other than as part of nonnumeric literals, comment lines, or
comment-entries.
The REPLACE statement can be used with DBCS literals and DBCS or EUC names.
Pseudo-text can contain DBCS or EUC character-strings, but the characters cannot
be continued across lines.
The compiler processes REPLACE statements in a source program after the
processing of any COPY statements. COPY must be processed first, to assemble a
complete source program. Then REPLACE can be used to modify that program,
performing simple string substitution. REPLACE statements can themselves
contain COPY statements.
The text produced as a result of the processing of a REPLACE statement must not
contain a REPLACE statement.
Comparison operation
The comparison operation to determine text replacement starts with the leftmost
source program text word following the REPLACE statement, and with the first
pseudo-text-1. Pseudo-text-1 is compared to an equivalent number of contiguous
source program text words. Pseudo-text-1 matches the source program text if, and
only if, the ordered sequence of text words that forms pseudo-text-1 is equal,
character for character, to the ordered sequence of source program text words.
For purposes of matching, each occurrence of a separator comma, semicolon, and
space, and each sequence of one or more space separators is considered to be a
single space.
However, when pseudo-text-1 consists solely of a separator comma or semicolon, it
participates in the match as a text word (in this case, the space following the
comma or semicolon separator can be omitted).
If no match occurs, the comparison is repeated with each successive occurrence of
pseudo-text-1, until either a match is found or there is no next successive
occurrence of pseudo-text-1.
When all occurrences of pseudo-text-1 have been compared and no match has
occurred, the next successive source program text word is then considered as the
leftmost source program text word, and the comparison cycle starts again with the
first occurrence of pseudo-text-1.
Whenever a match occurs between pseudo-text-1 and the source program text, the
corresponding pseudo-text-2 replaces the matched text in the source program. The
source program text word immediately following the rightmost text word that
participated in the match is then considered as the leftmost source program text
word. The comparison cycle starts again with the first occurrence of pseudo-text-1.
The comparison operation continues until the rightmost text word in the source
program text which is within the scope of the REPLACE statement has either
participated in a match or been considered as a leftmost source program text word
and participated in a complete comparison cycle.
Note: Each word in pseudo-text-2 that is to be placed into the resultant program
begins in the same area of the resultant program as it appears in pseudo-text-2.
Format
──SERVICE LABEL──────────────────────────────────────────────────────────
The SERVICE LABEL statement can appear only in the Procedure Division, not in
the Declaratives Section.
Format
──SERVICE RELOAD──identifier-1───────────────────────────────────────────
SKIP1/2/3 statements
The SKIP1/2/3 statements specify blank lines that the compiler should add when
printing the source listing. SKIP statements have no effect on the compilation of
the source program itself.
Format
──┬─SKIP1─┬──┬───┬───────────────────────────────────────────────────────
├─SKIP2─┤ └─.─┘
└─SKIP3─┘
SKIP1
Specifies a single blank line to be inserted in the source listing.
SKIP2
Specifies two blank lines to be inserted in the source listing.
SKIP3
Specifies three blank lines to be inserted in the source listing.
SKIP1, SKIP2, or SKIP3 can be written anywhere in either Area A or Area B, and
can be terminated with a separator period. It must be the only statement on the
line.
The SKIP1/2/3 statement must be embedded in a program source. For example,
in the case of batch applications, the SKIP1/2/3 statement must be placed between
the CBL (PROCESS) statement and the end of the program (or the END
PROGRAM header, if specified).
TITLE statement
The TITLE statement specifies a title to be printed at the top of each page of the
source listing produced during compilation. If no TITLE statement is found, a title
containing the identification of the compiler and the current release level is
generated. The title is left-justified on the title line.
Format
──TITLE──literal──┬───┬──────────────────────────────────────────────────
└─.─┘
literal
Must be nonnumeric and can be followed by a separator period.
Can be a DBCS or EUC literal.
Must not be a figurative constant.
In addition to the default or chosen title, the right side of the title line contains:
Name of the program from the PROGRAM-ID paragraph for the outermost
program (This space is blank on pages preceding the PROGRAM-ID paragraph
for the outermost program.)
Current page number
Date and time of compilation
The TITLE statement:
Forces a new page immediately, if the SOURCE compiler option is in effect
Is not printed on the source listing
Has no other effect on compilation
Has no effect on program execution
Cannot be continued on another line
Can appear anywhere in any of the divisions
A title line is produced for each page in the listing produced by the LIST option.
This title line uses the last TITLE statement found in the source statements or the
default.
The word TITLE can begin in either Area A or Area B.
The TITLE statement must be embedded in a program source. For example, in the
case of batch applications, the TITLE statement must be placed between the CBL
(PROCESS) statement and the end of the program (or the END PROGRAM header,
if specified).
No other statement can appear on the same line as the TITLE statement.
USE statement
The formats for the USE statement are:
EXCEPTION/ERROR declarative
LABEL declarative (OS/390 and VM Only)
DEBUGGING declarative
For general information on declaratives, see “Declaratives” on page 207.
file-name-1
Valid for all files. When this option is specified, the procedure is executed
only for the file(s) named. No file-name can refer to a sort or merge file. For
any given file, only one EXCEPTION/ERROR procedure can be specified; thus,
file-name specification must not cause simultaneous requests for execution of
more than one EXCEPTION/ERROR procedure.
A USE AFTER EXCEPTION/ERROR declarative statement specifying the name
of a file takes precedence over a declarative statement specifying the open
mode of the file.
INPUT
Valid for all files. When this option is specified, the procedure is executed for
all files opened in INPUT mode or in the process of being opened in INPUT
mode that get an error.
OUTPUT
Valid for all files. When this option is specified, the procedure is executed for
all files opened in OUTPUT mode or in the process of being opened in
OUTPUT mode that get an error.
I-O
Valid for all direct-access files. When this option is specified, the procedure is
executed for all files opened in I-O mode or in the process of being opened in
I-O mode that get an error.
EXTEND
Valid for all files. When this option is specified, the procedure is executed for
all files opened in EXTEND mode or in the process of being opened in
EXTEND mode that get an error.
The EXCEPTION/ERROR procedure is executed:
Either after completing the system-defined input/output error routine, or
Upon recognition of an INVALID KEY or AT END condition when an
INVALID KEY or AT END phrase has not been specified in the input/output
statement, or
Upon recognition of an IBM-defined condition that causes status key 1 to be
set to 9. (See “Status key” on page 244.)
LABEL declarative
The LABEL declarative provides user label-handling procedures.
AFTER
User labels follow standard file labels, and are to be processed.
The labels must be listed as data-names in the LABEL RECORDS clause in the
file description entry for the file, and must be described as level-01 data items
subordinate to the file entry.
If neither BEGINNING nor ENDING is specified, the designated procedures
are executed for both beginning and ending labels.
If FILE, REEL, or UNIT is not included, the designated procedures are
executed both for REEL or UNIT, whichever is appropriate, and for FILE
labels.
FILE
The designated procedures are executed at beginning-of-file (on the first
volume) and/or at end-of-file (on the last volume) only.
REEL
The designated procedures are executed at beginning-of-volume (on each
volume except the first) and/or at end-of-volume (on each volume except the
last).
The REEL option is not applicable to direct-access files.
UNIT
The designated procedures are executed at beginning-of-volume (on each
volume except the first) and/or at end-of-volume (on each volume except the
last).
DEBUGGING declarative
Debugging sections are permitted only in the outermost program; they are not
valid in nested programs. Debugging sections are never triggered by procedures
contained in nested programs.
Debugging sections are not permitted in:
A program or method defined with the RECURSIVE attribute
A program compiled with the THREAD compiler option (Workstation only)
The WITH DEBUGGING MODE clause of the SOURCE compiler statement
activates all debugging sections and lines that have been compiled into the object
program. See Appendix C, “Source language debugging” on page 504, for
additional details.
When the debugging mode is suppressed by not specifying that option of the
SOURCE compiler, any USE FOR DEBUGGING declarative procedures and all
debugging lines are inhibited.
Automatic execution of a debugging section is not caused by a statement
appearing in a debugging section.
Compiler directives
A compiler directive is a statement that causes the compiler to take a specific
action during compilation.
Currently, CALLINTERFACE is the only compiler directive supported.
CALLINTERFACE
The CALLINTERFACE directive specifies the interface convention for
CALL...USING statements. The convention specified stays in effect until another
CALLINTERFACE specification is made in the source program.
Under OS/390 and VM, the CALLINTERFACE directive is not
supported.
Format
──┬─>>CALLINTERFACE─┬──┬──────────┬──┬──────────────┬────────────────────
└─>>CALLINT───────┘ ├─SYSTEM───┤ ├─DESC─────────┤
├─OPTLINK──┤ ├─DESCRIPTOR───┤
├─FAR16────┤ ├─NODESC───────┤
├─PASCAL16─┤ └─NODESCRIPTOR─┘
└─CDECL────┘
Note: If you specify a suboption that is not applicable to the platform, the entire
CALLINTERFACE directive is ignored for that platform. For example, if
you specify >>CALLINT CDECL for an AIX program, it is ignored.
For more information on which suboptions are in effect for multiple
directive and compiler option specifications, see “Precedence of
sub-options” on page 490.
SYSTEM
Specifies that the system linkage convention of the platform is used as the call
interface convention.
OPTLINK
Specifies that the _Optlink calling convention as defined by C Set++ is used as
the call interface convention.
CDECL
Specifies that the CDECL calling convention as defined by Microsoft Visual
C++ is used as the call interface convention.
Precedence of sub-options
If you specify both the CALLINTERFACE directive (with suboptions) and the
CALLINT compiler option, the directive overrides the compiler option specification
for the statements following the directive within a source program.
If you specify the CALLINTERFACE directive without any suboptions, the
CALLINT compiler option specification is in effect.
If you specify only the DESC/NODESC suboption, the calling convention in effect
is the convention specified in the CALLINT compiler option. (DESC/NODESC are
options only for the CALLINTERFACE directive. They are not available in the
CALLINT compiler option.) For example, if the CALLINT compiler option is set
to CALLINT SYSTEM, given the following directives:
Note: If you include a COPY statement as a debugging line, the “D” must appear
on the first line of the COPY statement. IBM COBOL treats the copied text as the
debugging line or lines. The COPY statement is executed, regardless of whether
WITH DEBUGGING MODE is specified or not.
|Note: Under OS/390 and VM, you can change which reserved word table is used by using
|the WORD compiler option. For details on how to specify an alternate reserved word table, see the IBM
|COBOL for OS/390 & VM Programming Guide.
Table 57 (Page 1 of 6). Reserved words Table 57 (Page 1 of 6). Reserved words
IBM Standard IBM Standard
Reserved word COBOL only RFD Reserved word COBOL only RFD
ACCEPT X AUTHOR X
ACCESS X AUTOMATIC 1 X
ADD X B-AND X
ADDRESS X B-EXOR X
ADVANCING X B-LESS X
AFTER X B-NOT X
ALL X B-OR X
ALLOWING X BASIS X
ALPHABET X BEFORE X
ALPHABETIC X BEGINNING X
ALPHABETIC-LOWER X BINARY X
ALPHABETIC-UPPER X BIT X
ALPHANUMERIC X BITS X
ALPHANUMERIC-EDITED X BLANK X
ALSO X BLOCK X
ALTER X BOOLEAN X
ALTERNATE X BOTTOM X
AND X BY X
ANY X CALL X
APPLY X CANCEL X
ARE X CBL X
AREA X CD X
AREAS X CF X
ARITHMETIC X CH X
ASCENDING X CHARACTER X
ASSIGN X CHARACTERS X
AT X CLASS X
Note: In the following discussion, the information given for STANDARD-1 also
applies to STANDARD-2 except where otherwise specified.
The following paragraphs discuss the special considerations concerning ASCII- (or
ISCII-) encoded files.
Environment Division
In the Environment Division, the OBJECT-COMPUTER, SPECIAL-NAMES, and
FILE-CONTROL paragraphs are affected.
FILE-CONTROL paragraph
For ASCII files, the ASSIGN clause assignment-name has the following formats:
Format—QSAM file
──┬─────────┬──┬─────┬──name────────────────────────────────────────────────────────────────────
└─label- ─┘ └─S- ─┘
I-O-CONTROL paragraph
The assignment-name in a RERUN clause must not specify an ASCII-encoded file.
ASCII-encoded files containing checkpoint records cannot be processed.
Data Division
In the Data Division, there are special considerations for the FD entry and for data
description entries.
For each logical file defined in the Environment Division, there must be a
corresponding FD entry and level-01 record description entry in the File Section of
the Data Division.
FD Entry—CODE-SET clause
Procedure Division
An ASCII collated sort/merge operation can be specified in two ways:
Through the PROGRAM COLLATING SEQUENCE clause in the
OBJECT-COMPUTER paragraph.
In this case, the ASCII collating sequence is used for nonnumeric comparisons
explicitly specified in relation conditions and condition-name conditions.
Through the COLLATING SEQUENCE phrase of the SORT or MERGE
statement.
In this case, only this sort/merge operation uses the ASCII collating sequence.
In either case, alphabet-name must be associated with STANDARD-1 (for ASCII
collating sequence) in the SPECIAL-NAMES paragraph.
For this sort/merge operation, the COLLATING SEQUENCE option takes
precedence over the PROGRAM COLLATING SEQUENCE clause.
If both the PROGRAM COLLATING SEQUENCE clause and the COLLATING
SEQUENCE phrase are omitted (or if the one in effect specifies an EBCDIC
collating sequence), the sort/merge is performed using the EBCDIC collating
sequence.
Table 58 (Page 1 of 2). Language difference between mainframe and workstation IBM COBOL
Language element Implementation
ACCEPT statement Under AIX and Windows, environment-name determines file identification.
APPLY WRITE-ONLY clause Syntax checked, but has no effect on the execution of the program under
AIX and Windows.
ASSIGN clause Different syntax for the ASSIGNment name. ASSIGN...USING data-name is
not supported under OS/390 and VM.
CALL statement A file-name as a CALL argument is not supported under AIX and
Windows.
CLOSE statement The following phrases are syntax checked, but have no effect on the
execution of the program under AIX and Windows: FOR REMOVAL, WITH
NO REWIND, and UNIT/REEL.
CODE-SET clause Syntax checked, but has no effect on the execution of the program under
AIX and Windows.
DISPLAY statement Under AIX and Windows, environment-name determines file identification.
File status data-name-1 Some values and meanings for file status 9x are different under OS/390 and
VM than under AIX and Windows.
File status data-name-8 The format and values are different depending on the platform and the file
system.
LABEL RECORD clause LABEL RECORD IS data-name, USE...AFTER...LABEL PROCEDURE, and
GO TO MORE-LABELS are syntax checked, but have no effect on the
execution of the program under AIX and Windows. These language
elements are processed by the compiler; however, the user label declaratives
are not called at run time.
MULTIPLE FILE TAPE Syntax checked, but has no effect on the execution of the program under
AIX and Windows. On the workstation, all files are treated as single
volume files.
OPEN statement The following phrases are syntax checked, but have no effect on the
execution of the program under AIX and Windows: REVERSED and WITH
NO REWIND.
PASSWORD clause Syntax checked, but has no effect on the execution of the program under
AIX and Windows.
POINTER and Under COBOL for OS/390 & VM, a POINTER data item is defined as 4
PROCEDURE-POINTER data items bytes; a PROCEDURE-POINTER data item is defined as 8 bytes. Under
AIX and Windows, the size of these data items are consistent with the
native pointer definition of the platform (4 bytes for 32-bit machines and 8
bytes for 64-bit machines).
Appendix G. Summary of language difference: host COBOL and workstation COBOL 517
Industry specifications
Notices
This information was developed for products and services offered in the U.S.A. IBM may
not offer the products, services, or features discussed in this document in other countries.
Consult your local IBM representative for information on the products and services
currently available in your area. Any reference to an IBM product, program, or service is
not intended to state or imply that only that IBM product, program, or service may be used.
Any functionally equivalent product, program, or service that does not infringe any IBM
intellectual property right may be used instead. However, it is the user's responsibility to
evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in
this document. The furnishing of this document does not give you any license to these
patents. You can send license inquiries, in writing, to:
IBM Corporation
J74/G4
555 Bailey Avenue
P.O. Box 49023
San Jose, CA 95161-9023
U.S.A.
For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual
Property Department in your country or send inquiries, in writing, to:
The following paragraph does not apply to the United Kingdom or any other country
where such provisions are inconsistent with local law:INTERNATIONAL BUSINESS
MACHINES CORPORATION PROVIDES THIS PUBLICATION “AS IS” WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not
allow disclaimer of express or implied warranties in certain transactions, therefore, this
statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are
periodically made to the information herein; these changes will be incorporated in new
editions of the publication. IBM may make improvements and/or changes in the product(s)
and/or the program(s) described in this publication at any time without notice.
Any references in this publication to non-IBM Web sites are provided for convenience only
and do not in any manner serve as an endorsement of those Web sites. The materials at
those Web sites are not part of the materials for this IBM product and use of those Web
sites is at your own risk.
Trademarks
The following terms are trademarks of International Business Machines Corporation in the
United States, or other countries, or both:
Advanced Function Printing IMS/ESA
AFP MVS
AIX OS/390
AIX/6000 Print Services Facility
BookManager SOM
CICS SOMobjects
CICS/ESA VisualAge
DATABASE 2 VM/ESA
DB2
DFSORT
IBM
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft
Corporation in the United States and/or other countries.
UNIX is a registered trademark in the United States and/or other countries licensed
exclusively through X/Open Company Limited.
Other company, product, and service names may be trademarks or service marks of others.
Notices 521
Bibliography
Bibliography 523
IBM VisualAge COBOL
Fact Sheet, GC26-9052
Getting Started on Windows, GC26-8944
Language Reference, SC26-9046
Programming Guide, SC26-9050
Visual Builder User's Guide, SC26-9053
IBM COBOL Millennium Language Extensions Guide, GC26-9266
To view the latest IBM COBOL product publications in Acrobat PDF format, visit the IBM
COBOL Family home page on the World Wide Web at:
http://www.ibm.com/software/ad/cobol/
* block. A physical unit of data that is normally * character. The basic indivisible unit of the language.
composed of one or more logical records. For mass character position. The amount of physical storage
storage files, a block can contain a portion of a logical required to store a single standard data format
record. The size of a block has no direct relationship to character described as USAGE IS DISPLAY.
the size of the file within which the block is contained
or to the size of the logical record(s) that are either character set. All the valid characters for a
contained within the block or that overlap the block. programming language or a computer system.
The term is synonymous with physical record. * character-string. A sequence of contiguous
breakpoint. A place in a computer program, usually characters that form a COBOL word, a literal, a
specified by an instruction, where its execution may be PICTURE character-string, or a comment-entry. Must
interrupted by external intervention or by a monitor be delimited by separators.
program. checkpoint. A point at which information about the
Btrieve. A key-indexed record management system status of a job and the system can be recorded so that
that allows applications to manage records by key the job step can be later restarted.
value, sequential access method, or random access * class. The entity that defines common behavior and
method. IBM COBOL supports COBOL sequential and implementation for zero, one, or more objects. The
indexed file I-O language through Btrieve. objects that share the same implementation are
considered to be objects of the same class.
Glossary 527
— The subordinate date field has DATE FORMAT language-specific generated code or language library
YY. code.
— The group date field has DATE FORMAT * condition. A status of a program at run time for
YYYYXXXX and the subordinate date field has which a truth value can be determined. Where the
DATE FORMAT YYXX. term ‘condition’ (condition-1, condition-2,...) appears in
Procedure Division these language specifications in or in reference to
Two date fields are compatible if they have the ‘condition’ (condition-1, condition-2,...) of a general
same date format except for the year part, which format, it is a conditional expression consisting of
may be windowed or expanded. For example, a either a simple condition optionally parenthesized, or a
windowed date field with DATE FORMAT YYXXX combined condition consisting of the syntactically
is compatible with: correct combination of simple conditions, logical
— Another windowed date field with DATE operators, and parentheses, for which a truth value can
FORMAT YYXXX be determined.
— An expanded date field with DATE FORMAT * conditional expression. A simple condition or a
YYYYXXX complex condition specified in an EVALUATE, IF,
* compile. (1) To translate a program expressed in a PERFORM, or SEARCH statement. (See also “simple
high-level language into a program expressed in an condition” and “complex condition.”)
intermediate language, assembly language, or a * conditional phrase. A conditional phrase specifies
computer language. (2) To prepare a machine the action to be taken upon determination of the truth
language program from a computer program written in value of a condition resulting from the execution of a
another programming language by making use of the conditional statement.
overall logic structure of the program, or generating
more than one computer instruction for each symbolic * conditional statement. A statement specifying that
statement, or both, as well as performing the function the truth value of a condition is to be determined and
of an assembler. that the subsequent action of the object program is
dependent on this truth value.
* compile time. The time at which a COBOL source
program is translated, by a COBOL compiler, to a * conditional variable. A data item one or more
COBOL object program. values of which has a condition-name assigned to it.
compiler. A program that translates a program * condition-name. A user-defined word that assigns a
written in a higher level language into a machine name to a subset of values that a conditional variable
language object program. may assume; or a user-defined word assigned to a
status of an implementor defined switch or device.
compiler directing statement. A statement, beginning When ‘condition-name’ is used in the general formats,
with a compiler directing verb, that causes the compiler it represents a unique data item reference consisting of
to take a specific action during compilation. a syntactically correct combination of a
compiler directing statement. A statement that ‘condition-name’, together with qualifiers and
specifies actions to be taken by the compiler during subscripts, as required for uniqueness of reference.
processing of a COBOL source program. Compiler * condition-name condition. The proposition, for
directives are contained in the COBOL source program. which a truth value can be determined, that the value
Thus, you can specify different suboptions of the of a conditional variable is a member of the set of
directive within the source program by using multiple values attributed to a condition-name associated with
compiler directive statements in the program. the conditional variable.
* complex condition. A condition in which one or * Configuration Section. A section of the
more logical operators act upon one or more Environment Division that describes overall
conditions. (See also “negated simple condition,” specifications of source and object programs and class
“combined condition,” and “negated combined definitions.
condition.”)
CONSOLE. A COBOL environment-name associated
* computer-name. A system-name that identifies the with the operator console.
computer upon which the program is to be compiled or
run. * contiguous items. Items that are described by
consecutive entries in the Data Division, and that bear
condition. An exception that has been enabled, or a definite hierarchic relationship to each other.
recognized, by Language Environment and thus is
eligible to activate user and language condition copybook. A file or library member containing a
handlers. Any alteration to the normal programmed sequence of code that is included in the source
flow of an application. Conditions can be detected by program at compile time using the COPY statement.
the hardware/operating system and results in an The file can be created by the user, supplied by
interrupt. They can also be detected by COBOL, or supplied by another product.
Glossary 529
followed by the key words END DECLARATIVES. A In COBOL, a TEST BEFORE phrase used with the
declarative is composed of a section header, followed PERFORM statement functions in the same way.
by a USE compiler directing sentence, followed by a set
Double-Byte Character Set (DBCS). A set of
of zero, one, or more associated paragraphs.
characters in which each character is represented by
* de-edit. The logical removal of all editing characters two bytes. Languages such as Japanese, Chinese, and
from a numeric-edited data item in order to determine Korean, which contain more symbols than can be
that item's unedited numeric value. represented by 256 code points, require Double-Byte
Character Sets. Because each character requires two
* delimited scope statement. Any statement that
bytes, entering, displaying, and printing DBCS
includes its explicit scope terminator.
characters requires hardware and supporting software
* delimiter. A character or a sequence of contiguous that are DBCS-capable.
characters that identify the end of a string of characters
* dynamic access. An access mode in which specific
and separate that string of characters from the
logical records can be obtained from or placed into a
following string of characters. A delimiter is not part
mass storage file in a nonsequential manner and
of the string of characters that it delimits.
obtained from a file in a sequential manner during the
* descending key. A key upon the values of which scope of the same OPEN statement.
data is ordered starting with the highest value of key
Dynamic Storage Area (DSA). Dynamically acquired
down to the lowest value of key, in accordance with
storage composed of a register save area and an area
the rules for comparing data items.
available for dynamic storage allocation (such as
digit. Any of the numerals from 0 through 9. In program variables). DSAs are generally allocated
COBOL, the term is not used in reference to any other within STACK segments managed by Language
symbol. Environment.
* digit position. The amount of physical storage
required to store a single digit. This amount may vary E
depending on the usage specified in the data
description entry that defines the data item. * EBCDIC (Extended Binary-Coded Decimal
Interchange Code). A coded character set consisting
* direct access. The facility to obtain data from storage of 8-bit coded characters.
devices or to enter data into a storage device in such a
way that the process depends only on the location of EBCDIC character. Any one of the symbols included
that data and not on a reference to data previously in the 8-bit EBCDIC (Extended Binary-Coded-Decimal
accessed. Interchange Code) set.
* division. A collection of zero, one or more sections edited data item. A data item that has been modified
or paragraphs, called the division body, that are by suppressing zeroes and/or inserting editing
formed and combined in accordance with a specific set characters.
of rules. Each division consists of the division header * editing character. A single character or a fixed
and the related division body. There are four (4) 2-character combination belonging to the following set:
divisions in a COBOL program: Identification,
Environment, Data, and Procedure. Character Meaning
␣ space
* division header. A combination of words followed 0 zero
by a separator period that indicates the beginning of a + plus
division. The division headers are: − minus
IDENTIFICATION DIVISION. CR credit
ENVIRONMENT DIVISION. DB debit
DATA DIVISION. Z zero suppress
PROCEDURE DIVISION. * check protect
$ currency sign
do construction. In structured programming, a DO , comma (decimal point)
statement is used to group a number of statements in a . period (decimal point)
procedure. In COBOL, an in-line PERFORM statement / slant (virgule, slash)
functions in the same way.
element (text element). One logical unit of a string of
do-until. In structured programming, a do-until loop text, such as the description of a single data item or
will be executed at least once, and until a given verb, preceded by a unique code identifying the
condition is true. In COBOL, a TEST AFTER phrase element type.
used with the PERFORM statement functions in the
same way. * elementary item. A data item that is described as
not being further logically subdivided.
do-while. In structured programming, a do-while loop
will be executed if, and while, a given condition is true.
* entry. Any descriptive set of consecutive clauses * external data. The data described in a program as
terminated by a separator period and written in the external data items and external file connectors.
Identification Division, Environment Division, or Data * external data item. A data item which is described
Division of a COBOL program. as part of an external record in one or more programs
* environment clause. A clause that appears as part of of a run unit and which itself may be referenced from
an Environment Division entry. any program in which it is described.
Environment Division. One of the four main * external data record. A logical record which is
component parts of a COBOL program, class definition, described in one or more programs of a run unit and
or method definition. The Environment Division whose constituent data items may be referenced from
describes the computers upon which the source any program in which they are described.
program is compiled and those on which the object external decimal item. A format for representing
program is executed, and provides a linkage between numbers in which the digit is contained in bits 4
the logical concept of files and their records, and the through 7 and the sign is contained in bits 0 through 3
physical aspects of the devices on which files are of the rightmost byte. Bits 0 through 3 of all other
stored. bytes contain 1’s (hex F). For example, the decimal
environment-name. A name, specified by IBM, that value of +123 is represented as 1111 0001 1111 0010
identifies system logical units, printer and card punch 1111 0011. (Also know as “zoned decimal item.”)
control characters, report codes, and/or program * external file connector. A file connector which is
switches. When an environment-name is associated accessible to one or more object programs in the run
with a mnemonic-name in the Environment Division, unit.
the mnemonic-name may then be substituted in any
format in which such substitution is valid. external floating-point item. A format for
representing numbers in which a real number is
environment variable. Any of a number of variables represented by a pair of distinct numerals. In a
that describe the way an operating system is going to floating-point representation, the real number is the
run and the devices it is going to recognize. product of the fixed-point part (the first numeral), and
execution time. See “run time.” a value obtained by raising the implicit floating-point
base to a power denoted by the exponent (the second
execution-time environment. See “run-time numeral).
environment.”
For example, a floating-point representation of the
expanded date field. A date field containing an number 0.0001234 is: 0.1234 -3, where 0.1234 is the
expanded (4-digit) year. See also “date field” and mantissa and -3 is the exponent.
“expanded year.”
Glossary 531
* external switch. A hardware or software device, * fixed file attributes. Information about a file which
defined and named by the implementor, which is used is established when a file is created and cannot
to indicate that one of two alternate states exists. subsequently be changed during the existence of the
file. These attributes include the organization of the
file (sequential, relative, or indexed), the prime record
F key, the alternate record keys, the code set, the
minimum and maximum record size, the record type
* figurative constant. A compiler-generated value
(fixed or variable), the collating sequence of the keys
referenced through the use of certain reserved words.
for indexed files, the blocking factor, the padding
* file. A collection of logical records. character, and the record delimiter.
* file attribute conflict condition. An unsuccessful * fixed length record. A record associated with a file
attempt has been made to execute an input-output whose file description or sort-merge description entry
operation on a file and the file attributes, as specified requires that all records contain the same number of
for that file in the program, do not match the fixed character positions.
attributes for that file.
fixed-point number. A numeric data item defined
* file clause. A clause that appears as part of any of with a PICTURE clause that specifies the location of an
the following DATA DIVISION entries: file description optional sign, the number of digits it contains, and the
entry (FD entry) and sort-merge file description entry location of an optional decimal point. The format may
(SD entry). be either binary, packed decimal, or external decimal.
* file connector. A storage area which contains floating-point number. A numeric data item
information about a file and is used as the linkage containing a fraction and an exponent. Its value is
between a file-name and a physical file and between a obtained by multiplying the fraction by the base of the
file-name and its associated record area. numeric data item raised to the power specified by the
exponent.
File-Control. The name of an ENVIRONMENT
DIVISION paragraph in which the data files for a given * format. A specific arrangement of a set of data.
source program are declared.
* function. A temporary data item whose value is
* file control entry. A SELECT clause and all its determined at the time the function is referenced
subordinate clauses which declare the relevant physical during the execution of a statement.
attributes of a file.
* function-identifier. A syntactically correct
* file description entry. An entry in the File Section of combination of character-strings and separators that
the Data Division that is composed of the level references a function. The data item represented by a
indicator FD, followed by a file-name, and then function is uniquely identified by a function-name with
followed by a set of file clauses as required. its arguments, if any. A function-identifier may
include a reference-modifier. A function-identifier that
* file-name. A user-defined word that names a file
references an alphanumeric function may be specified
connector described in a file description entry or a
anywhere in the general formats that an identifier may
sort-merge file description entry within the File Section
be specified, subject to certain restrictions. A
of the Data Division.
function-identifier that references an integer or numeric
* file organization. The permanent logical file function may be referenced anywhere in the general
structure established at the time that a file is created. formats that an arithmetic expression may be specified.
*file position indicator. A conceptual entity that function-name. A word that names the mechanism
contains the value of the current key within the key of whose invocation, along with required arguments,
reference for an indexed file, or the record number of determines the value of a function.
the current record for a sequential file, or the relative
record number of the current record for a relative file,
or indicates that no next logical record exists, or that an G
optional input file is not present, or that the at end * global name. A name which is declared in only one
condition already exists, or that no valid next record program but which may be referenced from that
has been established. program and from any program contained within that
* File Section. The section of the Data Division that program. Condition-names, data-names, file-names,
contains file description entries and sort-merge file record-names, report-names, and some special registers
description entries together with their associated record may be global names.
descriptions. * group item. A data item that is composed of
file system. The collection of files and file subordinate data items.
management structures on a physical or logical mass
storage device, such as a diskette or minidisk.
Glossary 533
(2) A numeric data item defined in the Data Division * intra-record data structure. The entire collection of
that does not include any digit positions to the right of groups and elementary data items from a logical record
the decimal point. which is defined by a contiguous subset of the data
description entries which describe that record. These
(3) A numeric function whose definition provides that data description entries include all entries whose
all digits to the right of the decimal point are zero in level-number is greater than the level-number of the
the returned value for any possible evaluation of the first data description entry describing the intra-record
function. data structure.
integer function. A function whose category is intrinsic function. A pre-defined function, such as a
numeric and whose definition does not include any commonly used arithmetic function, called by a built-in
digit positions to the right of the decimal point. function reference.
interface. The information that a client must know to * invalid key condition. A condition, at object time,
use a class—the names of its attributes and the caused when a specific value of the key associated with
signatures of its methods. With direct-to-SOM compilers an indexed or relative file is determined to be invalid.
such as COBOL, the interface to a class may be defined
by native language syntax for class definitions. Classes * I-O-CONTROL. The name of an Environment
implemented in other languages might have their Division paragraph in which object program
interfaces defined directly in SOM Interface Definition requirements for rerun points, sharing of same areas by
Language (IDL). The COBOL compiler has a compiler several data files, and multiple file storage on a single
option, IDLGEN, to automatically generate IDL for a input-output device are specified.
COBOL class. * I-O-CONTROL entry. An entry in the
Interface Definition Language (IDL). The formal I-O-CONTROL paragraph of the Environment Division
language (independent of any programming language) which contains clauses that provide information
by which the interface for a class of objects is defined in required for the transmission and handling of data on
a IDL file, which the SOM compiler then interprets to named files during the execution of a program.
create an implementation template file and binding * I-O-Mode. The state of a file after execution of an
files. SOM's Interface Definition Language is fully OPEN statement, with the I-O phrase specified, for that
compliant with standards established by the Object file and before the execution of a CLOSE statement
Management Group's Common Object Request Broker without the REEL or UNIT phase for that file.
Architecture (CORBA).
* I-O status. A conceptual entity which contains the
interlanguage communication (ILC). The ability of 2-character value indicating the resulting status of an
routines written in different programming languages to input-output operation. This value is made available to
communicate. ILC support allows the application the program through the use of the FILE STATUS
writer to readily build applications from component clause in the file control entry for the file.
routines written in a variety of languages.
iteration structure. A program processing logic in
intermediate result. An intermediate field containing which a series of statements is repeated while a
the results of a succession of arithmetic operations. condition is true or until a condition is true.
* internal data. The data described in a program
excluding all external data items and external file
connectors. Items described in the Linkage Section of a K
program are treated as internal data. K. When referring to storage capacity, two to the
* internal data item. A data item which is described tenth power; 1024 in decimal notation.
in one program in a run unit. An internal data item * key. A data item that identifies the location of a
may have a global name. record, or a set of data items which serve to identify
internal decimal item. A format in which each byte in the ordering of data.
a field except the rightmost byte represents two * key of reference. The key, either prime or alternate,
numeric digits. The rightmost byte contains one digit currently being used to access records within an
and the sign. For example, the decimal value +123 is indexed file.
represented as 0001 0010 0011 1111. (Also known as
packed decimal.) * key word. A reserved word or function-name whose
presence is required when the format in which the
* internal file connector. A file connector which is word appears is used in a source program.
accessible to only one object program in the run unit.
kilobyte (KB). One kilobyte equals 1024 bytes.
* letter. A character belonging to one of the following * logical record. The most inclusive data item. The
two sets: level-number for a record is 01. A record may be
either an elementary item or a group of items. The
1. Uppercase letters: A, B, C, D, E, F, G, H, I, J, K, L,
term is synonymous with record.
M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
2. Lowercase letters: a, b, c, d, e, f, g, h, i, j, k, l, m, n, * low order end. The rightmost character of a string of
o, p, q, r, s, t, u, v, w, x, y, z characters.
Linkage Section. The section in the Data Division of * Method Definition. The COBOL source unit that
the called program that describes data items available defines a method.
from the calling program. These data items may be * method identification entry. An entry in the
referred to by both the calling and called program. METHOD-ID paragraph of the Identification Division
literal. A character-string whose value is specified which contains clauses that specify the method-name
either by the ordered set of characters comprising the and assign selected attributes to the method definition.
string, or by the use of a figurative constant. * method-name. A user-defined word that identifies a
locale. A set of attributes for a program execution method.
environment indicating culturally sensitive
Glossary 535
* mnemonic-name. A user-defined word that is * nonnumeric literal. A literal bounded by quotation
associated in the Environment Division with a specified marks. The string of characters may include any
implementor-name. character in the computer’s character set.
multitasking. Mode of operation that provides for the null. Figurative constant used to assign the value of
concurrent, or interleaved, execution of two or more an invalid address to pointer data items. NULLS can
tasks. When running under the Language Environment be used wherever NULL can be used.
product, multitasking is synonymous with
* numeric character. A character that belongs to the
multithreading.
following set of digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
numeric-edited item. A numeric item that is in such a
N form that it may be used in printed output. It may
name. A word composed of not more than 30 consist of external decimal digits from 0 through 9, the
characters that defines a COBOL operand. decimal point, commas, the dollar sign, editing sign
control symbols, plus other editing symbols.
* native character set. The implementor-defined
character set associated with the computer specified in * numeric function. A function whose class and
the OBJECT-COMPUTER paragraph. category are numeric but which for some possible
evaluation does not satisfy the requirements of integer
* native collating sequence. The implementor-defined functions.
collating sequence associated with the computer
specified in the OBJECT-COMPUTER paragraph. * numeric item. A data item whose description
restricts its content to a value represented by characters
* negated combined condition. The ‘NOT’ logical chosen from the digits from ‘0’ through ‘9’; if signed,
operator immediately followed by a parenthesized the item may also contain a ‘+’, ‘−’, or other
combined condition. representation of an operational sign.
* negated simple condition. The ‘NOT’ logical * numeric literal. A literal composed of one or more
operator immediately followed by a simple condition. numeric characters that may contain either a decimal
point, or an algebraic sign, or both. The decimal point
nested program. A program that is directly contained
must not be the rightmost character. The algebraic
within another program.
sign, if present, must be the leftmost character.
* next executable sentence. The next sentence to
which control will be transferred after execution of the
current statement is complete. O
* next executable statement. The next statement to object. An entity that has state (its data values) and
which control will be transferred after execution of the operations (its methods). An object is a way to
current statement is complete. encapsulate state and behavior.
* next record. The record that logically follows the object code. Output from a compiler or assembler that
current record of a file. is itself executable machine code or is suitable for
processing to produce executable machine code.
* noncontiguous items. Elementary data items in the
Working-Storage and Linkage Sections that bear no * OBJECT-COMPUTER. The name of an Environment
hierarchic relationship to other data items. Division paragraph in which the computer
environment, within which the object program is
non-date. Any of the following: executed, is described.
A data item whose date description entry does not
include the DATE FORMAT clause * object computer entry. An entry in the
OBJECT-COMPUTER paragraph of the Environment
A literal Division which contains clauses that describe the
A date field that has been converted using the computer environment in which the object program is
UNDATE function to be executed.
A reference-modified date field object deck. A portion of an object program suitable
The result of certain arithmetic operations that may as input to a linkage editor. Synonymous with object
include date field operands; for example, the module and text deck.
difference between two compatible date fields
object module. Synonym for object deck or text deck.
* nonnumeric item. A data item whose description
permits its content to be composed of any combination * object of entry. A set of operands and reserved
of characters taken from the computer’s character set. words, within a Data Division entry of a COBOL
Certain categories of nonnumeric items may be formed program, that immediately follows the subject of the
from more restricted character sets. entry.
X is the object of the OCCURS DEPENDING ON clause page. A vertical division of output data representing a
(ODO object). The value of the ODO object determines physical separation of such data, the separation being
how many of the ODO subject appear in the table. based on internal logical requirements and/or external
characteristics of the output medium.
ODO subject. In the example above, Y is the subject
of the OCCURS DEPENDING ON clause (ODO * page body. That part of the logical page in which
subject). The number of Y ODO subjects that appear in lines can be written and/or spaced.
the table depends on the value of X. * paragraph. In the Procedure Division, a
* open mode. The state of a file after execution of an paragraph-name followed by a separator period and by
OPEN statement for that file and before the execution zero, one, or more sentences. In the Identification and
of a CLOSE statement without the REEL or UNIT Environment Divisions, a paragraph header followed
phrase for that file. The particular open mode is by zero, one, or more entries.
specified in the OPEN statement as either INPUT, * paragraph header. A reserved word, followed by the
OUTPUT, I-O or EXTEND. separator period, that indicates the beginning of a
* operand. Whereas the general definition of operand paragraph in the Identification and Environment
is “that component which is operated upon,” for the Divisions. The permissible paragraph headers in the
purposes of this document, any lowercase word (or Identification Division are:
words) that appears in a statement or entry format may PROGRAM-ID. (Program Identification Division)
be considered to be an operand and, as such, is an CLASS-ID. (Class Identification Division)
implied reference to the data indicated by the operand. METHOD-ID. (Method Identification Division)
AUTHOR.
* operational sign. An algebraic sign, associated with INSTALLATION.
a numeric data item or a numeric literal, to indicate DATE-WRITTEN.
whether its value is positive or negative. DATE-COMPILED.
SECURITY.
* optional file. A file which is declared as being not
The permissible paragraph headers in the Environment
necessarily present each time the object program is
Division are:
executed. The object program causes an interrogation
for the presence or absence of the file. SOURCE-COMPUTER.
OBJECT-COMPUTER.
* optional word. A reserved word that is included in SPECIAL-NAMES.
a specific format only to improve the readability of the REPOSITORY. (Program or Class Configuration Section)
language and whose presence is optional to the user FILE-CONTROL.
I-O-CONTROL.
when the format in which the word appears is used in
a source program. * paragraph-name. A user-defined word that identifies
and begins a paragraph in the Procedure Division.
Glossary 537
parameter. Parameters are used to pass data values PERFORM procedure integration is the process
between calling and called programs. whereby a PERFORM statement is replaced by its
performed procedures. Contained program procedure
password. A unique string of characters that a
integration is the process where a CALL to a contained
program, computer operator, or user must supply to
program is replaced by the program code.
meet security requirements before gaining access to
data. * procedure-name. A user-defined word that is used
to name a paragraph or section in the Procedure
* phrase. A phrase is an ordered set of one or more
Division. It consists of a paragraph-name (which may
consecutive COBOL character-strings that form a
be qualified) or a section-name.
portion of a COBOL procedural statement or of a
COBOL clause. procedure-pointer data item. A data item in which a
pointer to an entry point can be stored. A data item
* physical record. See “block.”
defined with the USAGE IS PROCEDURE-POINTER
pointer data item. A data item in which address clause contains the address of a procedure entry point.
values can be stored. Data items are explicitly defined
* program identification entry. An entry in the
as pointers with the USAGE IS POINTER clause.
PROGRAM-ID paragraph of the Identification Division
ADDRESS OF special registers are implicitly defined as
which contains clauses that specify the program-name
pointer data items. Pointer data items can be
and assign selected program attributes to the program.
compared for equality or moved to other pointer data
items. * program-name. In the Identification Division and
the end program header, a user-defined word that
portability. The ability to transfer an application
identifies a COBOL source program.
program from one application platform to another with
relatively few changes to the source program. * pseudo-text. A sequence of text words, comment
lines, or the separator space in a source program or
* prime record key. A key whose contents uniquely
COBOL library bounded by, but not including,
identify a record within an indexed file.
pseudo-text delimiters.
* priority-number. A user-defined word which
* pseudo-text delimiter. Two contiguous equal sign
classifies sections in the Procedure Division for
characters (==) used to delimit pseudo-text.
purposes of segmentation. Segment-numbers may
contain only the characters '0','1', ... , '9'. A * punctuation character. A character that belongs to
segment-number may be expressed either as a 1- or the following set:
2-digit number. Character Meaning
* procedure. A paragraph or group of logically , comma
successive paragraphs, or a section or group of ; semicolon
logically successive sections, within the Procedure : colon
Division. . period (full stop)
" quotation mark
* procedure branching statement. A statement that ( left parenthesis
causes the explicit transfer of control to a statement ) right parenthesis
other than the next executable statement in the ␣ space
sequence in which the statements are written in the = equal sign
source program. The procedure branching statements
are: ALTER, CALL, EXIT, EXIT PROGRAM, GO TO,
MERGE, (with the OUTPUT PROCEDURE phrase), Q
PERFORM and SORT (with the INPUT PROCEDURE
or OUTPUT PROCEDURE phrase). QSAM (Queued Sequential Access Method). An
extended version of the basic sequential access method
Procedure Division. One of the four main component (BSAM). When this method is used, a queue is formed
parts of a COBOL program, class definition, or method of input data blocks that are awaiting processing or of
definition. The Procedure Division contains output data blocks that have been processed and are
instructions for solving a problem. The Program and awaiting transfer to auxiliary storage or to an output
Method Procedure Divisions may contain imperative device.
statements, conditional statements, compiler directing
statements, paragraphs, procedures, and sections. The * qualified data-name. An identifier that is composed
Class Procedure Division contains only method of a data-name followed by one or more sets of either
definitions. of the connectives OF and IN followed by a data-name
qualifier.
procedure integration. One of the functions of the
COBOL optimizer is to simplify calls to performed * qualifier.
procedures or contained programs. 1. A data-name or a name associated with a level
indicator which is used in a reference either
together with another data-name which is the name
record key. A key whose contents identify a record IS GREATER THAN OR EQUAL TO
within an indexed file. Greater than or equal to
* record-name. A user-defined word that names a IS >= Greater than or equal to
record described in a record description entry in the
Data Division of a COBOL program. IS LESS THAN OR EQUAL TO
Less than or equal to
* record number. The ordinal number of a record in IS <= Less than or equal to
the file whose organization is sequential.
* relation character. A character that belongs to the
recursion. A program calling itself or being directly or following set:
indirectly called by a one of its called programs. Character Meaning
recursively capable. A program is recursively capable
(can be called recursively) if the RECURSIVE attribute > greater than
is on the PROGRAM-ID statement. < less than
= equal to
reel. A discrete portion of a storage medium, the
dimensions of which are determined by each * relation condition. The proposition, for which a
implementor that contains part of a file, all of a file, or truth value can be determined, that the value of an
any number of files. The term is synonymous with arithmetic expression, data item, nonnumeric literal, or
unit and volume. index-name has a specific relationship to the value of
another arithmetic expression, data item, nonnumeric
reentrant. The attribute of a program or routine that literal, or index name. (See also “relational operator.”)
allows more than one user to share a single copy of a
load module. * relative file. A file with relative organization.
* reference format. A format that provides a standard * relative key. A key whose contents identify a logical
method for describing COBOL source programs. record in a relative file.
reference modification. A method of defining a new * relative organization. The permanent logical file
alphanumeric data item by specifying the leftmost structure in which each record is uniquely identified by
character and length relative to the leftmost character an integer value greater than zero, which specifies the
of another alphanumeric data item. record’s logical ordinal position in the file.
Glossary 539
* relative record number. The ordinal number of a FILE SECTION.
record in a file whose organization is relative. This WORKING-STORAGE SECTION.
LOCAL-STORAGE SECTION.
number is treated as a numeric literal which is an
LINKAGE SECTION.
integer.
* reserved word. A COBOL word specified in the list In the Procedure Division, a section header is
of words that may be used in a COBOL source composed of a section-name, followed by the reserved
program, but that must not appear in the program as word SECTION, followed by a separator period.
user-defined words or system-names. * section-name. A user-defined word that names a
* resource. A facility or service, controlled by the section in the Procedure Division.
operating system, that can be used by an executing selection structure. A program processing logic in
program. which one or another series of statements is executed,
* resultant identifier. A user-defined data item that is depending on whether a condition is true or false.
to contain the result of an arithmetic operation. * sentence. A sequence of one or more statements, the
reusable environment. A reusable environment is last of which is terminated by a separator period.
when you establish an assembler program as the main * separately compiled program. A program which,
program by using either ILBOSTP0 programs, together with its contained programs, is compiled
IGZERRE programs, or the RTEREUS run-time option. separately from all other programs.
routine. A set of statements in a COBOL program that * separator. A character or two contiguous characters
causes the computer to perform an operation or series used to delimit character-strings.
of related operations. In Language Environment, refers
to either a procedure, function, or subroutine. * separator comma. A comma (,) followed by a space
used to delimit character-strings.
* routine-name. A user-defined word that identifies a
procedure written in a language other than COBOL. * separator period. A period (.) followed by a space
used to delimit character-strings.
* run time. The time at which an object program is
executed. The term is synonymous with object time. * separator semicolon. A semicolon (;) followed by a
space used to delimit character-strings.
run-time environment. The environment in which a
COBOL program executes. sequence structure. A program processing logic in
which a series of statements is executed in sequential
* run unit. A stand-alone object program, or several order.
object programs, that interact via COBOL CALL
statements, which function at run time as an entity. * sequential access. An access mode in which logical
records are obtained from or placed into a file in a
consecutive predecessor-to-successor logical record
S sequence determined by the order of records in the file.
SBCS (Single Byte Character Set). See "Single Byte * sequential file. A file with sequential organization.
Character Set (SBCS)".
* sequential organization. The permanent logical file
scope terminator. A COBOL reserved word that structure in which a record is identified by a
marks the end of certain Procedure Division predecessor-successor relationship established when the
statements. It may be either explicit (END-ADD, for record is placed into the file.
example) or implicit (separator period).
serial search. A search in which the members of a set
* section. A set of zero, one or more paragraphs or are consecutively examined, beginning with the first
entities, called a section body, the first of which is member and ending with the last.
preceded by a section header. Each section consists of
* 77-level-description-entry. A data description entry
the section header and the related section body.
that describes a noncontiguous data item with the
* section header. A combination of words followed by level-number 77.
a separator period that indicates the beginning of a
* sign condition. The proposition, for which a truth
section in the Environment, Data, and Procedure
value can be determined, that the algebraic value of a
Divisions. In the Environment and Data Divisions, a
data item or an arithmetic expression is either less than,
section header is composed of reserved words followed
greater than, or equal to zero.
by a separator period. The permissible section headers
in the Environment Division are: * simple condition. Any single condition chosen from
CONFIGURATION SECTION. the set:
INPUT-OUTPUT SECTION. Relation condition
The permissible section headers in the Data Division Class condition
are: Condition-name condition
Switch-status condition
Glossary 541
* subscript. An occurrence number represented by A literal including, in the case of nonnumeric
either an integer, a data-name optionally followed by literals, the opening quotation mark and the closing
an integer with the operator + or -, or an index-name quotation mark that bound the literal.
optionally followed by an integer with the operator + Any other sequence of contiguous COBOL
or -, that identifies a particular element in a table. A characters except comment lines and the word
subscript may be the word ALL when the subscripted ‘COPY’ bounded by separators that are neither a
identifier is used as a function argument for a function separator nor a literal.
allowing a variable number of arguments.
top-down design. The design of a computer program
* subscripted data-name. An identifier that is using a hierarchic structure in which related functions
composed of a data-name followed by one or more are performed at each level of the structure.
subscripts enclosed in parentheses.
top-down development. See “structured
* super-class. A class that is inherited by another programming.”
class. See also sub-class.
trailer-label. (1) A file or data set label that follows
switch-status condition. The proposition, for which a the data records on a unit of recording medium. (2)
truth value can be determined, that an UPSI switch, Synonym for end-of-file label.
capable of being set to an ‘on’ or ‘off’ status, has been
set to a specific status. * truth value. The representation of the result of the
evaluation of a condition in terms of one of two values:
* symbolic-character. A user-defined word that true or false.
specifies a user-defined figurative constant.
syntax. (1) The relationship among characters or
groups of characters, independent of their meanings or U
the manner of their interpretation and use. (2) The * unary operator. A plus (+) or a minus (-) sign, that
structure of expressions in a language. (3) The rules precedes a variable or a left parenthesis in an
governing the structure of a language. (4) The arithmetic expression and that has the effect of
relationship among symbols. (5) The rules for the multiplying the expression by +1 or -1, respectively.
construction of a statement.
unit. A module of direct access, the dimensions of
* system-name. A COBOL word that is used to which are determined by IBM.
communicate with the operating environment.
universal object reference. A data-name that can refer
System Object Model (SOM). IBM's object-oriented to an object of any class.
programming technology for building, packaging, and
manipulating class libraries. SOM conforms to the * unsuccessful execution. The attempted execution of
Object Management Group's (OMG) Common Object a statement that does not result in the execution of all
Request Broker Architecture (CORBA) standards. the operations specified by that statement. The
unsuccessful execution of a statement does not affect
any data referenced by that statement, but may affect
T status indicators.
* table. A set of logically consecutive items of data UPSI switch. A program switch that performs the
that are defined in the Data Division by means of the functions of a hardware switch. Eight are provided:
OCCURS clause. UPSI-0 through UPSI-7.
* table element. A data item that belongs to the set of * user-defined word. A COBOL word that must be
repeated items comprising a table. supplied by the user to satisfy the format of a clause or
statement.
text deck. Synonym for object deck or object module.
* text-name. A user-defined word that identifies
library text. V
* text word. A character or a sequence of contiguous * variable. A data item whose value may be changed
characters between margin A and margin R in a by execution of the object program. A variable used in
COBOL library, source program, or in pseudo-text an arithmetic expression must be a numeric elementary
which is: item.
A separator, except for: space; a pseudo-text * variable length record. A record associated with a
delimiter; and the opening and closing delimiters file whose file description or sort-merge description
for nonnumeric literals. The right parenthesis and entry permits records to contain a varying number of
left parenthesis characters, regardless of context character positions.
within the library, source program, or pseudo-text,
* variable occurrence data item. A variable occurrence
are always considered text words.
data item is a table element which is repeated a
variable number of times. Such an item must contain
* variably located item.. A data item following, and windowed year. A date field that consists only of a
not subordinate to, a variable-length table in the same 2-digit year. This 2-digit year may be interpreted using
level-01 record. a century window. For example, 05 could be
interpreted as 2005. See also “century window.”
* verb. A word that expresses an action to be taken by
a COBOL compiler or object program. Compare with “expanded year.”
VM/SP (Virtual Machine/System Product). An * word. A character-string of not more than 30
IBM-licensed program that manages the resources of a characters which forms a user-defined word, a
single computer so that multiple computing systems system-name, a reserved word, or a function-name.
appear to exist. Each virtual machine is the functional
* Working-Storage Section. The section of the Data
equivalent of a “real” machine.
Division that describes working storage data items,
volume. A module of external storage. For tape composed either of noncontiguous items or working
devices it is a reel; for direct-access devices it is a unit. storage records or of both.
volume switch procedures. System specific
procedures executed automatically when the end of a Y
unit or reel has been reached before end-of-file has
been reached.
Z
zoned decimal item. See “external decimal item.”
Glossary 543
Index
AIX COBOL language differences
Special A (continued)
A, symbol in PICTURE BLOCK CONTAINS 135
Characters clause 161 CLOSE statement 268
, (comma) abbreviated combined relation CODE-SET 143
insertion character 171 condition COMP-5 data item 189
symbol in PICTURE examples 234 compiler limits 494
clause 163, 166 using parentheses in 233 control characters 129
/ (slash) ACCEPT statement DBCS 2
insertion character 171 mnemonic name in 250, 251 environment-name 252
symbol in PICTURE overlapping operands, file handling 118
clause 163, 166 unpredictable results 242 file status data-name-8 112
(/) comment line 33 system information LABEL RECORDS 139
(period) 163 transfer 252 LINE SEQUENTIAL file
<= (less than or equal to) 219 under AIX and Windows 250 I-O 105
< (less than) 219 access mode locale definition 515
{:} description 107 MORE-LABELS, GO TO 293
description 25 dynamic pointer data item size 192
required use of 473 DELETE statement 275 RECORD CONTAINS
$ (default currency symbol) description 108 clause 137
in PICTURE clause 164, 166 READ statement 348 RECORDING MODE
insertion character 172 random clause 142
* symbol in PICTURE clause 163 DELETE statement 275 RERUN clause 115
*CBL (*CONTROL) statement 466 description 108 RESERVE clause 103
+ (plus) READ statement 347 SAME AREA clause 116
insertion character 172, 173 sequential SAME SORT AREA clause 117
SIGN clause 180 DELETE statement 275 SAME SORT-MERGE AREA
symbol in PICTURE description 108 clause 118
clause 166 READ statement 345 SET statement 365
− (minus) ACCESS MODE clause 107 SORT-CONTROL special
insertion character 172 ACOS function 412 register 14
SIGN clause 180 ADD statement SORT-FILE-SIZE 15
symbol in PICTURE common phrases 238 SORT-MESSAGE 15
clause 166 CORRESPONDING SORT-MODE-SIZE 16
= (equal) 219 phrase 257 status key value and
> (greater than) 219 description and format 255 meaning 244
>= (greater than or equal to) 219 ADDRESS OF special register 9 USE...AFTER...LABEL
ADDRESS OF under AIX and PROCEDURE 485
Windows 365 WRITE ADVANCING 85, 394
Numerics ADVANCING phrase 394 aligning data 181
0 AFTER phrase ALL
insertion character 171 INSPECT statement 304 phrase of INSPECT
symbol in PICTURE PERFORM statement 335 statement 299, 301
clause 163, 166 with REPLACING 301 SEARCH statement 359
66, RENAMES data description with TALLYING 299 UNSTRING statement 387
entry 178 WRITE statement 394 ALL literal
77, item description entry 127 AIX COBOL language differences STOP statement 378
88, condition-name data ACCEPT statement 250 STRING statement 379
description entry 146 APPLY WRITE-ONLY 118 UNSTRING statement 387
9, symbol in PICTURE ASSIGN clause 100 ALL subscripting 405
clause 163, 166 basis-names, library-names, ALPHABET clause 86
text-names 36 alphabet-name
Index 545
category of data (continued) COBOL (continued) comparison (continued)
alphanumeric items 168 program structure 58 nonnumeric operands 224
alphanumeric-edited items 168 reference format 28 numeric and nonnumeric
DBCS items 169 COBOL word 3 operands 227
numeric items 167 CODE-SET clause numeric operands 223
numeric-edited items 167 ALPHABET clause and 88 of index data items 227
relationship to class of description 143 of index-names 227
data 127 format 131 rules for COPY statement 471
CBL (PROCESS) statement 465 NATIVE phrase and 143 compatible date field
century window collating sequence See also date field
See also date field ASCENDING/DESCENDING definition 54
definition 55 KEY phrase and 156 compile-time switch 505
CHAR function 416 ASCII 500 compiler directing statements
character code set, specifying 86 EBCDIC 498 BASIS 464
character-string locale definition 515 COPY 468
COBOL word 3 specified in DELETE 474
representation in PICTURE OBJECT-COMPUTER EJECT 475
clause 166 paragraph 82 ENTER 475
size determination 129 specified in SPECIAL-NAMES INSERT 476
CHARACTERS BY phrase 301 paragraph 86 READY TRACE 476
CHARACTERS phrase COLLATING SEQUENCE REPLACE 477
BLOCK CONTAINS phrase 82 RESET TRACE 476
clause 135 ALPHABET clause 86 SERVICE LABEL 480
INSPECT statement 299 MERGE statement 316 SERVICE RELOAD 481
MEMORY SIZE clause 82 SORT statement 370 SKIP1/2/3 481
USAGE clause and 135 colon character TITLE 482
characters, valid in COBOL description 25 USE 483
program 2 required use of 473 compiler limits 494
checkpoint processing, RERUN column 7 compiler options
clause 115 indicator area 31 ADV 395
class 63 specifying comments 32 controlling output from 466
CLASS clause 89 combined condition DATEPROC 53
class condition 215, 216 description 231 NUMPROC 228
class Data Division 120 evaluation rules 232 specifying 465
class definition logical operators and evaluation THREAD 157
affect of SELF and SUPER 307 results 231 TRUNC 129
class procedure division 202 order of evaluation 232 complex conditions
CLASS-ID paragraph 72 permissible element abbreviated combined
Configuration Section 80 sequences 231 relation 232
Data Division 120 comma (,) combined condition 231
description 63 Configuration Section 80 description 229
Identification Division 69 DECIMAL-POINT IS COMMA negated simple 230
inheritance rules 73 clause 91 complex OCCURS DEPENDING
requirements for indexed insertion character 171 ON (CODO) 160
tables 157 symbol in PICTURE composite of operands 242
class identification division 72 clause 163 COMPUTATIONAL data
class name, OO 36 comment line items 188
class procedure division 202 description 32 COMPUTE statement
CLASS-ID paragraph 72 Identification Division 76 common phrases 239
class-name class test 216 in library text 469 description and format 272
classes of data 127 COMMON clause 72 computer-name 80, 82
clauses 26, 27 common processing facilities 244 condition
CLOSE statement COMP-1 through COMP-5 data abbreviated combined
format and description 268 items 189 relation 232
COBOL comparison class 215
class definition 63 cycle, INSPECT statement 304 combined 231
language structure 2 DBCS operands 228 complex 229
method definition 65 in EVALUATE statement 286 condition-name 217
Index 547
data manipulation statements date format DECLARATIVES key word
(continued) See also DATE FORMAT clause begin in Area A 30
INITIALIZE 296 definition 54 description 207
list of 243 DATE FORMAT clause 148 Declaratives Section 207
MOVE 320 combining with other DELETE statement
overlapping operands 243 clauses 150 description and format 474
READ 342 DATE YYYYMMDD 253 dynamic access 275
RELEASE 349 DATE-COMPILED paragraph format and description 275
RETURN 351 description 76 INVALID KEY phrases 275
REWRITE 353 format 68 random access 275
SET 362 DATE-OF-INTEGER function 419 sequential access 275
STRING 379 DATE-TO-YYYYMMDD DELIMITED BY phrase
UNSTRING 386 function 420 STRING 379
WRITE 393 DATE-WRITTEN paragraph UNSTRING statement 386
data organization description 76 delimited scope statement 237
access modes and 108 format 68 delimiter
indexed 104 DATEPROC compiler option 53 INSPECT statement 302
line-sequential 105 DATEVAL function 421 UNSTRING statement 386
relative 105 DAY 253 DELIMITER IN phrase,
sequential 104 DAY YYYYDDD 253 UNSTRING statement 388
DATA RECORDS clause DAY-OF-INTEGER function 423 DEPENDING phrase
description 140 DAY-OF-WEEK 254 GO TO statement 292
format 131 DAY-TO-YYYYDDD function 424 OCCURS clause 158
data transfer 250 DB (debit) DESCENDING KEY phrase 156
data types insertion character 172 collating sequence 156
file data 124 symbol in PICTURE description 314
program data 124 clause 163 MERGE statement 314
data-name DBCS (Double-Byte Character Set) SORT statement 368
data description entry 147 See also multi-byte characters DISPLAY phrase in USAGE
data-names class and category 127 clause 190
precedence if duplicate 120 elementary move rules 322 DISPLAY statement
DATE 253 PICTURE clause and 169 description and format 277
date field use with relational external 128, 169
addition 212 operators 220 programming notes 279
arithmetic 211 using in comments 76 DIVIDE statement
compatible 54 DBCS class condition 216 common phrases 239
DATE FORMAT clause 148 DD statements description and format 280
DATEPROC compiler See environment variables REMAINDER phrase 282
option 53 De-editing 322 division header
DATEVAL function 421 DEBUG-ITEM special register 10 format, Environment
definition 53 debugging 504 Division 80
expansion of windowed date DEBUGGING declarative 487 format, Identification
fields before use 149 debugging line 33, 81 Division 68
group items that are date DEBUGGING MODE clause 81 format, Procedure
fields 151 decimal point (.) 240 Division 204
in relation conditions 219 DECIMAL-POINT IS COMMA specification of 29
in sign conditions 229 clause DO-UNTIL structure, PERFORM
MOVE statement, behavior description 91 statement 335
in 323 declarative procedures DO-WHILE structure, PERFORM
non-date 55 description and format 207 statement 335
purpose 52 PERFORM statement 332 Double-Byte Character Set (DBCS)
restrictions 150 USE statement 207 See also multi-byte characters
size errors 213, 240 declaratives class and category 127
storing arithmetic results 213 EXCEPTION/ERROR 483 PICTURE clause and 169
subtraction 212 LABEL 485 use with relational
trigger values 149 precedence rules for nested operators 220
UNDATE function 456 programs 484 using in comments 76
windowed date field USE FOR DEBUGGING 487
conditional variables 218
Index 549
figurative constant (continued) FROM phrase Identification Division
symbolic-character 8 ACCEPT statement 250 CLASS-ID paragraph 72
UNSTRING statement 387 REWRITE statement 353 format (program, class,
file SUBTRACT statement 383 method) 68
data type 124 with identifier 248 METHOD-ID paragraph 74
definition 124 WRITE statement 394 optional paragraphs 76
handling, under AIX and function PROGRAM-ID paragraph 70
Windows 118 arguments 404 identifier 41, 209
labels 139 class and category 127 IF statement 294
File Description entry description 402 imperative statement 235
See FD (File Description) entry rules for usage 403 implicit
file organization types of functions 403 redefinition of storage
definition 108 area 134, 175
LINAGE clause 140 scope terminators 238
line-sequential 105 G in-line PERFORM statement 332
types of 104 G, symbol in PICTURE indentation 30, 127
file position indicator clause 162 index
description 249 GIVING phrase data item 227, 320
READ statement 347 ADD statement 255 relative indexing 46
File Section 121 arithmetic 239 SET statement 46
EXTERNAL clause 134 DIVIDE statement 282 index name
RECORD clause 136 MERGE statement 318 assigning values 362
FILE STATUS clause MULTIPLY statement 325 comparisons 227
DELETE statement and 275 SORT statement 372 data item definition 190
description 112 SUBTRACT statement 384 OCCURS clause 157
format 94 GLOBAL clause PERFORM statement 341
INVALID KEY phrase and 247 with data item 153 SEARCH statement 356
status key 244 with file name 134 SET statement 362
FILE-CONTROL paragraph GO TO statement INDEX phrase in USAGE
ASSIGN clause 97 altered 293 clause 190
description and format 94 conditional 292 INDEXED BY phrase 157
FILE STATUS clause 112 format and description 292 indexed files
ORGANIZATION clause 103 MORE-LABELS 293 CLOSE statement 269
PADDING CHARACTER SEARCH statement 356 DELETE statement 275
clause 106 unconditional 292 FILE-CONTROL paragraph
RECORD KEY clause 109 GOBACK statement 291 format 94
RELATIVE KEY clause 111 GREATER THAN OR EQUAL TO I-O-CONTROL paragraph
RESERVE clause 103 symbol (>=) 218 format 114
SELECT clause 97 GREATER THAN symbol (>) 218 organization 104
file-name, specifying on SELECT group item permissible statements for 331
clause 97 class and categories 127 READ statement 346
FILLER phrase description 125 START statement 376
CORRESPONDING MOVE statement 324 indexed organization
phrase 147 nonnumeric operand description 104
data description entry 147 comparison 227 FILE-CONTROL paragraph
fixed insertion editing 172 group move rules 324 format 94
fixed-length I-O-CONTROL paragraph
item, maximum length 145 format 114
records 135 H indexing
floating insertion editing 172 halting execution 378 description 45
floating-point HIGH-VALUE(S) figurative MOVE statement
DISPLAY statement 277 constant 87 evaluation 320
internal 128 hyphen (-), in indicator area 31 OCCURS clause 45, 154
FOOTING phrase of LINAGE relative 46
clause 140 SET statement and 46
FOR REMOVAL phrase 268, 269 I indicator area 28
format notation, rules for vii industry specifications 518
IBM extensions, format
description vii
Index 551
LINE/LINES, WRITE MERGE statement
K statement 394 ASCENDING/DESCENDING
Kanji 216 LINES AT BOTTOM phrase 140 KEY phrase 314
key of reference 104 LINES AT TOP phrase 140 COLLATING SEQUENCE
KEY phrase Linkage Section phrase 316
OCCURS clause 156 called subprogram 206 format and description 314
READ statement 344 description 123 GIVING phrase 318
SEARCH statement 356 levels under AIX and OUTPUT PROCEDURE
SORT statement 368 Windows 365 phrase 318
START statement 375 requirement for indexed USING phrase 317
items 157 METACLASS clause 72, 191
VALUE clause 195 metaclass, description 63
L literal method data division 120
LABEL declarative 485 and arithmetic expressions 209 method definition
label processing, OPEN ASSIGN clause 97 affect of SELF and SUPER 307
statement 329 CODE-SET clause and Data Division 120
LABEL RECORDS clause ALPHABET clause 88 description 65
description 139 CURRENCY SIGN clause 90 Identification Division 70
format 131 description 17 inheritance rules 73
Language Environment Callable nonnumeric operand method procedure
Services comparison 227 division 202
description 260 null-terminated METHOD-ID paragraph 74
LEADING phrase nonnumeric 20 method identification division 74
INSPECT statement 299, 301 STOP statement 378 method name 36
SIGN clause 180 VALUE clause 196 method procedure division 202
LENGTH function 430 local storage METHOD-ID paragraph 74
LENGTH OF special register 11 defining with RECURSIVE methods
LESS THAN OR EQUAL TO clause 71 available to subclasses 73
symbol (<=) 218 requirement for indexed exiting 289
LESS THAN symbol (<) 218 items 157 invoking 307
level Local-Storage Section 123 recursively reentering 71
01 item 125 locale 515 reusing 72
02-49 item 125 LOG function 431 MIDRANGE function 437
66 item 127 LOG10 function 432 millennium language extensions
77 item 127 logical operator syntax 52
88 item 127 complex condition 229 millennium language extensions
indicator, definition of 125 in evaluation of combined (MLE)
level number conditions 231 See also date field
definition 125 list of 229 description 52
description and format 146 logical record MIN function 438
FILLER phrase 147 definition 124 minus sign (-)
library-name file data 124 COBOL character 2
COPY statement 468 program data 124 fixed insertion symbol 172
library-names record description entry floating insertion symbol 172,
under AIX and Windows 36 and 124 173
limit values, date field 149 RECORDS phrase 136 SIGN clause 180
limits of the compiler 494 LOW-VALUE(S) figurative mnemonic-name
LINAGE clause constant 88 ACCEPT statement 250
description 140 LOWER-CASE function 433 DISPLAY statement 278
diagram of phrases 140 SET statement 364
format 131 SPECIAL-NAMES
LINAGE-COUNTER special M paragraph 85
register MAX function 434 WRITE statement 395
description 12 maximum index value 46 MOD function 439
WRITE statement 395 MEAN function 435 MORE-LABELS GO TO
line advancing 394 MEDIAN function 436 statement 293
line-sequential file MEMORY SIZE clause 82 MOVE statement
organization 105 CORRESPONDING
phrase 320
Index 553
OPEN statement (continued) PICTURE SYMBOL phrase 91
format and description 327 P plus (+)
I-O phrase 327 P, symbol in PICTURE clause 162 fixed insertion symbol 172
label processing 329 PACKED-DECIMAL phrase in floating insertion symbol 172,
phrases 327 USAGE clause 188 173
programming notes 330 PADDING CHARACTER insertion character 173
system dependencies 331 clause 106 SIGN clause 180
operands page eject 33 pointer data item
comparison of nonnumeric 224 paragraph defined with USAGE
comparison of numeric 223 description 26, 208 clause 192
composite of 242 header, specification of 29 relation condition 221
overlapping 242, 243 termination, EXIT SET statement 364
operational sign statement 288 size on Workstation 192
algebraic, description of 130 paragraph name POINTER phrase
SIGN clause and 130 description 208 STRING statement 380
USAGE clause and 130 specification of 29 UNSTRING statement 388
optional file parentheses POSITIVE 228
See SELECT OPTIONAL clause combined conditions, use 231 PRESENT-VALUE function 446
ORD function 443 in arithmetic expressions 210 PREVIOUS RECORD phrase,
ORD-MAX function 444 partial listings 466 READ statement 342
ORD-MIN function 445 PASSWORD clause print files, WRITE statement 398
order of entries description 111 procedure branching
clauses in FILE-CONTROL system dependencies 112 GO TO statement 292
paragraph 94 PERFORM statement statements, executed
IO CONTROL paragraph 114 branching 333 sequentially 249
order of evaluation in combined conditional 335 Procedure Branching
conditions 232 END-PERFORM phrase 334 Statements 249
ORGANIZATION clause EVALUATE statement 284 Procedure Division
description 103 execution sequences 334 declarative procedures 207
format 94 EXIT statement 288 format (programs, methods,
ORGANIZATION IS INDEXED format and description 332 classes) 202
clause 103 in-line 333 header 204
ORGANIZATION IS LINE out-of-line 333 statements 250
SEQUENTIAL clause 104 TIMES phrase 334 procedure-name
ORGANIZATION IS RELATIVE VARYING phrase 335, 338 GO TO statement 292
clause 104 period (.) MERGE statement 318
ORGANIZATION IS actual decimal point 171 PERFORM statement 332
SEQUENTIAL clause 103 phrase, definition 27 SORT statement 372
out-of-line PERFORM physical record PROCEDURE-POINTER data item
statement 333 BLOCK CONTAINS defined with USAGE
outermost programs, clause 135 clause 193
debugging 487 definition 124 relation condition 222
output file, label processing 329 file data 124 SET statement 365
OUTPUT phrase 327 file description entry and 124 size on Workstation 192
OUTPUT PROCEDURE phrase RECORDS phrase 136 procedure, description 208
MERGE statement 318 PICTURE clause PROCESS (CBL) statement 465
RETURN statement 351 and class condition 215 PROGRAM COLLATING
SORT statement 373 computational items and 188 SEQUENCE clause
OVERFLOW phrase CURRENCY SIGN clause 90 ALPHABET clause 86
CALL statement 265 data categories in 166 SPECIAL-NAMES paragraph
STRING statement 380, 389 DECIMAL-POINT IS COMMA and 82
overlapping operands invalid in clause 91, 161 program termination
arithmetic statements 242 description 160 GOBACK statement 291
data manipulation editing 170 STOP statement 378
statements 243 format 160 PROGRAM-ID paragraph
sequence of symbols 164 description 70
symbols used in 161 format 68
Index 555
REPLACING phrase selection objects in EVALUATE
COPY statement 470 S statement 284
INITIALIZE statement 297 S 162 selection subjects in EVALUATE
REPOSITORY paragraph 91 S01-S05 environment names under statement 284
required words vii AIX and Windows 394 SELF special character word 7,
RERUN clause SAME AREA clause under AIX 307
checkpoint processing 115 and Windows 116 sending field
description 115 SAME clause 116 MOVE statement 320
format 114 SAME RECORD AREA clause SET statement 362
RECORDS phrase 115 description 117 STRING statement 379
sort/merge 116 format 114 UNSTRING statement 386
under AIX and Windows 115 SAME SORT AREA clause sentence
RESERVE clause description 117 COBOL, definition 27
description 103 format 114 description 209
format 94 SAME SORT AREA clause under SEPARATE CHARACTER phrase
under AIX and Windows 103 AIX and Windows 117 of SIGN clause 180
reserved word list 506 SAME SORT-MERGE AREA clause separate sign, class condition 215
RESET TRACE statement 476 description 118 separately-compiled program 58
result field format 114 separator 198
GIVING phrase 239 scope terminator sequence number area (cols.
NOT ON SIZE ERROR explicit 237 1-6) 28
phrase 240 implicit 238 sequential access mode
ON SIZE ERROR phrase 240 SD (Sort File Description) entry data organization and 108
ROUNDED phrase 240 Data Division 134 DELETE statement 275
RETURN statement DATA RECORDS clause 140 description 108
AT END phrase 352 description 131, 133 READ statement 345
description and format 351 level indicator 125 REWRITE statement 354
overlapping operands, SEARCH statement sequential files
unpredictable results 242 AT END phrase 356 access mode allowed 108
RETURN-CODE special binary search 359 CLOSE statement 268, 269
register 13 description and format 356 description 104
RETURNING phrase serial search 357 file description entry 131
CALL statement 264 SET statement 356 FILE-CONTROL paragraph
on INVOKE statement 311 USAGE IS INDEX clause 191 format 94
reusing logical records 354 VARYING phrase 357 LINAGE clause 140
REVERSE function 450 WHEN phrase 356 OPEN statement 327
REWRITE statement section 26, 208 PASSWORD clause valid
description and format 353 section header with 111
FROM identifier phrase 248 description 208 permissible statements for 330
INVALID KEY phrase 353 specification of 29 READ statement 345
ROUNDED phrase section name REWRITE statement 354
ADD statement 256 description 208 SELECT OPTIONAL clause 97
COMPUTE statement 272 in EXCEPTION/ERROR serial search
description 240 declarative 483 PERFORM statement 335
DIVIDE statement 281 SECURITY paragraph SEARCH statement 357
MULTIPLY statement 326 description 76 SERVICE LABEL statement 480
size error checking and 241 format 68 SERVICE RELOAD statement 481
SUBTRACT statement 384 segmentation considerations 259 SET statement
rules for syntax notation vii SELECT clause description and format 362
Rules for Usage 403 ASSIGN clause and 97 DOWN BY phrase 363
run unit format 94 index data item values
description 58 specifying a file name 97 assigned 190
termination with CANCEL SELECT OPTIONAL clause OFF phrase 364
statement 267 CLOSE statement 269 ON phrase 364
description 97 overlapping operands,
format 94 unpredictable results 242
specification for sequential I-O pointer data item 364
files 97 procedure-pointer data
item 365
Index 557
STRING statement system information transfer, transfer of data (continued)
description and format 379 ACCEPT statement 252 MOVE statement 320
execution of 381 system input device, ACCEPT STRING statement 379
overlapping operands, statement 251 UNSTRING statement 386
unpredictable results 242 system-name 82 trigger values, date field 149
structure of the COBOL computer-name 80 truncation of data
language 2 SOURCE-COMPUTER arithmetic item 129
structured programming paragraph 80 JUSTIFIED clause 154
DO-WHILE and ROUNDED phrase 240
DO-UNTIL 335 TRUNC compiler option 129
subclasses and methods 73 T truth value
subjects in EVALUATE tab character, restriction in IBM complex conditions 229
statement 284 COBOL 24 EVALUATE statement 285
subprogram linkage table references IF statement 294
CALL statement 260 indexing 45 of complex condition 230
CANCEL statement 266 subscripting 43 sign condition 228
ENTRY statement 283 TALLY special register 17 with conditional statement 236
subprogram termination TALLYING phrase type conformance
CANCEL statement 266 INSPECT statement 299 general rules 75
EXIT PROGRAM UNSTRING statement 389 INVOKE...USING 310
statement 290 TAN function 455 multiple inheritance 73
GOBACK statement 291 termination of execution SET...USAGE OBJECT
subscripting EXIT METHOD statement 289 REFERENCE 367
definition and format 43 EXIT PROGRAM
INDEXED BY phrase of statement 290
OCCURS clause 157 GOBACK statement 291 U
MOVE statement STOP RUN statement 378 unary operator 210
evaluation 320 terminators, scope 237 unconditional GO TO
OCCURS clause text words 469 statement 292
specification 154 text-name UNDATE function 456
table references 43 literal-1 468 unit file, definition 269
using data-names 45 under AIX and Windows 36 UNIT phrase 268
using index-names THREAD compiler option 157 universal object reference 191
(indexing) 45 requirement for indexed unsigned numeric item,
using integers 45 items 157 definition 167
substitution field of INSPECT THROUGH (THRU) phrase UNSTRING statement
REPLACING 299 ALPHABET clause 87 description and format 386
SUBTRACT statement CLASS clause 90 execution 390
common phrases 238 EVALUATE statement 284 overlapping operands,
description and format 383 PERFORM statement 332 unpredictable results 242
SUM function 454 RENAMES clause 178 receiving field 387
SUPER special character word 7, VALUE clause 197 sending field 386
307 TIME 254 UP BY phrase, SET statement 363
SUPPRESS option, COPY 470 TIMES phrase of PERFORM UPON phrase, DISPLAY 278
suppress output 466 statement 334 UPPER-CASE function 457
suppression editing 173 TITLE statement 482 UPSI-0 through UPSI-7, program
switch-status condition 229 TO phrase, SET statement 362 switches
SYMBOLIC CHARACTERS TO TRUE phrase, SET and switch-status
clause 89 statement 364 condition 229
symbols in PICTURE clause 161 transfer of control condition-name 85
SYNCHRONIZED clause 181 ALTER statement 259 processing special
VALUE clause and 195 explicit 50 conditions 85
syntax notation, rules for vii GO TO statement 292 SPECIAL-NAMES
system considerations, subprogram IF statement 294 paragraph 85
linkage implicit 50 USAGE clause
CALL statement 260 PERFORM statement 332 BINARY phrase 188
CANCEL statement 266 transfer of data CODE-SET clause and 143
ACCEPT statement 250 COMPUTATIONAL
phrases 189
Index 559
workstation COBOL language
differences (continued)
USE...AFTER...LABEL
PROCEDURE 485
WRITE ADVANCING 85, 394
WRITE
ADVANCING under AIX 394
ADVANCING under AIX and
Windows 85
WRITE statement
AFTER ADVANCING 394, 398
ALTERNATE RECORD
KEY 399
BEFORE ADVANCING 394,
398
description and format 393
END-OF-PAGE phrases 396
FROM identifier phrase 248
sequential files 394
X
X 162
X'00' - X'1F' control
characters 129
Y
year 2000 challenge
See date field
year-last date field
See also date field
definition 54
YEAR-TO-YYYY function 460
YEARWINDOW compiler option
century window 55
YEARWINDOW function 461
Z
Z
insertion character 173
symbol in PICTURE
clause 163
zero
filling, elementary moves 321
suppression and replacement
editing 173
ZERO in sign condition 228
Please use one of the following ways to send us your comments about this book:
Mail—Use the Readers' Comments form on the next page. If you are sending the form
from a country other than the United States, give it to your local IBM branch office or
IBM representative for mailing.
Fax—Use the Readers' Comments form on the next page and fax it to this U.S. number:
800-426-7773.
Internet—Use the form on the Web at:
— http://www.ibm.com/software/ad/rcf/
Be sure to include the following with your comments:
— Title and publication number of this book
— Your name, and address, telephone number, or e-mail address if you would like a
reply
Your comments should pertain only to the information in this book and the way the
information is presented. To request additional publications, or to comment on other IBM
information or the function of IBM products, please give your comments to your IBM
representative or to your IBM authorized remarketer.
IBM may use or distribute your comments without obligation.
Readers' Comments
COBOL for OS/390 & VM
COBOL Set for AIX
VisualAge COBOL
Language Reference
Publication No. SC26-9046-04
Complete
Easy to find
Easy to understand
Well organized
Overall satisfaction
Name Address
Company or Organization
Phone No.
Cut or Fold
Readers' Comments
IBM
Along Line
SC26-9046-04
NO POSTAGE
NECESSARY
IF MAILED IN THE
UNITED STATES
IBM Corporation
Department HHX/H3
PO Box 49023
San Jose, CA 95161-9023
Cut or Fold
SC26-9046-04 Along Line
IBM
VisualAge COBOL
SC26-9046 Language Reference
SC26-9050 Programming Guide
GC26-8944 Getting Started
SC26-9053 Visual Builder User's Guide
GC26-9052 Fact Sheet
SC26-9?46-?4
Spine information:
IBM IBM COBOL Language Reference