8–21 A HP COBOL Reserved Words B Character Sets C File Status Values D Report Writer Presentation Rules and Tables D.1 Organization.. This book describes the constructs and rules of the
Trang 1Revision/Update Information: This manual supersedes the
Compaq COBOL Reference Manual, Version 2.8 and the VAX COBOL Reference Manual, Version 5.4, as well
as the online-only Compaq COBOL Reference Manual, Version 2.8 and
Version 5.7
Operating System and Version: OpenVMS I64 Version 8.2
OpenVMS Alpha Version 6.2 or higherOpenVMS VAX Version 6.2 or higherTru64 UNIX Version 5.1 or higher
Software Version: HP COBOL for OpenVMS I64
Trang 2© Copyright 2005 Hewlett-Packard Development Company, L.P.
Confidential computer software Valid license from HP 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.
The information contained herein is subject to change without notice The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services Nothing herein should be construed as constituting an additional warranty HP shall not be liable for technical or editorial errors or omissions contained herein.
Intel and Itanium are trademarks or registered trademarks of Intel Corporation or its subsidiaries
in the United States and other countries.
Motif, UNIX®, and X/Open® are trademarks of The Open Group in the U.S and/or other countries All other product names mentioned herein may be trademarks of their respective companies Printed in the US
ZK6296 This manual is available on CD–ROM.
This document was prepared using DECdocument, Version 3.3-1b.
Trang 3Preface xiii
1 Overview of the COBOL Language
1.1 The COBOL Character Set 1–11.2 Character Strings 1–31.2.1 COBOL Words 1–31.2.1.1 User-Defined Words 1–31.2.1.2 System-Names 1–51.2.1.3 Reserved Words 1–61.2.1.4 Function-Names 1–101.2.2 Literals 1–101.2.2.1 Numeric Literals 1–101.2.2.2 Nonnumeric Literals 1–121.2.3 Figurative Constants 1–141.2.4 PICTURE Character-Strings 1–161.2.5 Separators 1–161.3 Source Reference Format 1–171.3.1 ANSI Format 1–181.3.2 Terminal Format 1–221.4 Sample Entry Format 1–23
2 Organization of a COBOL Program
2.1 Program Structure 2–22.1.1 Division Header 2–32.1.2 Section Header 2–42.1.3 Paragraph, Paragraph Header, Paragraph-Name 2–52.2 Data Division Entries 2–52.3 Declaratives 2–6
3 Identification Division
PROGRAM-ID 3–2AUTHOR 3–4DATE-COMPILED 3–5OPTIONS (Alpha, I64) 3–6
iii
Trang 44 Environment Division
4.1 CONFIGURATION Section 4–2
SOURCE-COMPUTER 4–3OBJECT-COMPUTER 4–4SPECIAL-NAMES 4–64.2 INPUT-OUTPUT Section 4–20
FILE-CONTROL 4–21ASSIGN 4–28BLOCK CONTAINS 4–31CODE-SET 4–32LOCK MODE (Alpha, I64) 4–33ORGANIZATION 4–34PADDING CHARACTER 4–35RECORD DELIMITER (OpenVMS) 4–36RESERVE 4–37I-O-CONTROL 4–38
5 Data Division
5.1 Logical Concepts of Data Storage 5–15.1.1 Record Description Entries 5–25.1.2 Level-Numbers 5–35.1.3 Multiple Record Description Entries for the Same Data 5–45.2 Physical Concepts of Data Storage 5–55.2.1 Categories and Classes of Data 5–65.2.2 COBOL Standard Alignment Rules 5–75.2.3 Additional Alignment Rules for Record Allocation 5–75.2.4 Alpha and I64 Alignment and Padding 5–155.3 DATA DIVISION General Format and Rules 5–16
FD (File Description) 5–20
SD (Sort-Merge File Description) 5–26
RD (Report Description) 5–27Data Description 5–30Report Group Description 5–34Screen Description (Alpha, I64) 5–38ACCESS MODE 5–43ALTERNATE RECORD KEY 5–45AUTO 5–48BACKGROUND-COLOR (Alpha, I64) 5–49BELL 5–50BLANK 5–51BLANK WHEN ZERO 5–52BLINK (Alpha, I64) 5–53CODE 5–54COLUMN NUMBER 5–55CONTROL 5–58
Trang 5ERASE (Alpha, I64) 5–64EXTERNAL 5–65FILE STATUS 5–67FOREGROUND-COLOR (Alpha, I64) 5–68FULL (Alpha, I64) 5–69GLOBAL 5–70GROUP INDICATE 5–71HIGHLIGHT (Alpha, I64) 5–73JUSTIFIED 5–74LABEL RECORDS 5–75Level-Number 5–76LINAGE 5–78LINE NUMBER (Alpha, I64) 5–82LOWLIGHT (Alpha, I64) 5–85NEXT GROUP 5–86OCCURS 5–88PAGE 5–92PICTURE 5–96RECORD 5–108RECORD KEY 5–111REDEFINES 5–113RENAMES 5–117REPORT 5–119REQUIRED (Alpha, I64) 5–120REVERSE-VIDEO (Alpha, I64) 5–121SECURE (Alpha, I64) 5–122SIGN 5–123SOURCE 5–126SUM 5–127SYNCHRONIZED 5–130TYPE 5–132UNDERLINE 5–137USAGE 5–138VALUE IS 5–150VALUE OF ID 5–156
6 Procedure Division
6.1 Verbs, Statements, and Sentences 6–16.1.1 Compiler-Directing Statements and Sentences 6–46.1.2 Imperative Statements and Sentences 6–56.1.3 Conditional Statements and Sentences 6–56.1.4 Scope of Statements 6–66.2 Uniqueness of Reference 6–76.2.1 Qualification 6–76.2.2 Subscripts and Indexes 6–106.2.3 Reference Modification 6–136.2.4 Identifiers 6–156.2.5 Ensuring Unique Condition-Names 6–15
v
Trang 66.2.6 Scope of Names 6–156.2.6.1 Conventions for Resolving Program-Name References 6–176.2.6.2 Conventions for Resolving Other References 6–216.2.7 External and Internal Data 6–236.3 Explicit and Implicit Specifications 6–246.3.1 Explicit and Implicit Procedure Division References 6–246.3.2 Explicit and Implicit Control Transfers 6–246.3.3 Explicit and Implicit Attributes 6–256.3.4 Explicit and Implicit Scope Terminators 6–256.4 Arithmetic Expressions 6–266.4.1 Arithmetic Operators 6–266.4.2 Formation and Evaluation of Arithmetic Expressions 6–276.4.3 Standard Arithmetic (Alpha, I64) 6–286.4.4 Native Arithmetic (Alpha, I64) 6–296.4.4.1 FLOAT Arithmetic (Alpha, I64) 6–296.4.4.2 CIT3 Arithmetic (Alpha, I64) 6–306.4.4.3 CIT4 Arithmetic (Alpha, I64) 6–306.5 Conditional Expressions 6–316.5.1 Relation Conditions 6–316.5.1.1 Comparison of Numeric Operands 6–326.5.1.2 Comparison of Nonnumeric Operands 6–326.5.2 Class Condition 6–336.5.3 Condition-Name Condition 6–346.5.4 Switch-Status Condition 6–356.5.5 Sign Condition 6–366.5.6 Success/Failure Condition 6–366.5.7 Complex Conditions 6–386.5.8 Abbreviated Combined Relation Conditions 6–396.5.9 Condition Evaluation Rules 6–406.6 Common Rules and Options for Data Handling 6–416.6.1 Arithmetic Operations 6–416.6.2 Multiple Receiving Fields in Arithmetic Statements 6–426.6.3 ROUNDED Phrase 6–426.6.4 ON SIZE ERROR Phrase 6–426.6.5 CORRESPONDING Phrase 6–436.6.6 ON EXCEPTION Phrase 6–446.6.7 Overlapping Operands and Incompatible Data 6–456.6.8 I-O Status 6–466.6.9 AT END Phrase 6–506.6.10 INVALID KEY Phrase 6–516.6.11 FROM Phrase 6–536.6.12 INTO Phrase 6–536.7 Segmentation 6–536.8 General Formats and Rules for Statements 6–54
ACCEPT 6–59ADD 6–84ALTER 6–87CALL 6–89CANCEL 6–95CLOSE 6–97COMPUTE 6–101
Trang 7DISPLAY 6–107DIVIDE 6–120EVALUATE 6–124EXIT 6–130EXIT PROGRAM 6–131GENERATE 6–132
GO TO 6–134
IF 6–136INITIALIZE 6–139INITIATE 6–142INSPECT 6–143MERGE 6–151MOVE 6–156MULTIPLY 6–161OPEN 6–164PERFORM 6–173READ 6–186RECORD (OpenVMS Only) 6–193RELEASE 6–195RETURN 6–196REWRITE 6–198SEARCH 6–202SET 6–209SORT 6–214START 6–222STOP 6–228STRING 6–229SUBTRACT 6–234SUPPRESS 6–237TERMINATE 6–238UNLOCK 6–239UNSTRING 6–244USE 6–250WRITE 6–254END PROGRAM 6–261
7 Intrinsic Functions
Intrinsic Function 7–2ACOS 7–8ANNUITY 7–9ARGCOUNT (OpenVMS Only) 7–10ASIN 7–11ATAN 7–12CHAR 7–13COS 7–14CURRENT-DATE 7–15
vii
Trang 8DATE-OF-INTEGER 7–17DATE-TO-YYYYMMDD 7–18DAY-OF-INTEGER 7–19DAY-TO-YYYYDDD 7–20FACTORIAL 7–21INTEGER 7–22INTEGER-OF-DATE 7–23INTEGER-OF-DAY 7–24INTEGER-PART 7–25LENGTH 7–26LOG 7–27LOG10 7–28LOWER-CASE 7–29MAX 7–30MEAN 7–32MEDIAN 7–33MIDRANGE 7–34MIN 7–35MOD 7–36NUMVAL 7–37NUMVAL-C 7–38ORD 7–39ORD-MAX 7–40ORD-MIN 7–41PRESENT-VALUE 7–42RANDOM 7–43RANGE 7–44REM 7–45REVERSE 7–46SIN 7–47SQRT 7–48STANDARD-DEVIATION 7–49SUM 7–50TAN 7–52TEST-DATE-YYYYMMDD 7–53TEST-DAY-YYYYDDD 7–54UPPER-CASE 7–55VARIANCE 7–56WHEN-COMPILED 7–57YEAR-TO-YYYY 7–59
Trang 98 Source Text Manipulation
8.1 Text-Word Definition Rules 8–1
COPY 8–3REPLACE 8–21
A HP COBOL Reserved Words
B Character Sets
C File Status Values
D Report Writer Presentation Rules and Tables
D.1 Organization D–1D.2 LINE NUMBER Clause Notation D–2D.3 LINE NUMBER Clause Sequence Substitutions D–2D.4 Saved-Next-Group-Integer Description D–2D.5 REPORT HEADING Group Presentation Rules D–3D.6 PAGE HEADING Group Presentation Rules D–5D.7 Body Group Presentation Rules D–6D.8 PAGE FOOTING Group Presentation Rules D–11D.9 REPORT FOOTING Group Presentation Rules D–13
E RTL Routines for Accessing the RAB and FAB Structures (OpenVMS
Alpha and I64 Only)
DCOB$RMS_CURRENT_FAB E–2DCOB$RMS_CURRENT_RAB E–3
ix
Trang 108–4 Matching a Nonnumeric Literal 8–138–5 Multiple-Line Pseudo-Text Replacement Item 8–148–6 Matching Pseudo-Text That Includes Separators 8–158–7 Command File That Creates Oracle CDD/Repository Directories and
Objects in Figure 8-1 (OpenVMS) 8–168–8 Using a Logical Name in a COPY Statement (OpenVMS) 8–188–9 Using a Full Pathname in a COPY Statement (OpenVMS) 8–198–10 Command File That Creates Oracle CDD/Repository Directories and
Objects in Figure 8-2 (OpenVMS) 8–20
Figures
1–1 Source Program Line 1–182–1 Structure of a COBOL Program 2–25–1 Hierarchical Record Structure 5–35–2 Level-Number Record Structure 5–45–3 Record Alignment Boundaries 5–85–4 Effect of Boundary and Location Equivalence Rules on Sample
Record 5–115–5 Storage Allocation for Sample Record 5–115–6 Storage Allocation Without and With Boundary Equivalence 5–125–7 Format 3 Clause Combinations 5–375–8 Control Break Levels and Their Printed Report Groups 5–595–9 Logical Page Areas Resulting from a LINAGE Clause 5–815–10 PICTURE Symbol Precedence Rules 5–1076–1 Possible Combinations of Status Keys 1 and 2 6–476–2 Valid and Invalid Nested PERFORM Statements 6–1776–3 PERFORM VARYING with the TEST BEFORE Phrase and One
Condition 6–1796–4 PERFORM VARYING with the TEST BEFORE Phrase and Two
Conditions 6–1806–5 PERFORM VARYING with the TEST AFTER Phrase and One
Condition 6–1816–6 PERFORM VARYING with the TEST AFTER Phrase and Two
Conditions 6–1838–1 Hierarchical Repository Structure (OpenVMS) 8–158–2 Nonhierarchical Repository Structure (OpenVMS) 8–19D–1 REPORT HEADING Group Presentation Rules D–3D–2 PAGE HEADING Group Presentation Rules Table D–5D–3 Body Group Presentation Rules D–7D–4 PAGE FOOTING Group Presentation Rules D–12D–5 REPORT FOOTING Group Presentation Rules D–14
Trang 111–1 The COBOL Character Set 1–21–2 COBOL User-Defined Words 1–31–3 Special Registers 1–71–4 Numeric Literals 1–111–5 Floating-Point Literals 1–121–6 Nonnumeric Literals 1–131–7 Hexadecimal Literals 1–141–8 Figurative Constants 1–151–9 Separators 1–164–1 CRT STATUS Termination Codes (Alpha, I64) 4–154–2 Required Manual Record-Locking Phrases (Hewlett-Packard
Standard) 4–415–1 Maximum Physical Record Size for Tape and Disk Devices 5–65–2 Classes and Categories of Data Items 5–75–3 Comparison of Major-Minor and Left-Right Locations 5–95–4 Alpha Alignment and Padding 5–155–5 Color Table 5–415–6 Page Regions Established by the PAGE Clause 5–955–7 Summary of PICTURE Clause Rules 5–975–8 PICTURE Clause Symbols 5–985–9 Using Sign Control Symbols in Fixed Insertion Editing 5–1035–10 Using Sign Control Symbols in Floating Insertion Editing 5–1045–11 Positive and Negative Signs for All Numeric Digits 5–1245–12 Unscaled Data Items, Allocated Storage, and Corresponding Data
Types 5–1415–13 Scaled Data Items, Allocated Storage, and Data Types 5–1466–1 Types and Categories of COBOL Statements 6–26–2 Contents of COBOL Sentences 6–46–3 Relational Operators and Corresponding True Conditions 6–326–4 How Logical Operators Affect Evaluation of Conditions 6–386–5 Combinations of Conditions, Logical Operators, and Parentheses 6–396–6 Expanded Equivalents for Abbreviated Combined Relation
Conditions 6–406–7 Relation of GIVING Phrase to RETURN-CODE Special Register
(Alpha, I64) 6–576–8 Field Editing Keys for OpenVMS Systems 6–736–9 Field Editing Keys for Tru64 UNIX Systems 6–746–10 SCREEN SECTION Keys for OpenVMS Alpha and I64 Systems 6–776–11 SCREEN SECTION Keys for Tru64 UNIX Systems 6–786–12 Effects of CLOSE Statement Formats on Files by Category 6–986–13 Valid MOVE Statements 6–1596–14 Opening Available and Unavailable Sequential, Line Sequential
(Alpha, I64), Relative, and Indexed Files 6–1666–15 Allowable Input-Output Statements for Sequential, Line Sequential
(Alpha, I64), Relative, and Indexed Files 6–1676–16 Opening Available and Unavailable Report Writer Files 6–171
xi
Trang 126–17 Allowable Statements for Report Writer Files 6–1716–18 Validity of Operand Combinations in Format 1 SET Statements 6–2117–1 Intrinsic Functions 7–48–1 Oracle CDD/Repository Data Types and HP COBOL Equivalents
(OpenVMS) 8–8C–1 I-O File Status Values for the Default -std 85 Flag or /STANDARD=85
Qualifier Option C–1C–2 I-O File Status Values for the V3 and 85 Options C–3
Trang 13This book describes the constructs and rules of the HP COBOL programminglanguage, which is a Hewlett-Packard Company implementation of COBOL(COmmon Business-Oriented Language) for the OpenVMS and Tru64 UNIXplatforms 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 HP COBOL User Manual and, optionally, the HP COBOL DBMS Database Programming Manual.
HP COBOL is the new name for what has formerly been known as CompaqCOBOL, DEC COBOL, DIGITAL COBOL, and VAX COBOL HP COBOL,unmodified, refers to the following products:
HP COBOL for OpenVMS Industry Standard 64
HP COBOL for OpenVMS Alpha
HP COBOL for Tru64 UNIX
HP COBOL for OpenVMS VAXAny references to the former names in product documentation or othercomponents should be construed as references to the HP COBOL names
Intended Audience
This manual is intended for experienced applications programmers who have athorough understanding of the COBOL language and some familiarity with theiroperating system This is not a tutorial manual
If you are a new COBOL user, you may need to read introductory COBOLtextbooks or take COBOL courses
Structure of This Document
This manual is organized as follows:
• Chapter 1 presents the elements of the COBOL language, describes twoformat options for a COBOL program, and explains how the remainingchapters organize and present the COBOL general formats
• Chapter 2 describes the organization of a COBOL program It presents thegeneral format for the four COBOL divisions and introduces the concept ofcontained programs This chapter shows the relationship between a programname and a source file name
• Chapter 3 describes the general format and contents of the IdentificationDivision It explains how to identify a COBOL program and its source listing
• Chapter 4 describes the general format and contents of the EnvironmentDivision It explains how to describe the program’s physical environment
xiii
Trang 14• Chapter 5 describes the general format and contents of the Data Division Itexplains how to describe data the program receives, creates, manipulates, andproduces as output.
• Chapter 6 describes the general format and contents of the ProcedureDivision It describes COBOL verbs, which process the files and data in theEnvironment and Data Divisions
• Chapter 7 describes the general format and use of the intrinsic functions
• Chapter 8 describes the general format of the COPY and REPLACEstatements
• Appendix A lists the HP COBOL reserved words, which are words that cannot
be used as system names or user-defined names
• Appendix B lists the ASCII, EBCDIC, and NATIVE character sets
• Appendix C lists the exception condition values that can appear in File Statusdata items
• Appendix D contains individual presentation rules and tables for each type ofreport group
• Appendix E describes RTL routines for accessing the RAB and FAB structures
HP COBOL User Manual
This manual describes how to use features of the HP COBOL language to developprograms on the Tru64 UNIX operating system or the OpenVMS operatingsystems on Alpha, I64, and VAX
Release Notes
Consult the HP COBOL release notes for your installed version for latecorrections and new features
On the OpenVMS Alpha, I64, or VAX operating system, the release notes are in:
SYS$HELP:COBOLnnn.RELEASE_NOTES (ASCII text) SYS$HELP:COBOLnnn_RELEASE_NOTES.PS
Where nnn is the version and release number.
On the Tru64 UNIX operating system, the release notes are in:
/usr/lib/cmplrs/cobol/relnotes
Compaq COBOL for Tru64 UNIX Systems Installation Guide
This manual provides instructions for installing HP COBOL on the Tru64 UNIXoperating system
Trang 15Compaq COBOL for OpenVMS VAX Systems Installation Guide
This manual provides instructions for installing HP COBOL on the OpenVMSVAX operating system
HP COBOL DBMS Database Programming Manual
This manual provides information on using HP COBOL for databaseprogramming with Oracle CODASYL DBMS on the OpenVMS Alpha, theOpenVMS I64, or OpenVMS VAX operating systems
The OpenVMS Calling Standard and other manuals in the OpenVMS
Documentation Set
This set contains information about using the features of the OpenVMS I64,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
Related Documents
For additional information about HP OpenVMS products and services, visit thefollowing World Wide Web address:
http://www.hp.com/go/openvms
Conventions Used in This Document
The following product names may appear in this manual:
• HP OpenVMS Industry Standard 64 for Integrity servers
• OpenVMS I64
• I64All three names—the longer form and the two abbreviated forms—refer to theversion of the OpenVMS operating system that runs on the Intel® Itanium®architecture
The following table lists the conventions used in this manual:
Ctrl/x A sequence such as Ctrl/x indicates that you must hold down
the key labeled Ctrl while you press another key or a pointing device button.
♦ A diamond signals the end of a section of system-specific
information The beginning of a system-specific section is identified in the text or header as Alpha (meaning OpenVMS Alpha and Tru64 UNIX Alpha, and excluding OpenVMS VAX);
or as OpenVMS (meaning both OpenVMS Alpha, OpenVMS I64 and OpenVMS VAX); or as Tru64 UNIX.
RECORD KEY IS Underlined uppercase words are required when used in a
general format Uppercase words not underlined are optional.
xv
Trang 16Convention Meaning
sortfile Lowercase words used in a general format are generic terms
that indicate entries you must provide.
8 9 Braces used in a general format enclose lists from which you
must choose only one item For example:
( SEQUENTIALRANDOMDYNAMIC
)
2 3 Brackets used in a general format enclose optional items from
which you can choose none or one For example:
RECORDALL RECORDS
Choice indicators, vertical lines inside a set of braces, used in a
general format enclose lists from which you must choose one or more items, using each item chosen only once For example:
8
<
:
COMMONINITIAL
... data-page="18">
COBOL HP COBOL for OpenVMS VAX was formerly known as Compaq COBOLfor OpenVMS VAX, VAX COBOL or as DIGITAL VAX COBOL.
Acknowledgement
COBOL is an industry... )-list (Tru64 UNIX flag )
COBOL This term refers to language information common to ANSI-85
COBOL, HP COBOL, and HP COBOL for OpenVMS VAX.
Enter... to the HP COBOL User Manual for programming examples For an explanation and a listing of RMS STS and STV values, refer to the OpenVMS System Messages and Recovery Procedures Reference Manual,