NetCOBOL V11.1 FUJITSU Software · 2017-02-01 · Preface This NetCOBOL Reference Manual covers the...

748
B1WD-3304-05ENZ0(00) February 2017 FUJITSU Software NetCOBOL V11.1 Language Reference

Transcript of NetCOBOL V11.1 FUJITSU Software · 2017-02-01 · Preface This NetCOBOL Reference Manual covers the...

  • B1WD-3304-05ENZ0(00)February 2017

    FUJITSU SoftwareNetCOBOL V11.1

    Language Reference

  • PrefaceThis NetCOBOL Reference Manual covers the rules for writing programs in COBOL (COmmon Business OrientedLanguage). It contains information on the base language, as well as extensions and restrictions for Fujitsu NetCOBOL andNetCOBOL for the .NET environment.

    The reader is assumed to have a basic knowledge of programming.

    Organization

    The table below shows how this manual is organized.

    Chapter/Appendix Description

    Chapter 1. General Rules Covers the general rules including the language elements of COBOL,unique reference, writing of literals, and reference format

    Chapter 2. COBOL Modules Lists and explains the facilities of COBOL

    Chapter 3. Identification Division and EndProgram Header

    Explains the syntax of the Identification Division and End Programheader

    Chapter 4. Environment Division Explains the syntax of the Environment Division

    Chapter 5. Data Division Explains the syntax of the Data Division

    Chapter 6. Procedure Division Explains the syntax of the Procedure Division

    Chapter 7. Source Text Manipulation Explains the syntax of statements used in the Source Text Manipulationfunction

    Chapter 8. Database(SQL) Explains the syntax of the Database function(SQL)

    Chapter 9. Communication Database Explains the syntax of the Communication Database function

    Chapter 10. Micro Focus Native Functions Explains the syntax of the Micro Focus native functions

    Chapter 11. Object-Oriented ProgrammingFunction

    Explains the syntax of the object-oriented programming function.

    Chapter 12. Microsoft .NET

    Support

    Describes the extensions added to support the .NET Framework

    Appendix A. List of Reserved Words Lists the reserved words in COBOL

    Appendix B. System QuantitativeRestrictions

    Lists the quantitative restrictions of the COBOL Runtime System

    Appendix C. Code Tables Lists the character sets and their internal representations

    Appendix D. Intermediate Results Explains the attributes and accuracy of intermediate results

    Appendix E. Functional Differences Lists the functional differences for each operating system

    Appendix F. Control Record Formats Explains the formats of the control records

    Appendix G. Data Item Definition UsingTypes

    Explains the usage of types.

    How to Use this Manual

    Users who wish to gain an understanding of the basic concepts of COBOL and its facilities should first read Chapters 1 and2 in that order. Users who already have an understanding of COBOL may skip the first two chapters and read any of theother chapters or appendices as required.

    The following diagram shows the sequence in which the chapters and appendices of this reference manual should be read.

    - i -

  • Symbols Used in Format Diagrams

    In each chapter, Format shows how to write COBOL language elements, such as statements and clauses. The words shownin Format must be written in the sequence shown unless otherwise specified in the syntax rules or general rules.

    Symbol Meaning Example

    Character-stringin uppercaseletters

    COBOL reserved word.

    These character-strings must be writtenexactly as they appear in Format.

    Example

    VALUE IS constant-1

    Meaning

    VALUE cannot be omitted. IS can be omitted.Write any constant conforming to the syntaxrules in constant-1.

    For example

    VALUE IS "XXXX"

    VALUE 12345

    ___________

    (underline)

    Underlining indicates that the character-stringis a key word. A key word cannot be omitted.A character-string that is not underlined canbe omitted.

    Character-stringin lowercaseletters

    Character-string in lowercase letters indicatesthe classifications of user-defined word,literal, PICTURE clause character-strings,and comment entries. Any character-stringcan be written in this portion provided that itconforms to the syntax rules.

    [ ]

    (brackets)

    Brackets indicate that one of the values givenin the parentheses can be selected, or thecontents of the brackets can be omitted.

    Example 1

    - ii -

  • Symbol Meaning Example

    Meaning

    Write data-name-1 or FILLER, or omit this valuecompletely.

    Example 2

    [ON SIZE ERROR unconditional-statement-1]

    Meaning

    This value can be omitted completely.

    { }

    (braces)

    Braces indicate that one of the values given inthe braces can be selected or the value can beomitted.

    Example 1

    {identifier-1 | literal-1}

    Example 2

    Meaning

    Write either identifier-1 or literal-1.

    {| |}

    (choiceindicators)

    These indicate that at least one of the valuesgiven in the choice indicators can be written.However, each character-string must beunique.

    Example

    Meaning

    Any of the following can be written:

    - COMMON

    - INITIAL

    - COMMON INITIAL

    - INITIAL COMMON

    ...

    (occurrencesymbol)

    Indicates that the portion immediatelypreceding the occurrence symbol (the portionenclosed in brackets or parentheses) can berepeated.

    Example

    Meaning

    Identifier-1 or literal-1 can be repeated.

    .

    (period)

    Any period shown in Format must be writtenin the same position.

    Example

    WORKING-STORAGE SECTION.

    Meaning

    The period after SECTION must be written.

    - iii -

  • Symbol Meaning Example

    Specialcharacters suchas

    +, -, >, =,

    Special characters are key words. They are notunderlined, but must not be omitted.

    Example

    Meaning

    The symbol =, > or >= must be written.

    Shading

    The shaded portions in the documentation indicate that they describe extended functions or functions specific to NetCOBOL.If the heading of a section or an item is shaded, the entire description under that heading is an extended function ofNetCOBOL.

    Syntax Rules and General Rules

    The explanation of COBOL language elements such as statements and clauses are arranged into Format, syntax rules, andgeneral rules.

    Format shows the arrangement of elements making up a statement or clause.

    Syntax rules explain the arrangement of the elements in Format and restrictions on their arrangement.

    General rules explain the results of execution and compilation where a statement or clause was written. They also explainthe meaning of elements in Format and the relationship between the elements.

    Syntax rules or general rules are omitted when there are no rules relating to the elements in Format.

    Obsolete Elements

    Elements marked "Obsolete elements" in the text are given in the 1985 issue of the ANSI COBOL standard but may not beincluded in the next edition. Fujitsu recommends that obsolete elements not be used when creating new programs.

    Related Documentation

    The documentation set for NetCOBOL includes "NetCOBOL User's Guide" in addition to this document. Refer to"NetCOBOL User's Guide" for creating, compiling, executing, and debugging programs.

    Refer to "NetCOBOL User's Guide" for the details of the other systems.

    Scope of NetCOBOL Functions

    The NetCOBOL functions consist of ANSI standard COBOL functions (ANSI Standard COBOL X3.23 1985,ISO-1989-1985) and NetCOBOL extended functions. The NetCOBOL functions are as follows:

    - iv -

  • NetCOBOL

    functions

    ANSIstandard

    COBOL

    functions

    Required

    functions

    Nucleus (2, nucleus 1, 2)

    Sequential I-O function (2, sequential 1, 2)

    Relative I-O function (2, relative 0, 2)

    Indexed I-O function (2, indexed 0, 2)

    Inter-program communication function

    (2, communication 1, 2)

    Sort-merge function (1, sort 0, 1)

    Source test manipulation function

    (2, source test 0, 2)

    Optional

    functions

    Report writer function (1, report 0, 1)

    Built-in function (1, function 0, 1)

    Debug function (2, debug 0, 2)*

    Segmentation function (2, segmentation 0,2)*

    NetCOBOL

    extendedfunctions

    Presentation file function

    Screen handling module

    Command line argument and

    environment variable operation function

    Database function

    Communication database function

    Micro Focus native function

    Object-oriented programming function

    .NET programming function

    *: The debug function and segmentation functions are treated as comments when the program is run.

    Note

    In the above, standard mnemonic symbols for each ANSI standard COBOL function are shown in parentheses. From leftto right the symbols show the position of the function in the hierarchy, the function abbreviation, and the maximum andminimum levels of the function to which the level belongs.

    System-specific Functions

    Some parts of the COBOL common syntax described in this manual depend on system functions, and differ among systems.

    Such parts are indicated by the following system names:

    Indicator Corresponding system Corresponding product

    [DS]

    [UXP/DS]

    UXP/DS COBOL85 V20L11

    [HP] HP-UX COBOL85 V20L11

    [Solaris] Oracle Solaris 10 NetCOBOL V10

    [Linux] Red Hat(R) Enterprise Linux(R) 5(for x86)

    Red Hat(R) Enterprise Linux(R) 5(for Intel64) 32bit

    NetCOBOL (32bit) V7.3

    [LinuxIPF] Red Hat(R) Enterprise Linux(R) 5(for Intel Itanium) NetCOBOL V9.0

    - v -

  • Indicator Corresponding system Corresponding product

    [Linux64] Red Hat(R) Enterprise Linux(R) 6(for Intel64) 64bit

    Red Hat(R) Enterprise Linux(R) 7(for Intel64) 64bit

    NetCOBOL V11

    [Win16] Windows 95

    Windows 3.1

    COBOL V20L11

    [Win32] Windows Server 2012 R2

    Windows Server 2012

    Windows Server 2008 R2

    Windows 10

    Windows 8.1

    Windows 7

    NetCOBOL (32bit) V11

    [Winx64] Windows Server 2016

    Windows Server 2012 R2

    Windows Server 2012

    Windows Server 2008 R2

    Windows 10 (x64)

    Windows 8.1(x64)

    Windows 7(x64)

    NetCOBOL (64bit) V11

    [.NET] Windows Server 2012 R2

    Windows Server 2012

    Windows Server 2008 R2

    Windows 10

    Windows 8.1

    Windows 7

    NetCOBOL for .NET V7

    Refer to Appendix E "Functional Differences" for a list of functional differences.

    Abbreviations

    The following abbreviations are used in this manual:

    Product Name Abbreviation

    Microsoft® Windows Server® 2016 Datacenter

    Microsoft® Windows Server® 2016 Standard

    Microsoft® Windows Server® 2016 Essentials

    Windows Server 2016

    Microsoft® Windows Server® 2012 R2 Datacenter

    Microsoft® Windows Server® 2012 R2 Standard

    Microsoft® Windows Server® 2012 R2 Essentials

    Microsoft® Windows Server® 2012 R2 Foundation

    Windows Server 2012 R2

    Microsoft® Windows Server® 2012 Datacenter

    Microsoft® Windows Server® 2012 Standard

    Microsoft® Windows Server® 2012 Essentials

    Windows Server 2012

    - vi -

  • Product Name Abbreviation

    Microsoft® Windows Server® 2012 Foundation

    Microsoft® Windows Server® 2008 R2 Foundation

    Microsoft® Windows Server® 2008 R2 Standard

    Microsoft® Windows Server® 2008 R2 Enterprise

    Microsoft® Windows Server® 2008 R2 Datacenter

    Windows Server 2008 R2

    Windows® 10 Education

    Windows® 10 Home

    Windows® 10 Pro

    Windows® 10 Enterprise

    Windows 10

    or

    Windows 10 (x64)

    Windows® 8.1

    Windows® 8.1 Pro

    Windows® 8.1 Enterprise

    Windows 8.1

    or

    Windows 8.1 (x64)

    Windows® 7 Home Premium

    Windows® 7 Professional

    Windows® 7 Enterprise

    Windows® 7 Ultimate

    Windows 7

    or

    Windows 7 (x64)

    Oracle Solaris Solaris

    Trademarks

    - NetCOBOL is a trademark or registered trademark of Fujitsu Limited or its subsidiaries in the United States or othercountries or in both.

    - HP and HP-UX are trademarks of Hewlett-Packard Inc., U.S.A.

    - Micro Focus is a trademark of Micro Focus International Limited

    - Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of theirrespective owners. Oracle Solaris might be described as Solaris, Solaris Operating System, or Solaris OS.

    - Windows, Windows Server, MSDN, Visual Studio, and .NET are trademarks or registered trademarks of MicrosoftCorporation in the United States and/or other countries.

    - Linux is a registered trademark of Mr. Linus Torvalds in the United States and other countries.

    - UNIX is a registered trademark of The Open Group in the United States and other countries.

    - Intel and Itanium are registered trademarks of Intel Corporation.

    - Other brand and product names are trademarks or registered trademarks of their respective owners.

    NetCOBOL is copyrighted by Fujitsu Limited with all rights reserved. As a component of that program NetCOBOL useslibXpm developed by Groupe BULL and licensed to Fujitsu Limited under the requirement to reflect the followingpermission only as it pertains to the libXpm.

    Copyright 1989-94 GROUPE BULL

    Permission is hereby granted, free of charge, to any person obtaining a copy of the libXpm and associated documentationfiles (the "libXpm software"), to deal in the libXpm software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the libXpm Software, and to permit personsto whom the libXpm Software is furnished to do so, subject to the following conditions: The above copyright notice andthis permission notice shall be included in all copies or substantial portions of the Software.

    - vii -

  • THE LIBXPM SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR APARTICULAR PURPOSE AND NONINFRIGEMENT. IN NO EVENT SHALL GROUPE BULL BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM, OUT OF OR IN CONNECTION WITH THE LIBXPM SOFTWARE OR THE USE OR OTHERDEALINGS IN THE LIBXPM SOFTWARE.

    Except as contained in this notice, the name of GROUPE BULL shall not be used in advertising or otherwise to promotethe sale, use or other dealings in this libXpm software without prior written authorization from GROUPE BULL.

    Export Regulation

    Exportation/release of this document may require necessary procedures in accordance with the regulations of your residentcountry and/or US export control laws.

    Acknowledgment

    COBOL language specifications are based on the original specifications developed by the Conference on Data SystemsLanguages (CODASYL), and specifications in this manual are also derived from these specifications. The chapters listedbelow were included on request from CODASYL.

    COBOL is not owned by any particular company, organization, or group; it has been designed for general use in industry.CODASYL does not guarantee and bears no responsibility in relation to the programming method, the accuracy of language,and functions.

    The following copyright owners permitted partial use of the following documents when the original specifications were puttogether. This permission also extends to the use of the original specifications in other COBOL specifications.

    - FLOW-MATIC (trademark of Sperryrand Inc.), "Programming for the Univac I and II, Data Automation Systems",copyright Sperryrand Inc. 1958, 1959

    - IBM Commercial Translator, library number F28-8013, copyright IBM Inc. 1959

    - FACT, library number 27A5260-2760, copyright Minneapolis Honeywell Inc. 1960

    The contents of this manual may be revised without prior notice. No part of this document may be reproduced or transmittedin any form or by any means, electronic or mechanical, for any purpose, without the express written permission of FujitsuLimited.

    February 2017

    Copyright 1996-2017 FUJITSU LIMITED

    - viii -

  • ContentsChapter 1 General Rules..........................................................................................................................................................1

    1.1 Characters and Character Sets............................................................................................................................................................. 11.2 Basic Overview of the Language.........................................................................................................................................................2

    1.2.1 Separator....................................................................................................................................................................................... 21.2.2 COBOL Word...............................................................................................................................................................................4

    1.2.2.1 User-defined Words...............................................................................................................................................................51.2.2.1.1 Rules for Describing User-defined Words......................................................................................................................61.2.2.1.2 Application of User-defined Words................................................................................................................................7

    1.2.2.2 System Name......................................................................................................................................................................... 81.2.2.3 Reserved Words.....................................................................................................................................................................91.2.2.4 FUNCTION-NAME............................................................................................................................................................ 11

    1.2.3 Literal..........................................................................................................................................................................................111.2.3.1 Numeric Literal....................................................................................................................................................................111.2.3.2 Nonnumeric Literal..............................................................................................................................................................121.2.3.3 Hexadecimal Nonnumeric Literal........................................................................................................................................131.2.3.4 National Nonnumeric Literal............................................................................................................................................... 141.2.3.5 Boolean Literal.................................................................................................................................................................... 15

    1.2.4 Figurative Constant.....................................................................................................................................................................151.2.5 Concatenation Expression...........................................................................................................................................................171.2.6 Literals for Special Applications................................................................................................................................................ 171.2.7 Picture Character-string.............................................................................................................................................................. 181.2.8 Comment Entry...........................................................................................................................................................................18

    1.3 Concept of Data Description..............................................................................................................................................................181.3.1 Concept of Levels....................................................................................................................................................................... 181.3.2 Concept of Class......................................................................................................................................................................... 181.3.3 Concept of Types........................................................................................................................................................................ 19

    1.3.3.1 Weakly-Typed Item............................................................................................................................................................. 191.3.3.2 Strongly-Typed Item............................................................................................................................................................20

    1.3.4 Standard Alignment Rule............................................................................................................................................................211.3.5 Adjustment of Data Boundaries..................................................................................................................................................21

    1.3.5.1 Slack Byte............................................................................................................................................................................ 211.3.5.2 Slack Bit...............................................................................................................................................................................23

    1.4 Uniqueness of Reference................................................................................................................................................................... 251.4.1 Qualification............................................................................................................................................................................... 251.4.2 Subscripting................................................................................................................................................................................ 281.4.3 Reference Modification.............................................................................................................................................................. 291.4.4 Pointer.........................................................................................................................................................................................311.4.5 Identifier......................................................................................................................................................................................321.4.6 Condition-name Uniqueness of Reference ................................................................................................................................ 321.4.7 Function-identifier...................................................................................................................................................................... 33

    1.5 Reference Format...............................................................................................................................................................................331.5.1 Configuration of a Source Code Line......................................................................................................................................... 341.5.2 Reference Format for Area A and Area B.................................................................................................................................. 351.5.3 Blank Line...................................................................................................................................................................................351.5.4 Comment Line............................................................................................................................................................................ 361.5.5 Continuation of Lines................................................................................................................................................................. 361.5.6 Debugging Line.......................................................................................................................................................................... 371.5.7 In-line Comment......................................................................................................................................................................... 371.5.8 Reference Format for Free Format............................................................................................................................................. 37

    1.5.8.1 Configuration of a Line........................................................................................................................................................371.5.8.2 Blank Line............................................................................................................................................................................381.5.8.3 Comment Lines....................................................................................................................................................................381.5.8.4 Continuation of Lines.......................................................................................................................................................... 381.5.8.5 Debugging Line................................................................................................................................................................... 38

    - ix -

  • 1.6 Program Configuration...................................................................................................................................................................... 381.6.1 Returning Result from a Program...............................................................................................................................................39

    1.7 Operation Mode................................................................................................................................................................................. 39

    Chapter 2 COBOL Modules....................................................................................................................................................412.1 Nucleus.............................................................................................................................................................................................. 41

    2.1.1 Transcription and Movement of Data.........................................................................................................................................432.1.2 Arithmetic Operations.................................................................................................................................................................442.1.3 Optional Processing and Branching............................................................................................................................................442.1.4 Repetitive Processing..................................................................................................................................................................452.1.5 Table Handling........................................................................................................................................................................... 462.1.6 Initialization of Data Items......................................................................................................................................................... 492.1.7 Handling Character Strings.........................................................................................................................................................492.1.8 Simple Input-Output................................................................................................................................................................... 502.1.9 Terminating a Program............................................................................................................................................................... 502.1.10 Pointer Handling....................................................................................................................................................................... 502.1.11 Handling Floating-Point Data Items......................................................................................................................................... 51

    2.2 Input-Output Facility......................................................................................................................................................................... 522.2.1 File Organization........................................................................................................................................................................ 532.2.2 File Connector.............................................................................................................................................................................542.2.3 Operation of Input-Output Statements........................................................................................................................................552.2.4 File Position (Record Pointer) Indicator.....................................................................................................................................562.2.5 Volume Indicator........................................................................................................................................................................ 562.2.6 Sharing and Exclusion of Files................................................................................................................................................... 562.2.7 Locking a Record........................................................................................................................................................................572.2.8 I-O Status.................................................................................................................................................................................... 582.2.9 Record Format............................................................................................................................................................................ 592.2.10 Record Area.............................................................................................................................................................................. 592.2.11 LINAGE-COUNTER Special Register.................................................................................................................................... 60

    2.3 Inter-program Communication Module.............................................................................................................................................602.3.1 Accessing and Returning to a Program.......................................................................................................................................612.3.2 Global Name and Local Name....................................................................................................................................................612.3.3 External Attribute and Internal Attribute....................................................................................................................................622.3.4 External Name and Internal Name..............................................................................................................................................622.3.5 Program Activation.....................................................................................................................................................................632.3.6 The Common Attribute ..............................................................................................................................................................632.3.7 Initial State of a Program............................................................................................................................................................ 632.3.8 Recursive Attribute of the Program............................................................................................................................................ 642.3.9 Passing Parameters to the Called Program................................................................................................................................. 642.3.10 Scope of Names........................................................................................................................................................................ 652.3.11 Scope of a Program-name and Secondary Entry Point Names(*)............................................................................................ 662.3.12 PROGRAM-STATUS and RETURN-CODE Special Registers..............................................................................................67

    2.4 Sort-Merge Module............................................................................................................................................................................672.4.1 Sorting Methods..........................................................................................................................................................................682.4.2 Merging Methods........................................................................................................................................................................682.4.3 SORT Input Procedure................................................................................................................................................................682.4.4 Sort-Merge Output Procedures................................................................................................................................................... 682.4.5 Sort-merge File........................................................................................................................................................................... 682.4.6 Special Register.......................................................................................................................................................................... 69

    2.4.6.1 SORT-STATUS...................................................................................................................................................................692.4.6.2 SORT-CORE-SIZE............................................................................................................................................................. 69

    2.5 Source Text Manipulation Module.................................................................................................................................................... 692.6 Presentation File Module................................................................................................................................................................... 70

    2.6.1 Destination Type.........................................................................................................................................................................712.6.2 Screen Form Descriptor.............................................................................................................................................................. 722.6.3 File Organization and Access Mode...........................................................................................................................................722.6.4 Presentation File Input-Output Statements................................................................................................................................. 72

    - x -

  • 2.6.5 I-O Status.................................................................................................................................................................................... 722.6.6 Presentation File Special Registers.............................................................................................................................................73

    2.7 Intrinsic Function Module................................................................................................................................................................. 742.8 Screen Handling Module................................................................................................................................................................... 76

    2.8.1 Screen and Screen Item...............................................................................................................................................................762.8.1.1 Screen Data Description Entry............................................................................................................................................ 762.8.1.2 Screen Item.......................................................................................................................................................................... 76

    2.8.2 Input-Output Handling of the Screen..........................................................................................................................................772.8.3 Screen Input Status..................................................................................................................................................................... 77

    2.9 Command Line Argument and Environment Variable Modules.......................................................................................................772.9.1 Processing Command Line Arguments...................................................................................................................................... 78

    2.9.1.1 Method for Finding the Number of Command Line Arguments.........................................................................................782.9.1.2 Method for Obtaining the Value of Individual Command Line Arguments....................................................................... 78

    2.9.2 Accessing an Environment Variable...........................................................................................................................................792.9.2.1 Accessing the Value of an Environment Variable...............................................................................................................792.9.2.2 Updating the Value of an Environment Variable................................................................................................................ 79

    2.10 Report Writer Module......................................................................................................................................................................792.10.1 Report File................................................................................................................................................................................ 812.10.2 Report Writer Special Registers............................................................................................................................................... 81

    2.10.2.1 Page Counter......................................................................................................................................................................812.10.2.2 Line-Counter......................................................................................................................................................................81

    Chapter 3 Identification Division and End Program Header...................................................................................................823.1 Composition of the Identification Division....................................................................................................................................... 82

    3.1.1 Program-Id Paragraph.................................................................................................................................................................823.1.2 DATE-COMPILED Paragraph...................................................................................................................................................83

    3.2 End Program Header..........................................................................................................................................................................84

    Chapter 4 Environment Division.............................................................................................................................................864.1 Composition of the Environment Division........................................................................................................................................864.2 CONFIGURATION SECTION.........................................................................................................................................................86

    4.2.1 SOURCE-COMPUTER Paragraph............................................................................................................................................ 864.2.1.1 WITH DEBUGGING MODE Clause..................................................................................................................................87

    4.2.2 OBJECT-COMPUTER Paragraph............................................................................................................................................. 874.2.2.1 MEMORY SIZE Clause...................................................................................................................................................... 874.2.2.2 PROGRAM COLLATING SEQUENCE Clause................................................................................................................ 88

    4.2.3 SPECIAL-NAMES Paragraph....................................................................................................................................................894.2.3.1 Function-name-1 Clause...................................................................................................................................................... 894.2.3.2 Function-name-2 Clause...................................................................................................................................................... 924.2.3.3 Function-name-3 Clause...................................................................................................................................................... 934.2.3.4 ALPHABET Clause.............................................................................................................................................................934.2.3.5 CLASS Clause..................................................................................................................................................................... 964.2.3.6 CRT STATUS Clause..........................................................................................................................................................974.2.3.7 CURRENCY SIGN Clause................................................................................................................................................. 984.2.3.8 CURSOR Clause..................................................................................................................................................................984.2.3.9 DECIMAL-POINT IS COMMA Clause............................................................................................................................. 994.2.3.10 POSITIONING UNIT Clause............................................................................................................................................994.2.3.11 PRINTING MODE Clause................................................................................................................................................ 994.2.3.12 SYMBOLIC CHARACTERS Clause............................................................................................................................. 1014.2.3.13 SYMBOLIC CONSTANT Clause...................................................................................................................................102

    4.3 Input-Output Section........................................................................................................................................................................1034.3.1 File-Control Paragraph............................................................................................................................................................. 103

    4.3.1.1 ACCESS MODE Clause (Sequential, Relative, Indexed, Presentation(*), and Report Writer Files)...............................1104.3.1.2 ALTERNATE RECORD KEY Clause (Indexed File)......................................................................................................1124.3.1.3 ASSIGN Clause (Sequential File, Relative File, and Indexed File)..................................................................................1134.3.1.4 ASSIGN Clause (Sort-merge and Report Writer)............................................................................................................. 1154.3.1.5 ASSIGN Clause (Presentation File).................................................................................................................................. 1154.3.1.6 DESTINATION Clause (Presentation File)...................................................................................................................... 116

    - xi -

  • 4.3.1.7 END KEY Clause (Presentation File)............................................................................................................................... 1164.3.1.8 FILE STATUS Clause (Sequential File, Relative File, Indexed File, Presentation File(*), and Report Writer)..............1174.3.1.9 FORMAT Clause (Sequential File, Presentation File)...................................................................................................... 1184.3.1.10 GROUP Clause (Sequential File, Presentation File)....................................................................................................... 1184.3.1.11 LOCK MODE Clause (Sequential File, Relative File, and Indexed File).......................................................................1194.3.1.12 MESSAGE CLASS Clause (Presentation File)...............................................................................................................1204.3.1.13 MESSAGE CODE Clause (Presentation File)................................................................................................................ 1204.3.1.14 MESSAGE MODE Clause (Presentation File)............................................................................................................... 1214.3.1.15 MESSAGE OWNER Clause (Presentation File).............................................................................................................1224.3.1.16 MESSAGE SEQUENCE Clause (Presentation File)...................................................................................................... 1224.3.1.17 ORGANIZATION Clause (Sequential File)................................................................................................................... 1234.3.1.18 ORGANIZATION Clause (Relative File).......................................................................................................................1234.3.1.19 ORGANIZATION Clause (Indexed File)....................................................................................................................... 1234.3.1.20 ORGANIZATION Clause (Presentation File(*) and Report Writer)..............................................................................1244.3.1.21 PADDING CHARACTER Clause (Sequential File).......................................................................................................1244.3.1.22 PROCESSING CONTROL Clause (Presentation File)...................................................................................................1244.3.1.23 PROCESSING MODE Clause (Presentation File)..........................................................................................................1244.3.1.24 PROCESSING TIME Clause (Presentation File)............................................................................................................1254.3.1.25 RECORD DELIMITER Clause (Sequential File)........................................................................................................... 1264.3.1.26 RECORD KEY Clause (Indexed File)............................................................................................................................ 1264.3.1.27 RESERVE Clause (Sequential File, Relative File, Indexed File, and Report Writer).................................................... 1274.3.1.28 SELECT Clause (Sequential File, Relative File, Indexed File, and Report Writer)....................................................... 1274.3.1.29 SELECT Clause (Sort-merge and Presentation File(*))..................................................................................................1284.3.1.30 SELECTED FUNCTION Clause (Presentation File)......................................................................................................1284.3.1.31 SESSION CONTROL Clause (Presentation File)...........................................................................................................1284.3.1.32 SYMBOLIC DESTINATION Clause (Presentation File)...............................................................................................1294.3.1.33 UNIT CONTROL Clause (Presentation File)................................................................................................................. 130

    4.3.2 I-O-Control Paragraph (I-O-CONTROL).................................................................................................................................1304.3.2.1 APPLY MULTICONVERSATION-MODE Clause (Presentation File).......................................................................... 1314.3.2.2 APPLY SAVED-AREA Clause (Presentation File)..........................................................................................................1324.3.2.3 MULTIPLE FILE TAPE Clause (Sequential File and Report Writer)............................................................................. 1324.3.2.4 RERUN Clause (Sequential File, Relative File and Indexed File)....................................................................................1324.3.2.5 SAME Clause (Sequential, Relative, Indexed, Sort-merge, Presentation File(*), and Report Writer Files).................... 132

    Chapter 5 Data Division........................................................................................................................................................1355.1 Composition of the Data Division................................................................................................................................................... 1355.2 File Description Entry......................................................................................................................................................................139

    5.2.1 BLOCK CONTAINS Clause (Sequential File, Relative File, Indexed File, and Report Writer Module)...............................1405.2.2 CODE-SET Clause (Sequential File and Report Writer Module)............................................................................................1415.2.3 CONTROL RECORDS Clause (Sequential File).................................................................................................................... 1415.2.4 DATA RECORDS Clause (Sequential File, Relative File, and Indexed File).........................................................................1425.2.5 ENCODING Clause (Sequential File, Relative File, Indexed File, and Presentation File)..................................................... 1425.2.6 EXTERNAL Clause (Sequential File, Relative File, Indexed File, Presentation File(*), and Report Writer Module)...........1435.2.7 GLOBAL Clause (Sequential File, Relative File, Indexed File, Presentation File(*), and Report Writer Module)................1435.2.8 LABEL RECORDS Clause (Sequential File, Relative File, Indexed File, and Report Writer File)....................................... 1445.2.9 LINAGE Clause (Sequential File)............................................................................................................................................1445.2.10 RECORD Clause (Sequential File, Relative File, and Indexed File)..................................................................................... 1465.2.11 RECORD Clause (Presentation File)......................................................................................................................................1495.2.12 RECORD Clause (Report Writer Module).............................................................................................................................1495.2.13 REPORT Clause (Report Writer Module)..............................................................................................................................1505.2.14 VALUE OF Clause (Sequential File, Relative File, Indexed File, and Report Writer Module)............................................150

    5.3 Sort-Merge File Description Entry.................................................................................................................................................. 1505.4 Data Description Entry.................................................................................................................................................................... 151

    5.4.1 BASED ON Clause...................................................................................................................................................................1545.4.2 BLANK WHEN ZERO Clause................................................................................................................................................ 1555.4.3 CHARACTER TYPE Clause................................................................................................................................................... 1555.4.4 ENCODING Clause..................................................................................................................................................................159

    - xii -

  • 5.4.5 EXTERNAL Clause................................................................................................................................................................. 1615.4.6 GLOBAL Clause...................................................................................................................................................................... 1625.4.7 JUSTIFIED Clause................................................................................................................................................................... 1625.4.8 OCCURS Clause.......................................................................................................................................................................1635.4.9 PICTURE Clause......................................................................................................................................................................1655.4.10 PRINTING POSITION Clause...............................................................................................................................................1765.4.11 REDEFINES Clause............................................................................................................................................................... 1775.4.12 RENAMES Clause................................................................................................................................................................. 1785.4.13 SIGN Clause........................................................................................................................................................................... 1795.4.14 SYNCHRONIZED Clause..................................................................................................................................................... 1805.4.15 TYPE Clause...........................................................................................................................................................................1825.4.16 TYPEDEF Clause................................................................................................................................................................... 1835.4.17 USAGE Clause....................................................................................................................................................................... 1845.4.18 VALUE Clause....................................................................................................................................................................... 191

    5.5 Screen Data Description Entry........................................................................................................................................................ 1935.5.1 AUTO Clause........................................................................................................................................................................... 1965.5.2 BACKGROUND-COLOR Clause........................................................................................................................................... 1965.5.3 BELL Clause.............................................................................................................................................................................1975.5.4 BLANK LINE Clause...............................................................................................................................................................1975.5.5 BLANK SCREEN Clause........................................................................................................................................................ 1975.5.6 BLANK WHEN ZERO Clause................................................................................................................................................ 1985.5.7 BLINK Clause.......................................................................................................................................................................... 1985.5.8 COLUMN NUMBER Clause................................................................................................................................................... 1995.5.9 ERASE Clause..........................................................................................................................................................................1995.5.10 FOREGROUND-COLOR Clause.......................................................................................................................................... 2005.5.11 FULL Clause...........................................................................................................................................................................2015.5.12 HIGHLIGHT Clause...............................................................................................................................................................2015.5.13 JUSTIFIED Clause................................................................................................................................................................. 2025.5.14 LINE NUMBER Clause......................................................................................................................................................... 2025.5.15 LOWLIGHT Clause............................................................................................................................................................... 2035.5.16 PICTURE Clause....................................................................................................................................................................2035.5.17 REQUIRED Clause................................................................................................................................................................ 2055.5.18 REVERSE-VIDEO Clause..................................................................................................................................................... 2055.5.19 SECURE Clause..................................................................................................................................................................... 2055.5.20 SIGN Clause........................................................................................................................................................................... 2065.5.21 UNDERLINE Clause..............................................................................................................................................................2065.5.22 USAGE Clause....................................................................................................................................................................... 2065.5.23 VALUE Clause....................................................................................................................................................................... 207

    5.6 Report Description Entry................................................................................................................................................................. 2075.6.1 CODE Clause............................................................................................................................................................................2095.6.2 CONTROL Clause....................................................................................................................................................................2095.6.3 PAGE Clause............................................................................................................................................................................ 210

    5.7 Report Group Description Entry......................................................................................................................................................2125.7.1 COLUMN NUMBER Clause................................................................................................................................................... 2155.7.2 GROUP INDICATE Clause..................................................................................................................................................... 2155.7.3 LINE NUMBER Clause........................................................................................................................................................... 2165.7.4 NEXT GROUP Clause............................................................................................................................................................. 2175.7.5 SIGN Clause............................................................................................................................................................................. 2175.7.6 SOURCE Clause.......................................................................................................................................................................2185.7.7 SUM Clause..............................................................................................................................................................................2185.7.8 TYPE Clause.............................................................................................................................................................................2205.7.9 USAGE Clause......................................................................................................................................................................... 2245.7.10 VALUE Clause....................................................................................................................................................................... 224

    5.8 Report Group Presentation Rules.................................................................................................................................................... 2255.8.1 How to Use the Presentation Table Rules ............................................................................................................................... 2255.8.2 Report Heading Group Presentation Rules...............................................................................................................................2265.8.3 Page Heading Group Presentation Rules.................................................................................................................................. 228

    - xiii -

  • 5.8.4 Report Body Group Presentation Rules....................................................................................................................................2295.8.5 Page Footing Group Presentation Rules................................................................................................................................... 2315.8.6 Report Footing Group Presentation Rule..................................................................................................................................232

    Chapter 6 Procedure Division...............................................................................................................................................2346.1 Composition of the Procedure Division...........................................................................................................................................2346.2 Procedure Division Header..............................................................................................................................................................2386.3 Common Statement Rules............................................................................................................................................................... 240

    6.3.1 Arithmetic Expressions.............................................................................................................................................................2406.3.2 Boolean Expressions.................................................................................................................................................................2426.3.3 Conditional Expressions........................................................................................................................................................... 244

    6.3.3.1 Relation Condition.............................................................................................................................................................2446.3.3.2 Class Condition..................................................................................................................................................................2456.3.3.3 Condition-name ................................................................................................................................................................ 2476.3.3.4 Switch-status Condition.....................................................................................................................................................2486.3.3.5 Sign Condition................................................................................................................................................................... 2486.3.3.6 Complex Condition............................................................................................................................................................2486.3.3.7 Abbreviating a Combined Relation Condition.................................................................................................................. 254

    6.3.4 Comparison Rules.....................................................................................................................................................................2556.3.5 Rules for Moving (Transcribing) Data..................................................................................................................................... 2606.3.6 Arithmetic Statements...............................................................................................................................................................2636.3.7 More Than One Arithmetic Result .......................................................................................................................................... 2646.3.8 ROUNDED Phrase................................................................................................................................................................... 2646.3.9 ON SIZE ERROR Phrase......................................................................................................................................................... 2656.3.10 CORRESPONDING Phrase................................................................................................................................................... 2666.3.11 Overlapping of Operands........................................................................................................................................................2666.3.12 INVALID KEY Phrase...........................................................................................................................................................2666.3.13 AT END Phrase...................................................................................................................................................................... 2676.3.14 Incompatible Data...................................................................................................................................................................269

    6.4 Statements........................................................................................................................................................................................2696.4.1 ACCEPT Statement (Nucleus)................................................................................................................................................. 2696.4.2 ACCEPT Statement (Screen Handling)....................................................................................................................................2716.4.3 ACCEPT Statement (Command Line Arguments and Environmental Variables)...................................................................2726.4.4 ADD Statement (Nucleus)........................................................................................................................................................ 2736.4.5 ALTER Statement (Nucleus)....................................................................................................................................................2746.4.6 CALL Statement (Inter-program Communication).................................................................................................................. 2756.4.7 CANCEL Statement (Inter-program Communication).............................................................................................................2806.4.8 CLOSE Statement (Sequential, Relative, Indexed, Presentation File(*), and Report Writer Module)....................................2816.4.9 COMPUTE Statement (Nucleus)..............................................................................................................................................2846.4.10 CONTINUE Statement (Nucleus).......................................................................................................................................... 2856.4.11 DELETE Statement (Relative and Indexed Files)..................................................................................................................2856.4.12 DISPLAY Statement (Nucleus)..............................................................................................................................................2876.4.13 DISPLAY Statement (Screen Handling)................................................................................................................................ 2886.4.14 DISPLAY Statement (Command Line Arguments and Environmental Variables)............................................................... 2896.4.15 DIVIDE Statement (Nucleus).................................................................................................................................................2906.4.16 ENTRY Statement (Inter-program Communication)............................................................................................................. 2936.4.17 EVALUATE Statement (Nucleus)......................................................................................................................................... 2946.4.18 EXIT Statement (Nucleus)......................................................................................................................................................2986.4.19 EXIT PERFORM Statement (Nucleus)..................................................................................................................................2986.4.20 EXIT PROGRAM Statement (Inter-program Communication).............................................................................................2996.4.21 GENERATE Statement (Report writer)................................................................................................................................. 2996.4.22 GO TO Statement (Nucleus)...................................................................................................................................................3016.4.23 IF Statement (Nucleus)........................................................................................................................................................... 3026.4.24 INITIALIZE Statement (Nucleus)..........................................................................................................................................3036.4.25 INITIATE Statement (Report writer)..................................................................................................................................... 3056.4.26 INSPECT Statement............................................................................................................................................................... 3066.4.27 MERGE Statement (Sort-merge)............................................................................................................................................314

    - xiv -

  • 6.4.28 MOVE Statement (Nucleus)...................................................................................................................................................3196.4.29 MULTIPLY Statement (Nucleus).......................................................................................................................................... 3216.4.30 OPEN Statement (Sequential File, Relative File, Indexed File).............................................................................................3226.4.31 OPEN Statement (Presentation File)...................................................................................................................................... 3266.4.32 OPEN Statement (Report Writer)........................................................................................................................................... 3276.4.33 PERFORM Statement (Nucleus)............................................................................................................................................ 3286.4.34 READ Statement (Sequential File, Relative File, Indexed File)............................................................................................ 3366.4.35 READ Statement (Presentation File)......................................................................................................................................3436.4.36 RELEASE Statement (Sort-merge)........................................................................................................................................ 3456.4.37 RETURN Statement (Sort-merge)..........................................................................................................................................3456.4.38 REWRITE Statement (Sequential File, Relative File, Indexed File)..................................................................................... 3466.4.39 SEARCH Statement (Nucleus)...............................................................................................................................................3496.4.40 SET Statement (Nucleus)........................................................................................................................................................3546.4.41 SORT Statement (Sort-merge)................................................................................................................................................3566.4.42 START Statement (Relative File)...........................................................................................................................................3616.4.43 START Statement (Indexed File)........................................................................................................................................... 3626.4.44 STOP Statement (Nucleus).....................................................................................................................................................3676.4.45 STRING Statement (Nucleus)................................................................................................................................................ 3676.4.46 SUBTRACT Statement (Nucleus)..........................................................................................................................................3736.4.47 SUPPRESS Statement (Report Writer).................................................................................................................................. 3756.4.48 TERMINATE Statement (Report Writer).............................................................................................................................. 3756.4.49 UNLOCK Statement (Sequential File, Relative File, Indexed File)...................................................................................... 3766.4.50 UNSTRING Statement (Nucleus).......................................................................................................................................... 3766.4.51 USE Statement (Sequential, Relative, Indexed, Presentation File, and Report Writer Module)............................................3856.4.52 USE BEFORE REPORTING Statement (Report Writer)...................................................................................................... 3876.4.53 USE FOR DEAD-LOCK Statement.......................................................................................................................................3886.4.54 WRITE Statement (Sequential File)....................................................................................................................................... 3896.4.55 WRITE Statement (Relative and Indexed Files).................................................................................................................... 3946.4.56 WRITE Statement (Presentation File).................................................................................................................................... 397

    6.5 General Rules for Functions............................................................................................................................................................ 3986.5.1 Function Call Format................................................................................................................................................................ 3986.5.2 Types of Arguments..................................................................................................................................................................3986.5.3 Rules Applied for Specifying a Table as an Argument............................................................................................................ 3996.5.4 Function Types......................................................................................................................................................................... 399

    6.6 Functions..........................................................................................................................................................................................4006.6.1 ACOS Function.........................................................................................................................................................................4006.6.2 ADDR Function........................................................................................................................................................................4006.6.3 ANNUITY Function................................................................................................................................................................. 4016.6.4 ASIN Function..........................................................................................................................................................................4026.6.5 ATAN Function........................................................................................................................................................................ 4026.6.6 CAST-ALPHANUMERIC Function........................................................................................................................................4026.6.7 CHAR Function........................................................................................................................................................................ 4036.6.8 COS Function........................................................................................................................................................................... 4036.6.9 CURRENT-DATE Function.....................................................................................................................................................4046.6.10 DATE-OF-INTEGER Function..............................................................................................................................................4056.6.11 DAY-OF-INTEGER Function................................................................................................................................................4056.6.12 DISPLAY-OF Function..........................................................................................................................................................4056.6.13 FACTORIAL Function...........................................................................................................................................................4066.6.14 INTEGER Function................................................................................................................................................................ 4076.6.15 INTEGER-OF-DATE Function..............................................................................................................................................4076.6.16 INTEGER-OF-DAY Function................................................................................................................................................4086.6.17 INTEGER-PART Function.....................................................................................................................................................4086.6.18 LENG Function.......................................................................................................................................................................4096.6.19 LENGTH Function................................................................................................................................................................. 4096.6.20 LOG Function......................................................................................................................................................................... 4106.6.21 LOG10 Function..................................................................................................................................................................... 4116.6.22 LOWER-CASE Function....................................................................................................................................................... 411

    - xv -

  • 6.6.23 MAX Function........................................................................................................................................................................4116.6.24 MEAN Function..................................................................................................................................................................... 4126.6.25 MEDIAN Function................................................................................................................................................................. 4126.6.26 MIDRANGE Function............................................................................................................................................................4136.6.27 MIN Function......................................................................................................................................................................... 4136.6.28 MOD Function........................................................................................................................................................................4146.6.29 NATIONAL Function.............................................................................................................................................................4146.6.30 NATIONAL-OF Function...................................................................................................................................................... 4156.6.31 NUMVAL Function................................................................................................................................................................4166.6.32 NUMVAL-C Function............................................................................................................................................................4166.6.33 ORD Function.........................................................................................................................................................................4176.6.34 ORD-MAX Function.............................................................................................................................................................. 4186.6.35 ORD-MIN Function.................................