CONTENTS Title Page Copyright Page Preface Summary of Technical Changes 1 Overview of the COBOL Language 1.1 The COBOL Character Set 1.2 Character-Strings 1.2.1 COBOL Words 1.2.1.1 User-Defined Words 1.2.1.2 System-Names 1.2.1.3 Reserved Words 1.2.2 Literals 1.2.2.1 Numeric Literals 1.2.2.2 Floating Point Literals 1.2.2.3 Nonnumeric Literals 1.2.2.4 Hexadecimal Literals 1.2.3 Figurative Constants 1.2.4 PICTURE Character-Strings 1.2.5 Separators 1.3 Meta-Language Elements 1.3.1 Uppercase and Special-Character Words 1.3.2 Lowercase Words 1.3.3 Brackets and Braces 1.3.4 Choice Indicators 1.3.5 The Ellipsis 1.4 Source Reference Format 1.4.1 ANSI Format 1.4.1.1 Line Continuation 1.4.1.2 Blank Lines 1.4.1.3 Comment Lines 1.4.1.4 Conditional Compilation Lines 1.4.1.5 Pseudo-Text 1.4.1.6 Short Lines and Tab Characters 1.4.2 Terminal Format 1.5 Sample Format Entry 2 Organization of the COBOL Source Program 2.1 Program Structure 2.1.1 Division Header 2.1.2 Section Header 2.1.3 Paragraph, Paragraph Header, Paragraph-Name 2.2 Data Division Entries 2.3 Declaratives 3 Identification Division PROGRAM-ID AUTHOR DATE-COMPILED 4 Environment Division 4.1 Configuration Section SOURCE-COMPUTER OBJECT-COMPUTER SPECIAL-NAMES 4.2 INPUT-OUTPUT Section FILE-CONTROL ASSIGN BLOCK CONTAINS CODE-SET ORGANIZATION PADDING CHARACTER RECORD DELIMITER RESERVE I-O-CONTROL 5 Data Division 5.1 Logical Concepts 5.1.1 Record Description 5.1.2 Level-Numbers 5.1.3 Multiple Record Definitions 5.2 Physical Concepts 5.2.1 Categories and Classes of Data 5.2.2 Standard Alignment Rules 5.2.3 Record Allocation 5.2.3.1 Location Equivalence 5.2.3.2 Boundary Equivalence 5.3 DATA DIVISION General Format and Rules DB (Subschema Description) LD (Keeplist Description) FD (Sequential, Relative, Indexed, and Report file descriptions) SD (Sort-Merge File Description) RD (Report Description) data description Report Group Description ACCESS MODE ALTERNATE RECORD KEY BLANK WHEN ZERO CODE COLUMN NUMBER CONTROL Data-Name DATA RECORDS EXTERNAL FILE STATUS GLOBAL GROUP INDICATE JUSTIFIED LABEL RECORDS LEVEL-NUMBER LINAGE LINE NUMBER NEXT GROUP OCCURS PAGE PICTURE RECORD RECORD KEY REDEFINES RENAMES REPORT SIGN SOURCE SUM SYNCHRONIZED TYPE USAGE VALUE IS VALUE OF ID 6 Procedure Division 6.1 Verbs, Statements, and Sentences 6.1.1 Compiler-Directing Statements and Sentences 6.1.2 Imperative Statements and Sentences 6.1.3 Conditional Statements and Sentences 6.1.4 Scope of Statements 6.2 Uniqueness of Reference 6.2.1 Qualification 6.2.2 Subscripts and Indexes 6.2.2.1 Subscripting 6.2.2.2 Indexing 6.2.3 Reference Modification 6.2.4 Identifiers 6.2.5 Ensuring Unique Condition-Names 6.2.6 Scope of Names 6.2.6.1 Conventions for Resolving Program-Name References 6.2.6.2 Conventions for Resolving Other References 6.2.7 External and Internal Data 6.3 Database Key Identifiers 6.4 Explicit and Implicit Specifications 6.4.1 Explicit and Implicit Procedure Division References 6.4.2 Explicit and Implicit Control Transfers 6.4.3 Explicit and Implicit Attributes 6.4.4 Explicit and Implicit Scope Terminators 6.5 Arithmetic Expressions 6.5.1 Arithmetic Operators 6.5.2 Formation and Evaluation of Arithmetic Expressions 6.6 Conditional Expressions 6.6.1 Relation Conditions 6.6.1.1 Comparison of Numeric Operands 6.6.1.2 Comparison of Nonnumeric Operands 6.6.1.3 Comparisons of Index-Names or Index Data Items 6.6.2 Class Condition 6.6.3 Condition-Name Condition 6.6.4 Switch-Status Condition 6.6.5 Sign Condition 6.6.6 Database Conditions 6.6.6.1 Tenancy Condition 6.6.6.2 Member Condition 6.6.6.3 Database Key Condition 6.6.7 Success/Failure Condition 6.6.8 Complex Conditions 6.6.8.1 Negated Simple Conditions 6.6.8.2 Combined and Negated Combined Conditions 6.6.9 Abbreviated Combined Relation Conditions 6.6.10 Condition Evaluation Rules 6.7 Record Selection Expressions 6.8 Common Rules and Options for Data Handling 6.8.1 Arithmetic Operations 6.8.2 Multiple Receiving Fields in Arithmetic Statements 6.8.3 ROUNDED Phrase 6.8.4 ON SIZE ERROR Phrase 6.8.5 CORRESPONDING Phrase 6.8.6 ON EXCEPTION Phrase 6.8.7 Overlapping Operands and Incompatible Data 6.8.8 I-O Status 6.8.9 INVALID KEY Phrase 6.8.10 AT END Phrase 6.8.11 Database on Error Condition 6.8.12 FROM Phrase 6.8.13 INTO Phrase 6.8.14 RETAINING Clause 6.9 Segmentation 6.9.1 Fixed Segments 6.9.2 Independent Segments 6.10 Procedure Division General Format and Rules ACCEPT ADD ALTER CALL CANCEL CLOSE COMMIT COMPUTE CONNECT CONTINUE DELETE DISCONNECT DISPLAY DIVIDE ERASE EVALUATE EXIT EXIT PROGRAM FETCH FIND FREE GENERATE GET GO TO IF INITIALIZE INITIATE INSPECT KEEP MERGE MODIFY MOVE MULTIPLY OPEN PERFORM READ READY RECONNECT RECORD RELEASE RETURN REWRITE ROLLBACK SEARCH SET SORT START STOP STORE STRING SUBTRACT SUPPRESS TERMINATE UNLOCK UNSTRING USE WRITE 7 END PROGRAM Header 8 Source Text Manipulation 8.1 Text-Word Definition Rules 8.2 COPY Statement 8.3 REPLACE Statement A VAX COBOL Reserved Words B Character Sets C File Status Key Values D Set Membership Options and DML Verbs E Report Writer Presentation Rules and Tables E.1 Organization E.2 LINE NUMBER Clause Notation E.3 LINE NUMBER Clause Sequence Substitutions E.4 Saved-Next-Group-Integer Description E.5 REPORT HEADING Group Presentation Rules E.6 PAGE HEADING Group Presentation Rules E.7 Body Group Presentation Rules E.8 PAGE FOOTING Group Presentation Rules E.9 REPORT FOOTING Group Presentation Rules F Extension Marking F.1 General Format-Identification Division F.2 General Format-Environment Division F.3 General Format-SOURCE-COMPUTER F.4 General Format-OBJECT-COMPUTER F.5 General Format-SPECIAL-NAMES F.6 General Formats-FILE-CONTROL F.7 General Format-I-O-CONTROL F.8 General Format-DATA DIVISION F.9 General Format-Subschema Description F.10 General Format-Keeplist Description F.11 General Formats-File Description F.12 General Format-Sort-Merge File Description F.13 General Format-Report Description F.14 General Format-Alternate Record Key F.15 General Format-Record Key F.16 General Formats-Data Description F.17 General Formats-Report Group Descriptions F.18 General Formats-Procedure Division F.19 General Formats-ACCEPT F.20 General Formats-ADD F.21 General Format-ALTER F.22 eneral Format-CALL F.23 General Format-CANCEL F.24 General Format-CLOSE F.25 General Format-COMMIT F.26 General Format-COMPUTE F.27 General Format-CONNECT F.28 General Format-CONTINUE F.29 General Format-DELETE F.30 General Format-DISCONNECT F.31 General Formats-DISPLAY F.32 General Format-DIVIDE F.33 General Format-ERASE F.34 General Format-EVALUATE F.35 General Format-EXIT F.36 General Format-EXIT PROGRAM F.37 General Format-FETCH F.38 General Formats-FIND F.39 General Format-FREE F.40 General Format-GENERATE F.41 General Format-GET F.42 General Formats-GO TO F.43 General Format-IF F.44 General Format-INITIALIZE F.45 General Format-INITIATE F.46 General Formats-INSPECT F.47 General Format-KEEP F.48 General Format-MERGE F.49 General Format-MODIFY F.50 General Formats-MOVE F.51 General Formats-MULTIPLY F.52 General Formats-OPEN F.53 General Formats-PERFORM F.54 General Formats-READ F.55 General Format-READY F.56 General Format-RECONNECT F.57 General Format-RECORD F.58 General Format-RELEASE F.59 General Format-RETURN F.60 General Format-REWRITE F.61 General Format-ROLLBACK F.62 General Formats-SEARCH F.63 General Formats-SET F.64 General Format-SORT F.65 General Format-START F.66 General Format-STOP F.67 General Format-STORE F.68 General Format-STRING F.69 General Formats-SUBTRACT F.70 General Format-SUPPRESS F.71 General Format-TERMINATE F.72 General Format-UNLOCK F.73 General Format-UNSTRING F.74 General Formats-USE F.75 General Formats-WRITE F.76 General Format-END PROGRAM F.77 General Formats-COPY F.78 General Formats-REPLACE F.79 Miscellaneous Formats F.79.1 Subscripting: F.79.2 Indexing: F.79.3 Reference Modification: F.79.4 Identifier: F.79.5 Database Key Identifiers: F.79.6 Relation Condition: F.79.7 Class Condition: F.79.8 Sign Condition: F.79.9 Tenancy Condition: F.79.10 Member Condition: F.79.11 Database Key Condition: F.79.12 Success/Failure Condition: F.79.13 Negated Simple Condition: F.79.14 Combined and Negated Combined Condition: F.79.15 Combined Abbreviated Relation Condition: F.79.16 Database Key Identifier Access: F.79.17 Database Set Owner Access: F.79.18 Database Access Key: F.79.19 Record Search Access: F.79.20 ON SIZE ERROR Phrase: F.79.21 INVALID KEY Phrase: F.79.22 AT END Phrase: F.79.23 Database On Error Condition: F.79.24 FROM Phrase: F.79.25 INTO Phrase: F.79.26 RETAINING Clause: F.79.27 Segmentation: Glossary EXAMPLES 5-1 Multiple Record Definition Structure 8-1 COPY With No REPLACING Phrase 8-2 Replacing a Word With a Literal 8-3 Replacing a Word by a Literal and Pseudo-Text by Pseudo-Text 8-4 Matching a Nonnumeric Literal 8-5 Multiple-Line Psuedo-Text Replacement Item 8-6 Matching Pseudo-text That Includes Separators 8-7 Command File That Creates CDD/Plus Directories and Objects in Figure 8-1 8-8 Using a Logical Name in a COPY Statment 8-9 Using a Full Pathname in a COPY Statement 8-10 Command File That Creates CDD/Plus Directories and Objects in Figure 8-2 FIGURES 1-1 Source Program Line 2-1 Structure of a COBOL Program 5-1 Hierarchical Record Structure 5-2 Level-Number Record Structure 5-3 Record Alignment Boundaries 5-4 Comparison of Major-Minor and Left-Right Locations 5-5 Effect of Boundary and Location Equivalence Rules on Sample Record 5-6 Storage Allocation for Sample Record 5-7 Storage Allocation Without and with Boundary Equivalence 5-8 Format 3 Clause Combinations 5-9 Control Break Levels and Their Printed Report Groups 5-10 Logical Page Areas Resulting from a LINAGE Clause 5-11 PICTURE Symbol Precedence Rules 6-1 Combinations of Symbols in Arithmetic Expressions 6-2 Possible Combinations of Status Keys 1 and 2 6-3 PERFORM . . . VARYING with the TEST BEFORE Phrase and One Condition 6-4 PERFORM . . . VARYING with the TEST BEFORE Phrase and Two Conditions 6-5 PERFORM . . . VARYING with the TEST AFTER Phrase and One Condition 6-6 PERFORM . . . VARYING with the TEST AFTER Phrase and Two Conditions 6-7 Valid and Invalid Nested PERFORM Statements 6-8 Usage Mode Conflicts 6-9 Format 1 SEARCH Statement with Two WHEN Phrases 8-1 Hierarchical Dictionary Structure 8-2 Nonhierarchical Data Dictionary Structure E-1 REPORT HEADING Group Presentation Rules E-2 PAGE HEADING Group Presentation Rules Table E-3 Body Group Presentation Rules E-4 PAGE FOOTING Group Presentation Rules E-5 REPORT FOOTING Group Presentation Rules TABLES 1-1 The COBOL Character Set 1-2 COBOL User-Defined Words 1-3 Numeric Literals 1-4 Floating Point Literals 1-5 Nonnumeric Literals 1-6 Hexadecimal Literals 1-7 Separators 4-1 Required Manual Record-Locking Phrases 5-1 Classes and Categories of Data Items 5-2 Boundary Alignments by the SYNCHRONIZED Clause 5-3 Comparison of Major-Minor and Left-Right Locations 5-4 VAX COBOL and DDL Utility Data Type Equivalences 5-5 Page Regions Established by the PAGE Clause 5-6 Summary of PICTURE Clause Rules 5-7 PICTURE Clause Symbols 5-8 Using Sign Control Symbols in Fixed Insertion Editing 5-9 Using Sign Control Symbols in Floating Insertion Editing 5-10 Positive and Negative Signs for All Numeric Digits 5-11 Unscaled Data Items and Corresponding VMS Data Types 5-12 Scaled Data Items and VMS Data Types 6-1 Types and Categories of COBOL Statements 6-2 Contents of COBOL Sentences 6-3 Relational Operators and Corresponding True Conditions 6-4 How Logical Operators Affect Evaluation of Conditions 6-5 Combinations of Conditions, Logical Operators, and Parentheses 6-6 Expanded Equivalents for Abbreviated Combined Relation Conditions 6-7 Effects of CLOSE Statement Formats on Files by Category 6-8 Valid MOVE Statements 6-9 Opening Available and Unavailable Sequential, Relative, and Indexed Files 6-10 Allowable Input-Output Statements for Sequential, Relative, and Indexed Files 6-11 Opening Available and Unavailable Report Writer Files 6-12 Allowable Statements for Report Writer Files 6-13 Validity of Operand Combinations in Format 1 SET Statements 8-1 CDD/Plus Data Types and VAX COBOL Equivalents