Developer for System z
COBOL for Windows, Version 7.5, Language Reference
Contents
About this document
Accessibility of this document
IBM extensions
Obsolete language elements
How to read the syntax diagrams
DBCS notation
Acknowledgment
Summary of changes
Version 7 (December 2006)
Version 6 (May 2005)
How to send your comments
COBOL language structure
Characters
Character sets and code pages
Compile-time code page
Runtime code page
Character encoding units
Single-byte code pages
Multibyte code pages
Unicode UTF-16
Character-strings
COBOL words with single-byte characters
User-defined words with multibyte characters
User-defined words
System-names
Function-names
Reserved words
Figurative constants
Special registers
ADDRESS OF
DEBUG-ITEM
JNIENVPTR
LENGTH OF
LINAGE-COUNTER
RETURN-CODE
SHIFT-OUT and SHIFT-IN
SORT-CONTROL
SORT-CORE-SIZE
SORT-FILE-SIZE
SORT-MESSAGE
SORT-MODE-SIZE
SORT-RETURN
TALLY
WHEN-COMPILED
XML-CODE
XML-EVENT
XML-NTEXT
XML-TEXT
Literals
Alphanumeric literals
Numeric literals
DBCS literals
National literals
PICTURE character-strings
Comments
Separators
Rules for separators
Sections and paragraphs
Sentences, statements, and entries
Entries
Clauses
Sentences
Statements
Phrases
Reference format
Sequence number area
Indicator area
Area A
Division headers
Section headers
Paragraph headers or paragraph names
Level indicators (FD and SD) or level-numbers (01 and 77)
DECLARATIVES and END DECLARATIVES
End program, end class, and end method markers
Area B
Entries, sentences, statements, clauses
Continuation lines
Area A or Area B
Level-numbers
Comment lines
Compiler-directing statements
Compiler directives
Debugging lines
Pseudo-text
Blank lines
Scope of names
Types of names
External and internal resources
Resolution of names
Names within programs
Names within a class definition
Referencing data names, copy libraries, and procedure division names
Uniqueness of reference
Qualification
Identical names
References to COPY libraries
References to procedure division names
References to data division names
Condition-name
Index-name
Index data item
Subscripting
Reference modification
Function-identifier
Data attribute specification
Transfer of control
Millennium Language Extensions and date fields
Millennium Language Extensions syntax
Terms and concepts
Date field
Nondate
Century window
COBOL source unit structure
COBOL program structure
Nested programs
Conventions for program-names
COBOL class definition structure
COBOL method definition structure
Identification division
Identification division
PROGRAM-ID paragraph
CLASS-ID paragraph
General rules
Inheritance
FACTORY paragraph
OBJECT paragraph
METHOD-ID paragraph
Method signature
Method overloading, overriding, and hiding
Optional paragraphs
Environment division
Configuration section
SOURCE-COMPUTER paragraph
OBJECT-COMPUTER paragraph
SPECIAL-NAMES paragraph
ALPHABET clause
SYMBOLIC CHARACTERS clause
CLASS clause
CURRENCY SIGN clause
DECIMAL-POINT IS COMMA clause
REPOSITORY paragraph
General rules
Identifying and referencing the class
Input-Output section
FILE-CONTROL paragraph
SELECT clause
ASSIGN clause
Assignment name for non-environment variables and literals
Assignment name for data-names and environment variables
RESERVE clause
ORGANIZATION clause
File organization
PADDING CHARACTER clause
RECORD DELIMITER clause
ACCESS MODE clause
File organization and access modes
Access modes
Relationship between data organizations and access modes
RECORD KEY clause
ALTERNATE RECORD KEY clause
RELATIVE KEY clause
PASSWORD clause
FILE STATUS clause
I-O-CONTROL paragraph
RERUN clause
SAME AREA clause
SAME RECORD AREA clause
SAME SORT AREA clause
SAME SORT-MERGE AREA clause
MULTIPLE FILE TAPE clause
APPLY WRITE-ONLY clause
Data division
Data division overview
File section
Working-storage section
Local-storage section
Linkage section
Data units
File data
Program data
Method data
Factory data
Instance data
Data relationships
Levels of data
Levels of data in a record description entry
Special level-numbers
Indentation
Classes and categories of group items
Classes and categories of data
Category descriptions
Alignment rules
Character-string and item size
Signed data
Operational signs
Editing signs
Data division—file description entries
File section
EXTERNAL clause
GLOBAL clause
BLOCK CONTAINS clause
RECORD clause
Format 1
Format 2
Format 3
LABEL RECORDS clause
VALUE OF clause
DATA RECORDS clause
LINAGE clause
LINAGE-COUNTER special register
RECORDING MODE clause
CODE-SET clause
Data division—data description entry
Format 1
Format 2
Format 3
Level-numbers
BLANK WHEN ZERO clause
DATE FORMAT clause
Semantics of windowed date fields
Restrictions on using date fields
EXTERNAL clause
GLOBAL clause
JUSTIFIED clause
GROUP-USAGE clause
OCCURS clause
Fixed-length tables
ASCENDING KEY and DESCENDING KEY phrases
INDEXED BY phrase
Variable-length tables
OCCURS DEPENDING ON clause
PICTURE clause
Symbols used in the PICTURE clause
Character-string representation
Data categories and PICTURE rules
PICTURE clause editing
Simple insertion editing
Special insertion editing
Fixed insertion editing
Floating insertion editing
Zero suppression and replacement editing
REDEFINES clause
REDEFINES clause considerations
REDEFINES clause examples
Undefined results
RENAMES clause
SIGN clause
SYNCHRONIZED clause
Slack bytes
Slack bytes within records
Slack bytes between records
USAGE clause
Computational items
DISPLAY phrase
DISPLAY-1 phrase
FUNCTION-POINTER phrase
INDEX phrase
NATIONAL phrase
OBJECT REFERENCE phrase
POINTER phrase
PROCEDURE-POINTER phrase
NATIVE phrase
VALUE clause
Format 1
Format 2
Format 3
Procedure division
Procedure division structure
Requirements for a method procedure division
The procedure division header
The USING phrase
RETURNING phrase
References to items in the linkage section
Declaratives
Procedures
Arithmetic expressions
Arithmetic operators
Arithmetic with date fields
Conditional expressions
Simple conditions
Class condition
Condition-name condition
Relation conditions
General relation conditions
Data pointer relation conditions
Procedure-pointer and function-pointer relation conditions
Object-reference relation conditions
Sign condition
Switch-status condition
Complex conditions
Negated simple conditions
Combined conditions
Abbreviated combined relation conditions
Statement categories
Imperative statements
Conditional statements
Delimited scope statements
Explicit scope terminators
Implicit scope terminators
Compiler-directing statements
Statement operations
CORRESPONDING phrase
GIVING phrase
ROUNDED phrase
SIZE ERROR phrases
Arithmetic statements
Arithmetic statement operands
Data manipulation statements
Input-output statements
Common processing facilities
Procedure division statements
ACCEPT statement
Data transfer
System date-related information transfer
DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK, and TIME
ADD statement
ROUNDED phrase
SIZE ERROR phrases
CORRESPONDING phrase (format 3)
END-ADD phrase
ALTER statement
Segmentation considerations
CALL statement
USING phrase
BY REFERENCE phrase
BY CONTENT phrase
BY VALUE phrase
RETURNING phrase
ON EXCEPTION phrase
NOT ON EXCEPTION phrase
ON OVERFLOW phrase
END-CALL phrase
CANCEL statement
CLOSE statement
Effect of CLOSE statement on file types
COMPUTE statement
ROUNDED phrase
SIZE ERROR phrases
END-COMPUTE phrase
CONTINUE statement
DELETE statement
Sequential access mode
Random or dynamic access mode
END-DELETE phrase
DISPLAY statement
DIVIDE statement
ROUNDED phrase
REMAINDER phrase
SIZE ERROR phrases
END-DIVIDE phrase
ENTRY statement
USING phrase
EVALUATE statement
END-EVALUATE phrase
Determining values
Comparing selection subjects and objects
Executing the EVALUATE statement
EXIT statement
EXIT METHOD statement
EXIT PROGRAM statement
GOBACK statement
GO TO statement
Unconditional GO TO
Conditional GO TO
Altered GO TO
MORE-LABELS GO TO
IF statement
END-IF phrase
Transferring control
Nested IF statements
INITIALIZE statement
REPLACING phrase
INITIALIZE statement rules
INSPECT statement
TALLYING phrase (formats 1 and 3)
REPLACING phrase (formats 2 and 3)
BEFORE and AFTER phrases (all formats)
CONVERTING phrase (format 4)
Data flow
Example of the INSPECT statement
INVOKE statement
USING phrase
BY VALUE phrase
RETURNING phrase
ON EXCEPTION phrase
NOT ON EXCEPTION phrase
END-INVOKE phrase
Interoperable data types for COBOL and Java
Miscellaneous argument types for COBOL and Java
MERGE statement
ASCENDING/DESCENDING KEY phrase
COLLATING SEQUENCE phrase
USING phrase
GIVING phrase
OUTPUT PROCEDURE phrase
MERGE special registers
Segmentation considerations
MOVE statement
Elementary moves
Moves involving file record areas
Group moves
MULTIPLY statement
ROUNDED phrase
SIZE ERROR phrases
END-MULTIPLY phrase
OPEN statement
General rules
Label records
OPEN statement notes
PERFORM statement
Basic PERFORM statement
END-PERFORM
PERFORM with TIMES phrase
PERFORM with UNTIL phrase
PERFORM with VARYING phrase
Varying identifiers
Varying two identifiers
Varying three identifiers
Varying more than three identifiers
Varying phrase rules
READ statement
KEY IS phrase
AT END phrases
INVALID KEY phrases
END-READ phrase
Multiple record processing
Sequential access mode
Random access mode
Dynamic access mode
READ statement notes:
RELEASE statement
RETURN statement
AT END phrases
END-RETURN phrase
REWRITE statement
INVALID KEY phrases
END-REWRITE phrase
Reusing a logical record
Sequential files
Indexed files
Relative files
SEARCH statement
Serial search
Binary search
Search statement considerations
AT END and WHEN phrases
NEXT SENTENCE
END-SEARCH phrase
SET statement
Format 1: SET for basic table handling
Format 2: SET for adjusting indexes
Format 3: SET for external switches
Format 4: SET for condition-names
Format 5: SET for USAGE IS POINTER data items
Format 6: SET for procedure-pointer and function-pointer data items
Format 7: SET for USAGE OBJECT REFERENCE data items
SORT statement
ASCENDING KEY and DESCENDING KEY phrases
DUPLICATES phrase
COLLATING SEQUENCE phrase
USING phrase
INPUT PROCEDURE phrase
GIVING phrase
OUTPUT PROCEDURE phrase
SORT special registers
Segmentation considerations
START statement
KEY phrase
INVALID KEY phrases
END-START phrase
Indexed files
Relative files
STOP statement
STRING statement
ON OVERFLOW phrases
END-STRING phrase
Data flow
SUBTRACT statement
ROUNDED phrase
SIZE ERROR phrases
CORRESPONDING phrase (format 3)
END-SUBTRACT phrase
UNSTRING statement
DELIMITED BY phrase
INTO phrase
POINTER phrase
TALLYING IN phrase
ON OVERFLOW phrases
END-UNSTRING phrase
Data flow
Example of the UNSTRING statement
WRITE statement
ADVANCING phrase
END-OF-PAGE phrases
INVALID KEY phrases
END-WRITE phrase
WRITE for sequential files
WRITE for indexed files
WRITE for relative files
XML GENERATE statement
Nested XML GENERATE or XML PARSE statements
Operation of XML GENERATE
XML element name formation
XML PARSE statement
Nested XML GENERATE or XML PARSE statements
Control flow
Intrinsic functions
Intrinsic functions
Specifying a function
Function definition and evaluation
Types of functions
Rules for usage
Arguments
Examples
ALL subscripting
Function definitions
ACOS
ANNUITY
ASIN
ATAN
CHAR
COS
CURRENT-DATE
DATE-OF-INTEGER
DATE-TO-YYYYMMDD
DATEVAL
DAY-OF-INTEGER
DAY-TO-YYYYDDD
DISPLAY-OF
FACTORIAL
INTEGER
INTEGER-OF-DATE
INTEGER-OF-DAY
INTEGER-PART
LENGTH
LOG
LOG10
LOWER-CASE
MAX
MEAN
MEDIAN
MIDRANGE
MIN
MOD
NATIONAL-OF
NUMVAL
NUMVAL-C
ORD
ORD-MAX
ORD-MIN
PRESENT-VALUE
RANDOM
RANGE
REM
REVERSE
SIN
SQRT
STANDARD-DEVIATION
SUM
TAN
UNDATE
UPPER-CASE
VARIANCE
WHEN-COMPILED
YEAR-TO-YYYY
YEARWINDOW
Compiler-directing statements
Compiler-directing statements
BASIS statement
CBL (PROCESS) statement
*CONTROL (*CBL) statement
Source code listing
Object code listing
Storage map listing
COPY statement
SUPPRESS phrase
REPLACING phrase
Replacement and comparison rules
DELETE statement
EJECT statement
ENTER statement
INSERT statement
READY or RESET TRACE statement
REPLACE statement
Continuation rules for pseudo-text
Comparison operation
REPLACE statement notes
SERVICE LABEL statement
SERVICE RELOAD statement
SKIP statements
TITLE statement
USE statement
EXCEPTION/ERROR declarative
Precedence rules for nested programs
LABEL declarative
DEBUGGING declarative
Compiler directives
CALLINTERFACE
Syntax and general rules
Difference between the directive and compiler option
Precedence of suboptions
Appendixes
Appendixes
Appendix A. IBM extensions
Appendix B. Compiler limits
Appendix C. EBCDIC and ASCII collating sequences
EBCDIC collating sequence
US English ASCII code page
Appendix D. Source language debugging
Debugging lines
Debugging sections
DEBUG-ITEM special register
Activate compile-time switch
Activate object-time switch
Appendix E. Reserved words
Appendix F. Code page names
Appendix G. Locale considerations
Compile-time versus runtime locale
Code pages
Collating sequences
Supported locales
Appendix H. Industry specifications
COBOL language help
ALPHABETIC
ALSO
AND
AREA, AREAS
ASCENDING KEY and DESCENDING KEY phrases
BEFORE and AFTER phrases
CHARACTER, CHARACTERS
CLASS
CODE
COLLATING
CONTAINS
CONTENT
COUNT
DATA
DATE
DBCS
DELETE
DELIMITED
DELIMITER
DISPLAY
DIVISION
DUPLICATES
END
END-XML
ENVIRONMENT DIVISION
EXCEPTION
EXIT
EXTEND
EXTERNAL
FACTORY
FILE
GENERATE
GLOBAL
GROUP
I-O
INDEXED
INPUT
INVALID
KEY
LABEL
LEADING
LENGTH
LINE, LINES
METHOD
MODE
NATIONAL
NEXT
NOT
No help available
Not supported
Not supported in COBOL for Windows
OBJECT
OCCURS
OMITTED
OR
OUTPUT
OVERFLOW
PROGRAM
RANDOM
RECORD, RECORDS
REEL
REFERENCE
REPLACING
RETURNING
REWIND
RIGHT and LEFT phrases
Report Writer Precompiler
SAME
SECTION
SENTENCE
SEQUENCE
SERVICE
SIZE
STANDARD
STANDARD-1
STANDARD-2
STATUS
SUM
TALLYING
TEST
TIMES
TRUE
UNIT
USING
User-defined words
VALUE
VARYING
WHEN
WHEN-COMPILED
XML
Picture symbol sequences
Introduction
Numeric category
Numeric date category
Alphabetic category
Alphanumeric category
Alphanumeric-edited category
Numeric-edited category
Nonfloating insertion symbols
Floating insertion symbols
Other symbols
External floating point category
DBCS category
National category
National-edited category
Figure description: INSPECT statement
Figure description: LINAGE clause
Figure description: PERFORM statement
Figure description: PERFORM VARYING with TEST BEFORE
Figure description: PERFORM VARYING with TEST AFTER
Figure description: PERFORM VARYING with TEST AFTER
Figure description: STRING statement
Figure description: UNSTRING statement
How to read dotted decimal diagrams
Notices
Programming interface information
Trademarks
Glossary
List of resources
COBOL for Windows
COBOL for AIX
Enterprise COBOL for z/OS
Related publications for Windows
Index
Terms of use
|
Feedback
Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)