Compaq COBOL

Compaq COBOL

Reference Manual

Order Number: AA--Q2G0F--TK


October 2000

This manual provides reference information and syntax for the Compaq COBOL programming language.

Revision/Update Information: This manual supersedes the DIGITAL COBOL Reference Manual, Version 2.5.

Operating System and Version: OpenVMS Alpha Version 6.2 or
higher;
Tru64 UNIX Version 4.0F or
higher;
Microsoft Windows NT Version 4.0,
SP4, SP5 for Alpha Systems

Software Version: Compaq COBOL Version 2.7


Compaq Computer Corporation
Houston, Texas


© 2000 Compaq Computer Corporation

COMPAQ, VAX, VMS, the Compaq logo, and the DIGITAL logo Registered in U.S. Patent and Trademark Office.

OpenVMS and Tru64 are trademarks of Compaq Information Technologies Group, L.P.

Microsoft, MS-DOS, Win32, Windows, and Windows NT are trademarks of Microsoft Corporation.

Motif, OSF/1, UNIX, and X/Open are trademarks of The Open Group.

All other product names mentioned herein may be trademarks of their respective companies.

Confidential computer software. Valid license from Compaq required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.

Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this document is subject to change without notice.

THE INFORMATION IN THIS PUBLICATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK ARISING OUT OF THE USE OF THIS INFORMATION REMAINS WITH RECIPIENT. IN NO EVENT SHALL COMPAQ BE LIABLE FOR ANY DIRECT, CONSEQUENTIAL, INCIDENTAL, SPECIAL, PUNITIVE, OR OTHER DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION OR LOSS OF BUSINESS INFORMATION), EVEN IF COMPAQ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND WHETHER IN AN ACTION OF CONTRACT OR TORT, INCLUDING NEGLIGENCE.

The limited warranties for Compaq products are exclusively set forth in the documentation accompanying such products. Nothing herein should be construed as constituting a further or additional warranty.

ZK6296

Contents Index


Preface

This book describes the constructs and rules of the Compaq COBOL programming language, which is a Compaq Computer Corporation implementation of COBOL (COmmon Business-Oriented Language) for the OpenVMS Alpha, Compaq Tru64 UNIX, and Microsoft Windows NT Alpha platforms. It includes information about language syntax and semantics, as well as information about adherence and extensions to various COBOL standards. This documentation set also includes the Compaq COBOL User Manual and, optionally, DIGITAL COBOL DBMS Database Programming.

Compaq COBOL is the new name for DEC COBOL and for DIGITAL COBOL. Compaq COBOL, unmodified, refers to three products:

Compaq COBOL for OpenVMS Alpha
Compaq COBOL for Tru64 UNIX
Compaq COBOL for Windows NT Alpha

Compaq COBOL for OpenVMS VAX is the new name for VAX COBOL and DIGITAL VAX COBOL.

Any references to the former names in product documentation or other components should be construed as references to the Compaq COBOL names.

Intended Audience

This manual is intended for experienced applications programmers who have a thorough understanding of the COBOL language and some familiarity with their operating system. This is not a tutorial manual.

If you are a new COBOL user, you may need to read introductory COBOL textbooks or take COBOL courses.

Structure of This Document

This manual is organized as follows:

Associated Documents

The following documents contain additional information directly related to various topics covered in this manual:

Compaq COBOL User Manual

This manual describes how to use features of the Compaq COBOL language to develop programs on the Tru64 UNIX operating system or the OpenVMS Alpha operating system.

Compaq COBOL User Manual for Windows NT Alpha

The version of this manual for Microsoft Windows NT systems describes the use of the Compaq COBOL features on Windows NT Version 4.0, SP4, SP5 for Alpha systems. It also tells you how to install Compaq COBOL on NT. (There is no separate installation guide.)

DIGITAL COBOL Multiplatform Overview & Compatibility Guide

The DIGITAL COBOL Multiplatform Overview & Compatibility Guide is a small, easy-to-reference manual that compares COBOL on its four Compaq platforms: OpenVMS Alpha, OpenVMS VAX, Windows NT, and Tru64 UNIX. It is available both in hard copy and in Adobe Acrobat .PDF format on the COBOL web site for free download:


http://www.openvms.compaq.com/commercial/cobol 

Release Notes

Consult the Compaq COBOL release notes for your installed version for late corrections and new features.

On the OpenVMS Alpha operating system, the release notes are in:

SYS$HELP:COBOLnnn.RELEASE_NOTES (ASCII text)
SYS$HELP:COBOLnnn_RELEASE_NOTES.PS
SYS$HELP:COBOLnnn_RELEASE_NOTES.PDF (Portable Document Format file)

Where nnn is the version and release number.

On the Tru64 UNIX operating system, the release notes are in:

/usr/lib/cmplrs/cobol/relnotes

On Windows NT systems, the release notes are in:

drive-letter:\DEC\COBOL\Vnn\docs\Release_Notes.txt (ASCII text)
drive-letter:\DEC\COBOL\Vnn\docs\Release_Notes.ps (PostScript file)
drive-letter:\DEC\COBOL\Vnn\docs\Release_Notes.pdf (Portable Document Format file)

Where nn is the version and release number, for example, 27 for Version 2.7.

The default installation drive and directory is:

drive-letter:\DEC\COBOL\Vnn

Compaq COBOL for Tru64 UNIX Systems Installation Guide

This manual provides instructions for installing Compaq COBOL on the Tru64 UNIX operating system.

Compaq COBOL for OpenVMS Alpha Systems Installation Guide

This manual provides instructions for installing Compaq COBOL on the OpenVMS Alpha operating system.

DIGITAL COBOL DBMS Database Programming

This manual provides information on using Compaq COBOL for database programming with Oracle CODASYL DBMS on the OpenVMS Alpha operating system.

The OpenVMS Documentation Set

This set contains information about using the features of the OpenVMS Alpha and OpenVMS VAX operating systems and their tools.

The Tru64 UNIX Documentation Set

This set contains introductory and detailed information about using the features of the Tru64 UNIX operating system and its tools.

The Alpha Architecture Reference Manual

This manual is available from Digital Press.

Conventions Used in This Document

The following table lists the conventions used in this manual:


References

The following table shows certain references and their respective meanings in this manual:
Reference Meaning
OpenVMS OpenVMS Alpha operating system
Tru64 UNIX Tru64 UNIX operating system
Windows NT Microsoft Windows NT Version 4.0, SP4, SP5 for Alpha systems

Compaq Tru64 UNIX was formerly known as DEC OSF/1 or as DIGITAL UNIX. Compaq COBOL was formerly known as DIGITAL COBOL or DEC COBOL. Compaq COBOL for OpenVMS VAX was formerly known as VAX COBOL or as DIGITAL VAX COBOL.

Acknowledgement

COBOL is an industry language and is not the property of any company or group of companies, or of any organization or group of organizations.

No warranty, expressed or implied, is made by any contributor or by the CODASYL COBOL Committee as to the accuracy and functioning of the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection therewith.

The authors and copyright holders of the copyrighted material used herein are as follows: FLOW-MATIC (trademark of Unisys Corporation), Programming for the UNIVAC (R) I and II, Data Automation Systems, copyrighted 1958, 1959, by Unisys Corporation; IBM Commercial Translator Form No. F28-8013, copyrighted 1959 by IBM; FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.

They have specifically authorized the use of this material, in whole or in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals or similar publications.

How to Order Additional Documentation

For information on pricing and where to buy documentation and other Compaq products in the United States and Canada, please call toll-free 1-800-282-6672.

Reader's Comments

Compaq appreciates your comments. If you find errors or want to comment about this manual, please send the manual title, order number, and your comments by one of the following methods:

User Programs and the Year 2000

Even subsequent to the turn of the century, there still exist potential disruptions in previously problem-free software where there are instances of a two-digit year field that should be a four-digit field. Programmers need to correct all such fields, as Compaq cannot prevent problems that originate in application code.

New Features

Consult the Index for entries under Version 2.7 -- what's new since V2.5. They will point you to information added since Version 2.5 of Compaq COBOL.


Chapter 1
Overview of the COBOL Language

This chapter provides information about the structure and language of COBOL source programs. It describes the elements of the COBOL language, reference formats, and language organization.

The COBOL language consists of the following components:

A separately compiled COBOL program is a program that, together with its contained programs (if present), is compiled separately from all other programs. Each COBOL program is divided into four parts, called divisions: the Identification Division, Environment Division, Data Division, and Procedure Division. Divisions can contain sections, which in turn can contain paragraphs. Paragraphs can contain sentences, clauses, statements, or entries.

The building blocks of these language components include the COBOL character set, character-strings, separators, punctuation, and literals.

A COBOL program is a string of characters that is syntactically correct according to the COBOL language rules.

1.1 The COBOL Character Set

The COBOL character set, shown in Table 1-1, is used to form character-strings and separators.

The only components of a COBOL program that can contain characters outside this set are nonnumeric literals, comment-entries, and comment lines. Appendix B specifies the more inclusive computer character sets these elements can use.

Table 1-1 The COBOL Character Set
Character Meaning
0, 1, ..., 9 digit
A, B, ..., Z letter
a, b, ..., z lowercase letter (equivalent to letter)
+ plus sign
- minus sign (hyphen)
* asterisk
/ slash (stroke, virgule)
\ backslash
= equal sign
$ currency sign
> greater than symbol
< less than symbol
: colon
_ underline (underscore)
  space
[Tab] horizontal tab
( left parenthesis
) right parenthesis
, comma (decimal point)
; semicolon
. period (decimal point, full stop)
" quotation mark (double quotation mark)
' apostrophe (single quotation mark)
{ left brace
} right brace
[ left bracket
] right bracket
« double left-angle brackets
» double right-angle brackets

Except in nonnumeric literals, the compiler treats lowercase letters as if they were uppercase. Therefore, a program can contain COBOL words without regard to case.1 For example, the compiler recognizes the COBOL words in each of the following pairs as identical:


WORKING-STORAGE      Working-Storage 
Input                input 
file-a               FILE-A 
INSPECT              InSpect 

Note

1 On Tru64 UNIX and Windows NT the case sensitivity of the system affects COBOL's case insensitivity in a few situations. See the Section 3.1.1 paragraph in Chapter 3, and the section on Section 6.8.4 in Chapter 6. Also see the Compaq COBOL User Manual for a description of the -names lowercase, -names uppercase, and -names as_is flags.

1.2 Character Strings

A character-string is a character or a sequence of contiguous characters that form a COBOL word, a literal, a PICTURE character-string, or a comment-entry. Separators delimit character-strings. The following sections describe these topics in detail.

1.2.1 COBOL Words

A COBOL word is a character-string of not more than 31 characters that forms one of the following:

A user-defined word or system-name cannot be a reserved word. However, a program can use the same COBOL word as both a user-defined word and a system-name. The compiler determines the word's class from its context.

1.2.1.1 User-Defined Words

A user-defined word is a COBOL word that you must supply to satisfy the format of a clause or statement. This word consists of characters selected from the set A to Z, 0 to 9, the currency sign ($), underline (_), and hyphen (-). Throughout this manual, and except where specific rules apply, the hyphen (-) and the underline (_) are treated as the same character in a user-defined word. The underline (_), however, can begin or end a user-defined word, and the hyphen (-) cannot. By convention, names containing a currency sign ($) are reserved for Compaq.

Table 1-2 provides brief descriptions of the COBOL user-defined words.

Table 1-2 COBOL User-Defined Words
User-Defined Word Purpose
Alphabet-Name Assigns a name to a character set, collating sequence, or both. Alphabet-names must be defined in the SPECIAL-NAMES paragraph. (See Section 4.1.3 in Chapter 4, Environment Division.)
Class-Name Relates a name to a specified set of characters listed in that clause. (See Section 4.1.3 in Chapter 4, Environment Division.)
Condition-Name Assigns a name to a value, set of values, or range of values in the complete set of values that a data item can have. Data items with one or more associated condition-names are called conditional variables.

Data Division entries define condition-names. Names assigned in the SPECIAL-NAMES paragraph to the "on" or "off" status of switches are also condition-names.

Data-Name Names a data item described in a data description entry. When specified in a general format, data-name cannot be reference modified, subscripted, indexed, or qualified unless specifically allowed by the rules for that format.
File-Name Names a file connector. A file connector is a storage area that contains information about a file and is the link between:
  • A file-name and a physical file
  • A file-name and its associated storage area

File description entries and sort-merge file description entries describe file connectors.

Index-Name Names an index associated with a specific table.
Level-Number Is a one- or two-digit number that describes a data item's special properties or its position in the structure of a record. (See Sections 5.1.1 and 5.1.2.)
Library-Name Names a COBOL library used in a source program compilation. (See the Section 8.1.1 statement in Chapter 8.)
Mnemonic-Name Associates a name with a system-name, such as CONSOLE, SYSERR, ARGUMENT-NUMBER, ENVIRONMENT-NAME, C01, OR SWITCH-8. (See Section 4.1.3 in Chapter 4.)
Paragraph-Name Names a Procedure Division paragraph. (See Section 2.1.3.) Paragraph-names are equivalent only if they are identical; that is, if they are composed of the same sequence and number of digits and/or characters.

For example:
START-UP START-UP Equivalent
START-UP STARTUP Different
Start-up START-UP Equivalent
001-START-UP 01-START-UP Different
017 017 Equivalent
017 17 Different

Program-Name Identifies a COBOL source program. (See the Section 3.1.1 paragraph in Chapter 3, and the section on Section 6.8.4 in Chapter 6, for a description of case-sensitivity on the Tru64 UNIX operating system. Also see the Compaq COBOL User Manual for a description of the -names lowercase , -names uppercase , and -names as_is flags.)
Record-Name Names a data item described with level-number 01 or 77.
Report-Name Names a report produced by the Report Writer Control System (RWCS). (See the Section 5.3.42 clause in Chapter 5.)
Screen-Name Names a screen item defined in the SCREEN SECTION of a program. (See the Section 5.3.6 section of Chapter 5.)
Section-Name Names a Procedure Division section. Section-names are equivalent only if they are identical; that is, when they are composed of the same sequence and number of digits and/or characters. (See Section 2.1.2.)
Segmented-Key-Name Identifies a segmented key, which is a concatenation of one or more (up to eight) data items (segments) within a record associated with an indexed file. A segmented key is a form of primary or alternate key. It offers flexibility in defining record description entries for indexed files. (See the section on segmented keys in the Compaq COBOL User Manual.)
Segment-Number Is a 1- or 2-digit number that classifies a Procedure Division section for segmentation. In Compaq COBOL programs, segment-numbers specify independent and fixed segments. (See Section 6.7.)
Symbolic-Character Identifies a user-defined figurative constant.
Text-Name Identifies library text in a COBOL library. (See the Section 8.1.1 statement in Chapter 8.)

Within a given program, but excluding any contained program, the user-defined words are grouped into the following disjoint sets:

alphabet-names
class-names
condition-names, data-names, and record-names
file-names
index-names
library-names
mnemonic-names
paragraph-names
program-names
report-names
screen-names
section-names
segmented-key-names
symbolic-characters
text-names


Next Contents Index