COBOL Language Reference

Download COBOL Language Reference

Post on 10-Apr-2015

1.026 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

COBOL for OS/390 & VM COBOL Set for AIX VisualAge COBOL

IBM

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.

Fifth Edition (September 2000) This edition applies to: IBM COBOL for OS/390 & VM Version 2 Release 2 Modification 0 (program number 5648-A25) IBM COBOL Set for AIX Release 1 (program number 5765-548) IBM VisualAge COBOL Version 3.0.1 (program number 5639-B92) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. 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: IBM Corporation, Department HHX/H3 P.O. Box 49023 San Jose, CA 95161-9023 USA or fax it to this U.S. number: 800-426-7773 or use the form on the Web at: 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.

ContentsAbout this book. . . . . . . . . . . . . . . . .

vivi vi vi vii ix . x

Compatibility with previous IBM COBOL . . . . . . . . . (OS/390 and VM only) IBM extensions . . . . . . . . . . . . . . Obsolete language elements . . . . . . . How to read the syntax diagrams . . . . DBCS notation . . . . . . . . . . . . . . Acknowledgment . . . . . . . . . . . . .

products. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Part 2. COBOL source unit structure . . . . . . . . . . . . . .COBOL program structure

. . . . . .

5758

. . . . . . . .

Nested programs . . . . . . . . . . . . . . . . . . . 60

COBOL class definition structure Summary of changesFifth edition (September 2000) . . . . . . . Fourth edition (November 1998) . . . . . . Third edition (August 1998, softcopy only) Second edition (April 1998) . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi . xi . xi . xii . xii

. . . .

63 65

COBOL method definition structure

. .

Part 3. Identification DivisionIdentification DivisionPROGRAM-ID paragraph . . CLASS-ID paragraph . . . . . METHOD-ID paragraph . . . Optional paragraphs . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . .

6768. . . .

Part 1. COBOL language structureCharactersCharacter-strings . Figurative constants Special registers . . Literals . . . . . . Separators . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.

12. 3 . 7 . 9

. . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

70 72 74 76

17 24

Part 4. Environment DivisionConfiguration SectionSOURCE-COMPUTER paragraph OBJECT-COMPUTER paragraph SPECIAL-NAMES paragraph . . ALPHABET clause . . . . . . . . SYMBOLIC CHARACTERS clause CLASS clause . . . . . . . . . . . CURRENCY SIGN clause . . . . REPOSITORY paragraph . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . .

7980. . . . . . . .

Sections and paragraphs

. . . . . . . . . 26 Statements and clauses . . . . . . . . . . . . . . . . 26

Reference formatSequence number area Indicator area . . . . . Area A . . . . . . . . Area B . . . . . . . . . Area A or Area B . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

28. . . . .

28 28 29 30 32

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

80 82 83 86 89 89 90 91

Input-Output Section. . . . . . . Types of names . . . . . . . . . . External and internal resources . Resolution of names . . . . . . .

Scope of names

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. 35 . . 35 . . 37 . . 38

Referencing data names, copy libraries, and Procedure Division names . . . . . . . . . . . . . . . . . .Uniqueness of reference

. . . . 39 . . . . . . . . . . . . . . . 39

Transfer of control

. . . . . . . . . . . . . .

50

Millennium Language Extensions and date fields . . . . . . . . . . . . . . . . . .

.

52

Millennium Language Extensions syntax . . . . . . 52 Terms and concepts . . . . . . . . . . . . . . . . . 53 Copyright IBM Corp. 1991, 2000

FILE-CONTROL paragraph . . . . SELECT clause . . . . . . . . . . . ASSIGN clause . . . . . . . . . . . RESERVE clause . . . . . . . . . . ORGANIZATION clause . . . . . . PADDING CHARACTER clause . . RECORD DELIMITER clause . . . ACCESS MODE clause . . . . . . . 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 . . .

. . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . .

. 93 . . 94 . . 97 . . 97 . 103 . 103 . 106 . 107 . 107 . 109 . 110 . 111 . 111 . 112 . 114 . 115 . 116 . 117

iii

SAME SORT AREA clause . . . . . SAME SORT-MERGE AREA clause MULTIPLE FILE TAPE clause . . . APPLY WRITE-ONLY clause . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

117 118 118 118

Statement operations . . . . . . . . . . . . . . . .

238

Procedure Division statementsACCEPT statement . . . . ADD statement . . . . . . ALTER statement . . . . . CALL statement . . . . . CANCEL statement . . . . CLOSE statement . . . . . COMPUTE statement . . . CONTINUE statement . . DELETE statement . . . . DISPLAY statement . . . . DIVIDE statement . . . . ENTRY statement . . . . . EVALUATE statement . . EXIT statement . . . . . . EXIT METHOD statement EXIT PROGRAM statement GOBACK statement . . . GO TO statement . . . . . IF statement . . . . . . . . INITIALIZE statement . . INSPECT statement . . . . INVOKE statement . . . . MERGE statement . . . . MOVE statement . . . . . MULTIPLY statement . . OPEN statement . . . . . PERFORM statement . . . READ statement . . . . . RELEASE statement . . . RETURN statement . . . . REWRITE statement . . . SEARCH statement . . . . SET statement . . . . . . . SORT statement . . . . . . START statement . . . . . STOP statement . . . . . . STRING statement . . . . SUBTRACT statement . . UNSTRING statement . . WRITE statement . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Part 5. Data DivisionData Division overviewFile Section . . . . . . . Working-Storage Section Local-Storage Section . . Linkage Section . . . . . Data types . . . . . . . . Data relationships . . .. . . . . . . . . . . . . . . . . .

. . . . . . . . . .

119. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

120121 121 123 123 124 124

Data Divisionfile description entries 131File Section . . . . . . . . . EXTERNAL clause . . . . . GLOBAL clause . . . . . . . BLOCK CONTAINS clause RECORD clause . . . . . . . LABEL RECORDS clause . . VALUE OF clause . . . . . DATA RECORDS clause . . LINAGE clause . . . . . . . RECORDING MODE clause CODE-SET clause . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Recommended

View more >