HP COBOL II/XL Reference Manual MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
Table of Contents
HP COBOL II/XL Reference Manual
HP COBOL II/XL Reference Manual : COPYRIGHT NOTICE
Ch 1. Introduction
ANSI Standard Compliance
ANSI COBOL'85 Features in HP COBOL II
ANSI Features Added Since ANSI COBOL'85
Compatibility Considerations
Compatibility between ANSI COBOL'74 and ANSI COBOL'85
Compatibility of COBOL Functions
HP Extensions
Portability to HP from Other Vendors
Portability between HP COBOL II/V and HP COBOL II/XL
Ch 2. Program Structure
Structural Hierarchy
Divisions
Division Format
Division Header Format
Sections
Section Format
Section Header Format
Paragraphs
Paragraph Format
Paragraph Header and Name Format
Sentences, Statements, and Clauses
Ch 3. Program Elements
Character Strings
Words
Reserved Words
Keywords
Optional Words
Special Register Words
Figurative Constants
Special Character Words
User-Defined Words
System Names
Function-Names
Literals
Numeric Literals
Octal Literals
Examples
Nonnumeric Literals
Single and Double Quotation Marks in Nonnumeric Literals
Embedded Quotation Marks in Nonnumeric Literals
PICTURE Character Strings
Comment Entries
Comment Lines
Separators
Character Set
Coding Rules
Sequence Number (Columns 1 through 6)
Program Text (Columns 8 through 72)
Continuation Lines
Examples
Debugging Lines
Identification Code (Columns 73-80)
Ch 4. Describing and Referencing Data
Files
Records
Logical Versus Physical Records
Record Descriptions
Level 66, 77, and 88 Items
Data Items - Classes and Categories
Classes of Data Items
Categories of Data Items
Algebraic Signs
Operational Signs
Editing Signs
Data Alignment
Identifiers
Uniqueness of Reference
Qualifiers
Example
Tables
Defining a Table
Referencing Table Items with Subscripting
Referencing Table Items with Indexing
Condition Names
Function-Identifiers
Syntax
Parameters
Description
Evaluation of Function Parameters
Reference Modification
Syntax
Parameters
Reference Modification Rules
Examples
Ch 5. IDENTIFICATION DIVISION
IDENTIFICATION DIVISION Format
IDENTIFICATION DIVISION Syntax Rules
Paragraphs
PROGRAM-ID Paragraph
Example
DATE-COMPILED Paragraph
Other Paragraphs
Ch 6. ENVIRONMENT DIVISION
ENVIRONMENT DIVISION Format
ENVIRONMENT DIVISION Syntax Rules
CONFIGURATION SECTION
SOURCE-COMPUTER Paragraph
Syntax
OBJECT-COMPUTER Paragraph
Syntax
Parameters
MEMORY-SIZE Clause
PROGRAM COLLATING SEQUENCE Clause
SEGMENT-LIMIT Clause
SPECIAL-NAMES Paragraph
Syntax
Parameters
Feature-name, Switch-name, or Device-name Clause
Syntax
Parameters
Description
Software Switches
Line Printer Features
CONDITION-CODE Features
SYSIN, SYSOUT, and CONSOLE Devices
ALPHABET Clause
Syntax
Parameters
STANDARD-1, STANDARD-2 and NATIVE Phrases
EBCDIC and EBCDIK Phrases
LITERAL Phrase
Defining Your Own Collating Sequence
Example
SYMBOLIC CHARACTERS Clause
Syntax
Parameters
CLASS Clause
Syntax
Parameters
Example
CURRENCY SIGN IS Clause
Syntax
Parameters
Description
Example
DECIMAL POINT IS COMMA Clause
Syntax
Description
INPUT-OUTPUT SECTION
FILE-CONTROL Paragraph
Sequential Files
Random Access Files
Relative Files
Sequential Access
Random Access
Dynamic Access
Indexed Files
Sequential Access
Random Access
Dynamic Access
Sort-Merge Files
File Status
Fixed Length Records
Variable Length Records
File Control Clauses
SELECT Clause
Syntax
Parameters
OPTIONAL Phrase
ASSIGN Clause
Syntax
Parameters
Description
File Status Code
ACCESS MODE Clause
Syntax
Parameters
ACTUAL KEY Clause (an HP extension to the ANSI COBOL standard)
Syntax
Parameters
Example
ALTERNATE RECORD KEY Clause
Syntax
Parameters
DUPLICATES Phrase
FILE STATUS Clause
Syntax
Parameters
Description
ORGANIZATION Clause
Syntax
Description
RECORD KEY Clause
Syntax
Parameters
DUPLICATES Phrase
RESERVE Clause
Syntax
Parameters
Description
Example
I-O-CONTROL Paragraph
Syntax
SAME Clause
Syntax
SAME AREA Clause
SAME RECORD AREA Clause
SAME SORT AREA and SAME SORT-MERGE AREA Clauses
MULTIPLE FILE Clause
Syntax
Description
Ch 7. DATA DIVISION
DATA DIVISION Format
DATA DIVISION Syntax Rules
FILE SECTION
WORKING-STORAGE SECTION
LINKAGE SECTION
DATA DIVISION Clauses
File Description Clauses
FD Level Indicator - For Data File Descriptions
Syntax
Parameters
Description
SD Level Indicator - For Sort File Descriptions
Syntax
Parameters
Description
BLOCK CONTAINS Clause
Syntax
Parameters
Description
CODE-SET Clause
Syntax
Parameters
Description
DATA RECORDS Clause
Syntax
Parameters
Description
EXTERNAL Clause
Syntax
Description
GLOBAL Clause
Syntax
Description
LABEL RECORDS Clause
Syntax
Parameters
Description
LINAGE Clause
Syntax
Parameters
Description
FOOTING Phrase
LINES AT TOP and LINES AT BOTTOM Phrases
Use of Data Names Versus Use of Integers
LINAGE-COUNTER
RECORD CONTAINS Clause
Syntax
Parameters
Description
Fixed Length Records
Variable Length Records
Example
RECORDING MODE Clause
Syntax
Parameters
Description
VALUE OF Clause
Syntax
Parameters
Description
Example
Data Description Entries
77 Level Description Entries
Record Description Entries
Data Name or FILLER Clause
Syntax
Parameters
Description
BLANK WHEN ZERO Clause
Syntax
EXTERNAL Clause
Syntax
Description
GLOBAL Clause
Syntax
Description
JUSTIFIED Clause
Syntax
Parameters
Description
Example
OCCURS Clause
Syntax
Parameters to Format 1
Parameters to Format 2
Examples
PICTURE Clause
Syntax
Parameters
Description
Alphabetic Data
Numeric Data
Data Description Entries (continued)
Alphanumeric Data
Alphanumeric-Edited Data
Numeric-Edited Data
Size of Elementary Data Items
Examples
Editing Rules
Simple Insertion Editing
Special Insertion Editing
Fixed Insertion Editing
Floating Insertion Editing
Zero Suppression Editing
Precedence Rules
REDEFINES Clause
Syntax
Parameters
Description
Examples
SIGN Clause
Syntax
Parameters
Description
SYNCHRONIZED Clause
Syntax
Description
Slack Bytes
Example
USAGE Clause
Syntax
Parameters
Description
USAGE IS DISPLAY
USAGE IS BINARY or COMPUTATIONAL
USAGE IS PACKED-DECIMAL or COMPUTATIONAL-3
USAGE IS INDEX
VALUE Clause
Syntax
Parameters
Description
Restrictions on the Use of the VALUE Clause
Literals in the VALUE Clause
RENAMES Clause
Syntax
Parameters
Description
Example
Condition Names
Syntax
Parameters
Description
Example
Ch 8. PROCEDURE DIVISION
PROCEDURE DIVISION Header
USING Clause
PROCEDURE DIVISION Format
PROCEDURE DIVISION Syntax Rules
Declarative Sections
Procedures
Sections and Section Headers
Segmentation
Segment Numbers
PROCEDURE DIVISION Statements and Sentences
Conditional Statements and Sentences
Compiler Directing Statements and Sentences
Imperative Statements and Sentences
Categories of Statements
Scope Terminators
Examples
Arithmetic Expressions
Arithmetic Operators
Hierarchy of Operations
Use of Parentheses
Valid Combinations in Arithmetic Expressions
Exponentiation
Conditional Expressions
Simple Conditions
Sign Condition
Parameters
Example
Class Condition
Syntax
Parameters
Description
Switch-Status Condition
Parameter
Example
Relation Conditions
ANSI Standard Relation Conditions
Parameters
Comparison of Numeric Operands.
Comparisons Using Index Names and Index Data Items.
Comparison of Nonnumeric Operands.
Example
Condition Name Conditions
Parameter
Example
Intrinsic Relation Conditions
Syntax
Parameter
Description
Examples
Correct Example
Incorrect Examples
Complex Conditions
Combined Conditions
Parameter
Negated Simple Conditions
Parameter
Example
Condition Evaluation Rules
Abbreviated Combined Relation Conditions
Examples
Common Phrases
NOT Phrases
ROUNDED Phrase
SIZE ERROR Phrase
Example 1
Example 2
CORRESPONDING Phrase
Example
Common Features of Arithmetic Statements
Example
Overlapping Operands and Incompatible Data
Variable-Length Receiving Items
Input-Output Error Handling Procedures
Ch 9. PROCEDURE DIVISION Statements
ACCEPT Statement
Syntax
Parameters
ACCEPT Statement - Formats 1 and 2
FREE and INPUT ERROR Phrases
Example
ACCEPT Statement Without the FREE Phrase
Programming Considerations
Examples
Example 1: Minus sign conversion method
Example 2: Use of SIGN IS LEADING SEPARATE phrase
ACCEPT Statement - Format 3
Example
ADD Statement
Syntax
Parameters
Description
Example
ALTER Statement
Syntax
Parameters
Segmentation Considerations
CALL Statement
CANCEL Statement
CLOSE Statement
Syntax
Sequential Files - Format 1
Description
REEL/UNIT and REMOVAL Phrases
NO REWIND Phrase
WITH LOCK Phrase
Random, Relative and Indexed Files - Format 2
Example
COMPUTE Statement
Syntax
Parameters
Calculation of Intermediate Results
CONTINUE Statement
Syntax
Description
Example
DELETE Statement
Syntax
Parameters
Description
Example
DISPLAY Statement
Syntax
Parameters
Description
Length of Data Being Displayed
The WITH NO ADVANCING Phrase
Example 1
Example 2
DIVIDE Statement
Syntax
Parameters
Description
Example
ENTER Statement
ENTRY Statement
EVALUATE Statement
Syntax
Subjects and Objects
Correspondence Between Subjects and Objects
Evaluation of Subjects and Objects
Comparison Operation of EVALUATE
Execution of EVALUATE
Examples
EXAMINE Statement
Syntax
Parameters
Description
TALLYING Phrase
REPLACING Phrase
EXCLUSIVE Statement
Syntax
Parameters
Description
Example
EXIT Statement
Syntax
Example
EXIT PROGRAM Statement
GOBACK Statement
GO TO Statement
Syntax
Parameters
Description
Examples
IF Statement
Syntax
Parameters
Description
Example
INITIALIZE Statement
Syntax
Parameters
Description
Initializing Data Fields
Example
INSPECT Statement
Syntax
Parameters
Description
CONVERTING Phrase
Example
How the Comparison Operation Occurs
Example
BEFORE and AFTER Phrases
LEADING Phrase
ALL Phrase
CHARACTERS Phrase
FIRST Phrase
Examples
MOVE Statement
Syntax
Parameters
Description
Rules For Moving Data
Rules For Elementary Moves
Alphanumeric or Alphanumeric-Edited Receiving Item
Numeric or Numeric-Edited Receiving Item
Alphabetic Receiving Item
Example
MULTIPLY Statement
Syntax
Parameters
Description
Examples
OPEN Statement
Syntax
Description
Label Records
EXTEND, REVERSE, and NO REWIND Phrases
Permissible Statements
FILE STATUS Data Item
PERFORM Statement
Parameters
Syntax
Format 4 PERFORM Statement (PERFORM...VARYING)
Variation of a Single Identifier
Out-of-Line PERFORM
In-Line PERFORM
General Rules of PERFORM
Range of the PERFORM Statement
Nested PERFORM Statements
PERFORM Constructs
Variation of Two or More Identifiers
ANSI COBOL'74
ANSI COBOL'85
Variation of More than Two Identifiers
Incompatibility Between ANSI COBOL'74 and ANSI COBOL'85
Examples
READ Statement
Syntax
Parameters
Description
READ Statement - Format 1
READ Statement - Format 2
READ Statement - Format 3
RELEASE Statement
RETURN Statement
REWRITE Statement
Syntax
Parameters
Description
FROM Phrase
SEARCH Statement
Syntax
Parameters
Description
SEARCH Statement - Format 1
VARYING Phrase
SEARCH Statement - Format 2
Example
SEEK Statement
Syntax
Description
SET Statement
Syntax
Parameters
SET Statement - Format 1
SET Statement - Format 2
SET Statement - Format 3
SET Statement - Format 4
START Statement
Syntax
Parameters
Description
STOP Statement
Syntax
Parameters
Description
STRING Statement
Syntax
Parameters
Description
Execution of the STRING Statement
Examples
SUBTRACT Statement
Syntax
Parameters
Description
Examples
UN-EXCLUSIVE Statement
Syntax
Parameter
Description
UNSTRING Statement
Syntax
Parameters
Description
Execution of the UNSTRING Statement
Overflow Conditions
Subscripting or Indexing of Identifiers
Example
USE Statement
Syntax
Parameters
Description
USE Statement - Format 1
USE Statement - Format 2
WRITE Statement
Syntax
Parameters
Description
FROM Phrase
WRITE Statement - Format 1
ADVANCING Phrase
END-OF-PAGE Phrase
Bounds Overflow
Multiple Reel/Unit Files
Print Files
Carriage Control Codes
WRITE Statement - Format 2
Random Access Files
Relative Files
INVALID KEY Conditions For a Relative File
Indexed Files
INVALID KEY Conditions For Indexed Files
Ch 10. COBOL Functions
The $CONTROL POST85 Option
ANSI85 Entry Point
Function Types
Function Parameters
Using ALL as a Table Subscript
Precision of Numeric Functions
Calling COBOL Functions
Examples
ACOS Function
Syntax
Parameters
Return Value
Example
ANNUITY Function
Syntax
Parameters
Return Value
Example
ASIN Function
Syntax
Parameters
Return Value
Example
ATAN Function
Syntax
Parameters
Return Value
Example
CHAR Function
Syntax
Parameters
Return Value
Example
COS Function
Syntax
Parameters
Return Value
Example
CURRENT-DATE Function
Syntax
Return Values
Setting the TZ Environment Variable
Example
DATE-OF-INTEGER Function
Syntax
Parameters
Return Value
Example
DAY-OF-INTEGER Function
Syntax
Parameters
Return Value
Example
FACTORIAL Function
Syntax
Parameters
Return Value
Example
INTEGER Function
Syntax
Parameters
Return Value
Example
INTEGER-OF-DATE Function
Syntax
Parameters
Return Value
Example
INTEGER-OF-DAY Function
Syntax
Parameters
Return Value
Example
INTEGER-PART Function
Syntax
Parameters
Return Value
Example
LENGTH Function
Syntax
Parameters
Return Values
Example 1
Example 2
LOG Function
Syntax
Parameters
Return Value
Example
LOG10 Function
Syntax
Parameters
Return Value
Example
LOWER-CASE Function
Syntax
Parameters
Return Value
Example
MAX Function
Syntax
Parameters
Return Values
Example
MEAN Function
Syntax
Parameters
Return Value
Example
MEDIAN Function
Syntax
Parameters
Return Value
Example
MIDRANGE Function
Syntax
Parameters
Return Value
Example
MIN Function
Syntax
Parameters
Return Value
Example
MOD Function
Syntax
Parameters
Return Value
Example
NUMVAL Function
Syntax
Parameters
Return Value
Example
NUMVAL-C Function
Syntax
Parameters
Return Value
Example 1
Example 2
ORD Function
Syntax
Parameters
Return Value
Example
ORD-MAX Function
Syntax
Parameters
Return Value
Example
ORD-MIN Function
Syntax
Parameters
Return Value
Example
PRESENT-VALUE Function
Syntax
Parameters
Return Value
Example
RANDOM Function
Syntax
Parameters
Return Value
Example
RANGE Function
Syntax
Parameters
Return Value
Example
REM Function
Syntax
Parameters
Return Value
Example
REVERSE Function
Syntax
Parameters
Return Value
Example
SIN Function
Syntax
Parameters
Return Value
Example
SQRT Function
Syntax
Parameters
Return Value
Example
STANDARD-DEVIATION Function
Syntax
Parameters
Return Value
Example
SUM Function
Syntax
Parameters
Return Value
Example
TAN Function
Syntax
Parameters
Return Value
Example
UPPER-CASE Function
Syntax
Parameters
Return Value
Example
VARIANCE Function
Syntax
Parameters
Return Value
Example
WHEN-COMPILED Function
Syntax
Return Value
Setting the TZ Environment Variable
Example
Ch 11. Interprogram Communication
Transfer of Control
Reference to Common Data and Files
Reference to Common Data through Parameter Passing
Reference to Common Data and Files through External Objects
PROGRAM-ID Paragraph
Syntax
Description
COMMON Clause
EXTERNAL Clause
Syntax
Description
Example
GLOBAL Clause
Syntax
Description
Types of Subprograms
Non-Dynamic Subprograms
Dynamic Subprograms
ANSISUB Subprograms
END PROGRAM Header
Syntax
Description
CALL Statement
Syntax
Parameters
Description
Example
Calling Intrinsics
Example
Execution-Time Loading
Pseudo-Intrinsics
.LOC. Pseudo-Intrinsic
.LEN. Pseudo-Intrinsic
Example
USING Phrase (COBOL Subprograms)
BY REFERENCE Phrase
BY CONTENT Phrase
USING Phrase (Non-COBOL Subprograms)
GIVING Phrase When Calling COBOL Subprograms
RETURN-CODE Special Register
Example
GIVING Phrase When Calling Non-COBOL Subprograms
CANCEL Statement
Syntax
Parameters
Description
ENTRY Statement
Syntax
Parameters
Description
Example
EXIT PROGRAM Statement
Syntax
Description
GOBACK Statement
Syntax
Description
Ch 12. SORT/MERGE Operations
MERGE Statement
Syntax
Parameters
Description
COLLATING SEQUENCE Phrase
GIVING and OUTPUT PROCEDURE Phrases
Segmentation Considerations
RELEASE Statement
Syntax
Parameters
Description
RETURN Statement
Syntax
Parameters
Description
INTO Phrase
AT END Phrase
SORT Statement
Syntax
Parameters
Description
Examples
DUPLICATES Phrase
ASCENDING and DESCENDING Phrases
COLLATING SEQUENCE Phrase
USING and INPUT PROCEDURE Phrases
GIVING and OUTPUT PROCEDURE Phrases
Sorting Large Files
Segmentation Considerations
Ch 13. Debug Module
WITH DEBUGGING MODE Clause
Syntax
USE FOR DEBUGGING statement
Syntax
Debugging Lines
The ANSI Debug Module Example
Using the ANSI Debug Module Example
Ch 14. Source Text Manipulation
COPY Statement
Syntax
Parameters
Description
REPLACING Phrase
Example 1
Example 2
REPLACE Statement
Syntax
Parameters
Description
Example 1
Example 2
Ap A. HP COBOL II Error Messages
Reading Error Messages from COBCAT
Example
Compile-Time Error Messages
Run-Time Error Messages
Warnings
Questionable Errors
Questionable Errors (Continued)
Serious Errors
Disastrous Errors
Nonstandard Warnings
Run-Time Errors
Informational Messages
Ap B. Preprocessor Commands and $CONTROL Options
Types of Processes
Preprocessor Programming Language
Parameters
Description
Continuation Lines
Example
$COMMENT Command
Defining and Using Macros
$DEFINE Command
Syntax
Parameters
Description
Example
Formal Parameters
Macro Calls
Parameters
Relationship of Formal Parameters to Actual Parameters
Examples
Nested Macro Calls
Example 1
Example 2
$PREPROCESSOR Command
Parameters
Example
Conditional Compilation
$SET Command
$IF Command
Example
File Insertion, and Merging and Editing Operations
$INCLUDE Command
Example
Merging Files and the $EDIT Command
Merging Files
Sequence Field Checking
$EDIT Command
Parameters
VOID Parameter
SEQNUM Parameter
NOSEQ Parameter
INC Parameter
Compiler-Dependent Options
$COPYRIGHT Command
Syntax
Parameter
Description
Examples
$PAGE Command
Syntax
Parameter
Description
$TITLE Command
Syntax
Parameters
Description
$VERSION Command
Syntax
Parameter
Description
Examples
$CONTROL Command
Parameters
ANSISORT
ANSISUB
BOUNDS
CHECKSYNTAX
CODE
NOCODE
CROSSREF
NOCROSSREF
DEBUG
DIFF74, DIFF74=OBS, and DIFF74=INC
DYNAMIC
ERRORS=number
LINES=number
LIST
NOLIST
LOCKING
LOCOFF
LOCON
MAP
NOMAP
MIXED
NOMIXED
QUOTE = " '
SOURCE
NOSOURCE
STAT74
STDWARN
NOSTDWARN
SUBPROGRAM
SYMDEBUG
SYNC16 and SYNC32
USLINIT
VERBS
NOVERBS
WARN
NOWARN
The COBCNTL FILE
Ap C. Differences Between ANSI COBOL'74 and ANSI COBOL'85
ANSI74 Entry Point Differences
Incompatibilities between ANSI COBOL'74 and ANSI COBOL'85
Syntax Incompatibilities
Run-time Incompatibilities
Obsolete Features
Ap D. ASCII and EBCDIC Character Sets
How to Use This Table
Example 1
Example 2
Ap E. COBOL Glossary
Definitions
Ap F. COBOL Reserved Word List
Ap G. COBEDIT Program and COPY Libraries
The COBEDIT Program
COPY Libraries
COBEDIT Commands
BUILD Command
Syntax
Parameters
Description
Examples
Example
COPY Command
Syntax
Example
EDIT Command
Syntax
Parameters
Description
Example 1
Example 2
Example 3
EXIT Command
Syntax
Description
Example 1
Example 2
Example 3
HELP Command
Syntax
Example
KEEP Command
Syntax
Parameters
Description
Example 1
Example 2
LIBRARY Command
Syntax
Parameters
Description
Example
LIST Command
Syntax
Parameters
Description
Example of Redirection
Example of Batch Job
Example
PURGE Command
Syntax
Parameters
Description
Example
SHOW Command
Syntax
Example
Ap H. MPE XL System Dependencies
Introduction
Compiling, Linking, and Executing Programs
Overview
Command Files
Syntax
Parameters
Compiling Your Program With the RUN Command
Syntax
Parameters
Linking Your Program
Executing Your Program with the RUN Command
Setting Software Switches
Setting the Object-Time Debug Module Switch
Control Options
MPE XL-Specific Control Options
CALLINTRINSIC
CMCALL
INDEX16 and INDEX32
NLS
Syntax
Location
Default
Limitations
Example 1
Example 2
OPTFEATURES
Syntax
Example
OPTIMIZE
Syntax
POST85
RLFILE and RLINIT
SYMDEBUG=XDB
VALIDATE and NOVALIDATE
Control Options that Work Differently
ANSISUB
BOUNDS
CODE
USLINIT
Obsolete Control Options
Data Alignment and Limits on MPE XL
Alignment
Limits on Data Items
HP COBOL II/XL Language Dependencies
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION
Interprogram Communication
External Names
Subprogram Types
Calling Intrinsics
.LOC. Pseudo-Intrinsic
Parameter Alignment
Run-Time Trap Handling
Supported Traps
Handling Run-Time Errors with COBRUNTIME
Setting COBRUNTIME
Example
The COBOL Trap Mechanism and Other Languages
Example 1
Example 2
Example 3
Example HP COBOL II/XL Program
INDEX
Index
MPE/iX 5.0 Documentation