You are previewing COBOL for the 21st Century.
O'Reilly logo
COBOL for the 21st Century

Book Description

COBOL . . . Still standing tall.

Just like the evergreen, the COBOL programming language has remained vibrant and full of life year after year. Today, COBOL is running a large number of the world's business data applications, and it's likely to remain a viable language in the years ahead.

Now in its 11th Edition, Nancy Stern, Robert Stern, and James Ley's COBOL for the 21st Century continues to show how to design COBOL programs that are easy to read, debug, modify, and maintain. You'll learn to write interactive programs as well as batch programs with sophisticated file processing techniques, and become familiar with valuable information processing and systems concepts.

  • Features

  • Updated to reflect COBOL 2008, where appropriate.

  • A chapter on the Report Writer Module.

  • More end-of-chapter questions.

  • A running case study builds on what you have learned in each chapter.

  • Integrated coverage of interactive programming.

  • Covers information processing and systems concepts that will help you interact with users and systems analysts when designing programs.

  • Introduces programming tools such as pseudocode and hierarchy charts that make program logic more structured, modular, and top-down.

  • Presents useful techniques for maintaining and modifying older "legacy" programs.

  • Effective learning tools, including chapter outlines and objectives, debugging tips and exercises, critical-thinking questions, and programming assignments.

  • Links to COBOL Internet resources.

  • Companion Website (www.wiley.com/college/stern), featuring a syntax reference guide, data sets for all programming assignments, and all programs illustrated in the book.

  • Table of Contents

    1. Copyright
    2. PREFACE
      1. INTENDED AUDIENCE
      2. SIGNIFICANCE OF COBOL AS A PROGRAMMING LANGUAGE FOR THE 21ST CENTURY
      3. OBJECTIVES OF THIS BOOK
      4. HIGHLIGHTS OF THIS EDITION
      5. FEATURES OF THE TEXT
        1. Format
        2. End-of-Chapter Material
      6. INSTRUCTIONAL AIDS
        1. Instructor Supplements
        2. Student Supplements
        3. COBOL Web Site
    3. ACKNOWLEDGMENTS
    4. I. THE BASICS
      1. 1. An Introduction to Structured Program Design in COBOL
        1. 1.1. COMPUTER PROGRAMMING: AN OVERVIEW
          1. 1.1.1. Types of Computer Programs
          2. 1.1.2. Applications Programs
          3. 1.1.3. Machine Language Programs
          4. 1.1.4. Symbolic Programs
        2. 1.2. THE APPLICATIONS PROGRAM DEVELOPMENT PROCESS
          1. 1.2.1. Determine Program Specifications
          2. 1.2.2. Design the Program Using Program Planning Tools
          3. 1.2.3. Code and Enter the Program
          4. 1.2.4. Compile the Source Program
          5. 1.2.5. Test the Program
            1. 1.2.5.1. Debugging During the Compile and Test Phases
              1. 1.2.5.1.1. Compile-Time Errors
              2. 1.2.5.1.2. Execution Errors
            2. 1.2.5.2. Debugging Techniques
              1. 1.2.5.2.1. Desk Checking
              2. 1.2.5.2.2. Correcting Syntax Errors
              3. 1.2.5.2.3. Program Walkthroughs
              4. 1.2.5.2.4. Detecting Logic and Run-time Errors by Executing the Program
          6. 1.2.6. Document the Program
        3. 1.3. THE NATURE OF COBOL
          1. 1.3.1. COBOL Is a Business-Oriented Language
          2. 1.3.2. COBOL Is a Standard Language
          3. 1.3.3. COBOL Is an English-Like Language
          4. 1.3.4. COBOL Is Relatively Easy to Understand
        4. 1.4. A HISTORY OF COBOL AND THE ANS VERSIONS
          1. 1.4.1. When it Began
          2. 1.4.2. The American National Standards (ANS) Versions of COBOL
          3. 1.4.3. The Future of COBOL: Lessons Learned from the Year 2000 Problem
          4. 1.4.4. SELF-TEST
        5. 1.5. TECHNIQUES FOR IMPROVING PROGRAM DESIGN
          1. 1.5.1. Structured Programming Using Modular Design for Coding Paragraphs
          2. 1.5.2. The Top-Down Approach for Coding Modules
        6. 1.6. SAMPLE PROGREMS
          1. 1.6.1. Interactive vs. Batch Processing
          2. 1.6.2. An Overview of the Four Divisions
          3. 1.6.3. Definition of the Problem
            1. 1.6.3.1. Sample Interactive Program
              1. 1.6.3.1.1. Coding Rules
              2. 1.6.3.1.2. The IDENTIFICATION DIVISION of the Interactive Program
              3. 1.6.3.1.3. The DATA DIVISION of the Interactive Program
              4. 1.6.3.1.4. The PROCEDURE DIVISION of the Interactive Program
            2. 1.6.3.2. Sample Batch Program
              1. 1.6.3.2.1. Output Layout
              2. 1.6.3.2.2. The Program Illustrated
              3. 1.6.3.2.3. Coding Rules
              4. 1.6.3.2.4. The IDENTIFICATION and ENVIRONMENT DIVISIONs of the Batch Program
              5. 1.6.3.2.5. The DATA DIVISION of the Batch Program
              6. 1.6.3.2.6. The PROCEDURE DIVISION of the Batch Program
              7. 1.6.3.2.7. The Use of Periods
          4. 1.6.4. A Brief Overview of Program Planning Tools
          5. 1.6.5. Our Definitions for Batch and Interactive Programs
          6. 1.6.6. Summary of COBOL as a Language for Both Batch and Interactive Processing
        7. 1.7. ENTERING AND RUNNING A COBOL PROGRAM ON YOUR COMPUTER
        8. 1.8. CHAPTER SUMMARY
        9. 1.9. KEY TERMS
        10. 1.10. CHAPTER SELF-TEST
        11. 1.11. REVIEW QUESTIONS
        12. 1.12. PROGRAMMING ASSIGNMENTS
      2. 2. The IDENTIFICATION and ENVIRONMENT DIVISIONs
        1. 2.1. BASIC STRUCTURE OF A COBOL PROGRAM
          1. 2.1.1. Coding a Source Program
          2. 2.1.2. Coding Rules
            1. 2.1.2.1. The Main Body of a Program
            2. 2.1.2.2. Optional Entries: Identification and Page and Serial Numbers
            3. 2.1.2.3. Column 7: For Comments, Continuing Nonnumeric Literals, and Starting a New Page
              1. 2.1.2.3.1. Using Column 7 for Comments
              2. 2.1.2.3.2. Page-Eject with a Slash (/) in Column 7
            4. 2.1.2.4. Coding Rules for Areas A and B
          3. 2.1.3. Types of COBOL Entries
        2. 2.2. CODING REQUIREMENTS OF THE IDENTIFICATION DIVISION
          1. 2.2.1. Paragraphs in the IDENTIFICATION DIVISION
          2. 2.2.2. Understanding Instruction Formats as They Appear in Reference Manuals
          3. 2.2.3. Examples
          4. 2.2.4. SELF-TEST
        3. 2.3. THE SECTIONS OF THE ENVIRONMENT DIVISION
          1. 2.3.1. CONFIGURATION SECTION (Optional)
          2. 2.3.2. INPUT-OUTPUT SECTION
        4. 2.4. ASSIGNING FILES TO DEVICES IN THE ENVIRONMENT DIVISION
          1. 2.4.1. Overall Format
            1. 2.4.1.1. File-Name Rules
            2. 2.4.1.2. Implementor-Names or Device Specifications
        5. 2.5. CHAPTER SUMMARY
        6. 2.6. KEY TERMS
        7. 2.7. CHAPTER SELF-TEST
        8. 2.8. PRACTICE PROGRAM 1: INTERACTIVE PROCESSING
        9. 2.9. PRACTICE PROGRAM 2: BATCH PROCESSING
        10. 2.10. REVIEW QUESTIONS
        11. 2.11. PROGRAMMING ASSIGNMENTS
      3. 3. The DATA DIVISION
        1. 3.1. SYSTEMS DESIGN CONSIDERATIONS
          1. 3.1.1. The Relationship Between a Business Information System and its Programs
          2. 3.1.2. Interactive and Batch Processing
          3. 3.1.3. Designing Input for Applications Using Batch Processing
        2. 3.2. FORMING DATA-NAMES
          1. 3.2.1. Rules
          2. 3.2.2. Guidelines
            1. 3.2.2.1. Use Meaningful Data-Names
            2. 3.2.2.2. Use Prefixes or Suffixes in Data-Names Where Appropriate
        3. 3.3. THE FILE SECTION OF THE DATA DIVISION
          1. 3.3.1. An Overview
          2. 3.3.2. File Description Entries
            1. 3.3.2.1. LABEL RECORD(S) Clause—(Optional for COBOL 85, Required for COBOL 74, Eliminated from COBOL 2008)
            2. 3.3.2.2. RECORD CONTAINS Clause—(Optional)
            3. 3.3.2.3. BLOCK CONTAINS Clause—(Optional)
          3. 3.3.3. SELF-TEST
          4. 3.3.4. Record Description Entries
            1. 3.3.4.1. Defining a Record
            2. 3.3.4.2. Level Numbers
            3. 3.3.4.3. Fields May Be Defined as Either Elementary or Group Items
          5. 3.3.5. SELF-TEST
            1. 3.3.5.1. PICTURE (PIC) Clauses
              1. 3.3.5.1.1. Types of Data Fields
              2. 3.3.5.1.2. Size of Data Fields
              3. 3.3.5.1.3. Format of PIC Clauses
            2. 3.3.5.2. Allotting Space for Unused Areas in Record Description Entries
            3. 3.3.5.3. The Use of the Implied Decimal Point in PIC Clauses
            4. 3.3.5.4. Interactive Processing
            5. 3.3.5.5. Summary of Record Description Entries
        4. 3.4. TYPES OF DATA
          1. 3.4.1. Variable and Constant Data
          2. 3.4.2. Types of Constants
            1. 3.4.2.1. Numeric Literal
            2. 3.4.2.2. Interactive Processing
            3. 3.4.2.3. Nonnumeric Literal
            4. 3.4.2.4. Figurative Constant
        5. 3.5. THE WORKING-STORAGE SECTION OF THE DATA DIVISION
          1. 3.5.1. Introduction
          2. 3.5.2. Uses of WORKING-STORAGE
          3. 3.5.3. VALUE Clauses for WORKING-STORAGE Entries
            1. 3.5.3.1. The Purpose of VALUE Clauses
            2. 3.5.3.2. Literals and Figurative Constants in VALUE Clauses
            3. 3.5.3.3. Continuation of Nonnumeric Literals in VALUE Clauses from One Line to the Next
          4. 3.5.4. The DATA DIVISION and Interactive Processing
        6. 3.6. CHAPTER SUMMARY
        7. 3.7. KEY TERMS
        8. 3.8. CHAPTER SELF-TEST
        9. 3.9. PRACTICE PROGRAM 1: BATCH PROCESSING
        10. 3.10. PRACTICE PROGRAM 2: INTERACTIVE PROCESSING
        11. 3.11. REVIEW QUESTIONS
        12. 3.12. DEBUGGING EXERCISES
        13. 3.13. PROGRAMMING ASSIGNMENTS
      4. 4. Coding Complete COBOL Programs: The PROCEDURE DIVISION
        1. 4.1. A REVIEW OF THE FIRST THREE DIVISIONS
        2. 4.2. THE FORMAT OF THE PROCEDURE DIVISION
          1. 4.2.1. Paragraphs that Serve as Modules
            1. 4.2.1.1. Defining Paragraphs
            2. 4.2.1.2. Rules for Forming Paragraph-Names
          2. 4.2.2. Statements within Paragraphs
          3. 4.2.3. The Sequence of Instructions in a Program
          4. 4.2.4. The Top-Down Approach for Coding Paragraphs
        3. 4.3. Statements Typically Coded in the Main Module of Batch Programs
          1. 4.3.1. OPEN Statement
            1. 4.3.1.1. The Instruction Format: A Review
            2. 4.3.1.2. The Purpose of the OPEN Statement
          2. 4.3.2. PERFORM UNTIL ... END-PERFORM Statement:A Structured Programming Technique
          3. 4.3.3. READ Statement
          4. 4.3.4. More on PERFORM Statements
            1. 4.3.4.1. The Simple PERFORM
            2. 4.3.4.2. A Summary of PERFORMs
          5. 4.3.5. End-of-Job Processing: The CLOSE and STOP RUN Statements
            1. 4.3.5.1. CLOSE Statement
            2. 4.3.5.2. STOP RUN Statement
            3. 4.3.5.3. SELF-TEST
        4. 4.4. STATEMENTS TYPICALLY CODED IN FULLY INTERACTIVE PROGRAMS
        5. 4.5. STATEMENTS TYPICALLY CODED FOR PROCESSING BATCH FILES
          1. 4.5.1. Simplified MOVE Statement
          2. 4.5.2. WRITE Statement
        6. 4.6. LOOKING AHEAD
        7. 4.7. PROCESS-AND-CREATE-OUTPUT MODULE FOR INTERACTIVE PROGRAMS
        8. 4.8. COMPARING BATCH AND INTERACTIVE PROGRAMS
        9. 4.9. REVIEW OF COMMENTS IN COBOL
        10. 4.10. Y2K-COMPLIANT DATE FIELDS
        11. 4.11. CHAPTER SUMMARY
        12. 4.12. KEY TERMS
        13. 4.13. CHAPTER SELF-TEST
        14. 4.14. PRACTICE PROGRAM
        15. 4.15. REVIEW QUESTIONS
        16. 4.16. DEBUGGING EXERCISES
        17. 4.17. PROGRAMMING ASSIGNMENTS
    5. II. DESIGNING STRUCTURED PROGRAMS
      1. 5. Designing and Debugging Batch and Interactive COBOL Programs
        1. 5.1. WHAT MAKES A WELL-DESIGNED PROGRAM?
          1. 5.1.1. Program Logic Should Be Mapped Out Using a Planning Tool
          2. 5.1.2. Programs Should Be Structured
          3. 5.1.3. Programs Should Use a Top-Down Approach
          4. 5.1.4. Programs Should Be Modular
        2. 5.2. DESIGNING PROGRAMS BEFORE CODING THEM
          1. 5.2.1. How Programs Are Designed
          2. 5.2.2. Pseudocode
          3. 5.2.3. The Four Logical Control Structures
            1. 5.2.3.1. Sequence
            2. 5.2.3.2. Selection
            3. 5.2.3.3. Iteration
              1. 5.2.3.3.1. Format of a PERFORM UNTIL ... END-PERFORM Loop or Iteration
              2. 5.2.3.3.2. MAIN-MODULE
              3. 5.2.3.3.3. PARAGRAPH −1
              4. 5.2.3.3.4. A Simple PERFORM
            4. 5.2.3.4. Case Structure
        3. 5.3. ILLUSTRATING LOGICAL CONTROL STRUCTURES USING PSEUDOCODE
          1. 5.3.1. Example 1
          2. 5.3.2. Example 2
        4. 5.4. HIERARCHY CHARTS FOR TOP-DOWN PROGRAMMING
        5. 5.5. NAMING MODULES OR PARAGRAPHS
        6. 5.6. MODULARIZING PROGRAMS
        7. 5.7. A REVIEW OF TWO CODING GUIDELINES
          1. 5.7.1. Code Each Clause on a Separate Line
          2. 5.7.2. Indent Clauses within a Statement
        8. 5.8. MAKING INTERACTIVE PROGRAMS MORE USER-FRIENDLY
        9. 5.9. HOW TO BEGIN CODING, COMPILING, AND DEBUGGING PROGRAMS
          1. 5.9.1. Syntax Errors
          2. 5.9.2. Logic Errors
            1. 5.9.2.1. Designing Test Data That Is Comprehensive and Realistic
            2. 5.9.2.2. Checking for Logic Errors Using the DISPLAY Statement
              1. 5.9.2.2.1. Capturing Screen Displays in Interactive Processing
              2. 5.9.2.2.2. Common Error Notations Using Mainframe Compilers
          3. 5.9.3. The Use of Periods in the PROCEDURE DIVISION
        10. 5.10. CHAPTER SUMMARY
        11. 5.11. KEY TERMS
        12. 5.12. CHAPTER SELF-TEST
        13. 5.13. PRACTICE PROGRAM 1
        14. 5.14. PRACTICE PROGRAM 2
        15. 5.15. REVIEW QUESTIONS
        16. 5.16. PROGRAMMING ASSIGNMENTS
      2. 6. Moving Data, Printing Information, and Displaying Output Interactively
        1. 6.1. INTRODUCTION
        2. 6.2. THE INSTRUCTION FORMATS OF THE MOVE STATEMENT
          1. 6.2.1. SELF-TEST
        3. 6.3. NUMERIC MOVE
          1. 6.3.1. When Sending and Receiving Fields Have the Same PIC Clauses
          2. 6.3.2. When Sending and Receiving Fields Have Different PIC Clauses
            1. 6.3.2.1. Moving Integer Portions of Numeric Fields
            2. 6.3.2.2. Moving Decimal Portions of Numeric Fields
          3. 6.3.3. Moving Numeric Literals to Numeric Fields
          4. 6.3.4. Moving Signed Numbers: An Introduction
          5. 6.3.5. SELF-TEST
        4. 6.4. NONNUMERIC OR ALPHANUMERIC MOVE
          1. 6.4.1. Basic Rules
          2. 6.4.2. A Group Move Is Considered a Nonnumeric Move
          3. 6.4.3. SELF-TEST
        5. 6.5. OTHER OPTIONS OF THE MOVE STATEMENT
          1. 6.5.1. Qualification of Names
          2. 6.5.2. Performing Multiple Moves with a Single Statement
          3. 6.5.3. Reference Modification: Accessing Segments of a Field
        6. 6.6. PRODUCING PRINTED OUTPUT AND SCREEN DISPLAYS
          1. 6.6.1. Features of Printed Output and Screen Displays
            1. 6.6.1.1. Use of Edit Symbols
            2. 6.6.1.2. Spacing of Forms
            3. 6.6.1.3. Alignment of Information
            4. 6.6.1.4. Printing Headings, Total Lines, and Footings
            5. 6.6.1.5. The Printer Spacing Chart
          2. 6.6.2. The Editing Function
            1. 6.6.2.1. Printing or Displaying Decimal Points
            2. 6.6.2.2. Suppressing Leading Zeros
            3. 6.6.2.3. Printing or Displaying Dollar Signs and Commas
            4. 6.6.2.4. Printing or Displaying Asterisks (*) for Check Protection
            5. 6.6.2.5. Printing or Displaying Plus or Minus Signs
            6. 6.6.2.6. Printing or Displaying Debit and Credit Symbols for Accounting Applications
            7. 6.6.2.7. Printing or Displaying Spaces, Zeros, or Slashes as Separators within Fields
          3. 6.6.3. SELF-TEST
          4. 6.6.4. Editing Using Floating Strings
          5. 6.6.5. BLANK WHEN ZERO Option
          6. 6.6.6. Defining Print Records in WORKING-STORAGE
          7. 6.6.7. The WRITE . . . FROM Statement
          8. 6.6.8. The JUSTIFIED RIGHT Option
          9. 6.6.9. The ADVANCING Option for Spacing Printed Forms
            1. 6.6.9.1. Advancing the Paper a Fixed Number of Lines
            2. 6.6.9.2. Advancing the Paper to a New Page
              1. 6.6.9.2.1. The PAGE Option
            3. 6.6.9.3. End-of-Page Control—with the Use of a Programmed Line Counter
          10. 6.6.10. SELF-TEST
          11. 6.6.11. Printing Page Numbers
          12. 6.6.12. Printing or Displaying the Date of the Run
            1. 6.6.12.1. Accepting DATE Using Compilers That Are Not Y2K Compliant
              1. 6.6.12.1.1. The Y2K Problem
          13. 6.6.13. Printing or Displaying Quotation Marks
        7. 6.7. DISPLAYING OUTPUT INTERACTIVELY USING SCREEN INPUT AND OUTPUT
        8. 6.8. DISCUSSION OF AN INTERACTIVE SOLUTION TO PROGRAMMING ASSIGNMENT 4
        9. 6.9. EXAMPLE: CALCULATION OF TUITION
        10. 6.10. ADDITIONAL SCREEN SECTION ENTRIES
        11. 6.11. CHAPTER SUMMARY
        12. 6.12. KEY TERMS
        13. 6.13. CHAPTER SELF-TEST
        14. 6.14. PRACTICE PROGRAM
        15. 6.15. REVIEW QUESTIONS
        16. 6.16. INTERPRETING INSTRUCTION FORMATS
        17. 6.17. DEBUGGING EXERCISES
        18. 6.18. PROGRAMMING ASSIGNMENTS
      3. 7. Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
        1. 7.1. THE BASIC ARITHMETIC VERBS
          1. 7.1.1. ADD Statement
          2. 7.1.2. SELF-TEST
          3. 7.1.3. SUBTRACT Statement
          4. 7.1.4. SELF-TEST
          5. 7.1.5. MULTIPLY and DIVIDE Statements
            1. 7.1.5.1. Basic Instruction Format
            2. 7.1.5.2. Examples of Arithmetic Operations
            3. 7.1.5.3. Use of the REMAINDER Clause in the DIVIDE Operation
          6. 7.1.6. SELF-TEST
        2. 7.2. OPTIONS AVAILABLE WITH ARITHMETIC VERBS
          1. 7.2.1. ROUNDED Option
          2. 7.2.2. ON SIZE ERROR Option
          3. 7.2.3. NOT ON SIZE ERROR Clause
          4. 7.2.4. Determining the Size of Receiving Fields
          5. 7.2.5. SELF-TEST
        3. 7.3. THE COMPUTE STATEMENT
          1. 7.3.1. Basic Format
          2. 7.3.2. Order of Evaluation
          3. 7.3.3. Comparing COMPUTE to Arithmetic Verbs
        4. 7.4. USE OF SIGNED NUMBERS IN ARITHMETIC OPERATIONS
          1. 7.4.1. The Use of S in PIC Clauses for Fields That Can Be Negative
          2. 7.4.2. Rules for Performing Arithmetic with Signed Numbers
          3. 7.4.3. Entering Signed Numbers
        5. 7.5. INTRINSIC FUNCTIONS
          1. 7.5.1. Calendar Functions
          2. 7.5.2. Statistical and Numerical Analysis Functions
          3. 7.5.3. Trigonometric Functions
          4. 7.5.4. Financial Functions
          5. 7.5.5. Character and String Functions
        6. 7.6. CHAPTER SUMMARY
        7. 7.7. KEY TERMS
        8. 7.8. CHAPTER SELF-TEST
        9. 7.9. PRACTICE PROGRAM
        10. 7.10. REVIEW QUESTIONS
        11. 7.11. DEBUGGING EXERCISES
        12. 7.12. PROGRAMMING ASSIGNMENTS
      4. 8. Decision Making Using the IF and EVALUATE Statements
        1. 8.1. SELECTION USING A SIMPLE IF STATEMENT
          1. 8.1.1. A Review Of Logical Control Structures
          2. 8.1.2. Basic Conditional Statements
            1. 8.1.2.1. The Instruction Format for an IF Statement
            2. 8.1.2.2. Interpreting Instruction Formats
              1. 8.1.2.2.1. ELSE Is Optional
            3. 8.1.2.3. Example of an IF Statement Without an ELSE Clause
              1. 8.1.2.3.1. More Than One Operation Can Be Performed When a Condition Exists
            4. 8.1.2.4. Coding Guidelines
              1. 8.1.2.4.1. Indenting
              2. 8.1.2.4.2. Using Relational Operators in Place of Words
              3. 8.1.2.4.3. Do Not Mix Field Types in a Comparison
          3. 8.1.3. Planning Conditional Statements with Pseudocode
          4. 8.1.4. How Comparisons Are Performed
          5. 8.1.5. ASCII and EBCDIC Collating Sequences
          6. 8.1.6. Ending Conditional Sentences with a Period or an END-IF Scope Terminator
          7. 8.1.7. The CONTINUE Clause
          8. 8.1.8. SELF-TEST
        2. 8.2. SELECTION USING OTHER OPTIONS OF THE IF STATEMENT
          1. 8.2.1. Nested Conditional
          2. 8.2.2. Compound Conditional
            1. 8.2.2.1. OR in a Compound Conditional
            2. 8.2.2.2. AND in a Compound Conditional
            3. 8.2.2.3. Using AND and OR in the Same Statement
              1. 8.2.2.3.1. Introduction
              2. 8.2.2.3.2. Order of Evaluation of Compound Conditionals
              3. 8.2.2.3.3. Order of Evaluation: Possibility 1
              4. 8.2.2.3.4. Order of Evaluation: Possibility 2
              5. 8.2.2.3.5. Examples
          3. 8.2.3. Sign and Class Tests
            1. 8.2.3.1. Sign Test
            2. 8.2.3.2. Class Test
          4. 8.2.4. Negating Conditionals
            1. 8.2.4.1. Negating Simple Conditionals
            2. 8.2.4.2. Negating Compound Conditionals
        3. 8.3. USING IF STATEMENTS TO DETERMINE LEAP YEARS
        4. 8.4. CONDITION-NAMES
        5. 8.5. THE EVALUATE STATEMENT: USING THE CASE STRUCTURE AS AN ALTERNATIVE TO SELECTION
        6. 8.6. CHAPTER SUMMARY
        7. 8.7. KEY TERMS
        8. 8.8. CHAPTER SELF-TEST
        9. 8.9. PRACTICE PROGRAM
        10. 8.10. REVIEW QUESTIONS
        11. 8.11. DEBUGGING EXERCISES
        12. 8.12. PROGRAMMING ASSIGNMENTS
      5. 9. Iteration: Beyond the Basic PERFORM
        1. 9.1. THE SIMPLE PERFORM REVIEWED
          1. 9.1.1. The Basic Formats
          2. 9.1.2. Modularizing Programs Using PERFORM Statements
          3. 9.1.3. Nested PERFORM: A PERFORM within a PERFORM
          4. 9.1.4. Executing a Group of Paragraphs with a Simple PERFORM
          5. 9.1.5. The Use and Misuse of GO TO Statements
          6. 9.1.6. The EXIT Statement
        2. 9.2. ITERATION USING OTHER TYPES OF PERFORMS
          1. 9.2.1. PERFORM UNTIL ... (A Review)
          2. 9.2.2. Coding a Loop with a PERFORM
          3. 9.2.3. Perform ... Times
          4. 9.2.4. Examples of Loops
          5. 9.2.5. PERFORM VARYING
        3. 9.3. USING NESTED PERFORM VARYING STATEMENTS
        4. 9.4. THE PERFORM WITH TEST AFTER OPTION
        5. 9.5. CHAPTER SUMMARY
        6. 9.6. KEY TERMS
        7. 9.7. CHAPTER SELF-TEST
        8. 9.8. PRACTICE PROGRAM
        9. 9.9. REVIEW QUESTIONS
        10. 9.10. DEBUGGING EXERCISES
        11. 9.11. PROGRAMMING ASSIGNMENTS
    6. III. WRITING HIGH-LEVEL COBOL PROGRAMS
      1. 10. Control Break Processing
        1. 10.1. AN INTRODUCTION TO CONTROL BREAK PROCESSING
          1. 10.1.1. Types of Reports: A Systems Overview
            1. 10.1.1.1. Detail or Transaction Reports
            2. 10.1.1.2. Exception Reports
            3. 10.1.1.3. Summary Reports
              1. 10.1.1.3.1. Displayed Output: A Systems Overview
          2. 10.1.2. An Example of a Control Break Procedure
        2. 10.2. PROGRAM REQUIREMENTS FOR CONTROL BREAK PROCESSING
          1. 10.2.1. A Single-Level Control Break
            1. 10.2.1.1. 200-DETAIL-RTN
              1. 10.2.1.1.1. 300-CONTROL-BREAK
          2. 10.2.2. Refinements to Improve the Quality of a Control Break Report
            1. 10.2.2.1. Printing a Final Total
            2. 10.2.2.2. Starting a New Page After Each Control Break
            3. 10.2.2.3. Sequence-Checking or Sorting: To Ensure That Input Data Was Entered in the Correct Sequence
            4. 10.2.2.4. Executing the Control Break Module from the Main Module After an End-of-File Condition Has Been Met
          3. 10.2.3. Summary of a Single-Level Control Break Procedure
          4. 10.2.4. SELF-TEST
        3. 10.3. MULTIPLE-LEVEL CONTROL BREAKS
        4. 10.4. CHAPTER SUMMARY
        5. 10.5. KEY TERMS
        6. 10.6. CHAPTER SELF-TEST
        7. 10.7. PRACTICE PROGRAM 1
        8. 10.8. PRACTICE PROGRAM 2
        9. 10.9. REVIEW QUESTIONS
        10. 10.10. DEBUGGING EXERCISES
        11. 10.11. PROGRAMMING ASSIGNMENTS
      2. 11. Data Validation
        1. 11.1. AVOIDING LOGIC ERRORS BY VALIDATING INPUT
          1. 11.1.1. Why Input to a Business System Must Be Validated
          2. 11.1.2. Some Consequences Of Invalid Input
            1. 11.1.2.1. Inaccurate Output
            2. 11.1.2.2. Logic Errors Resulting from Erroneous Input
          3. 11.1.3. Data Validation Techniques
            1. 11.1.3.1. Testing Fields to Ensure a Correct Format
            2. 11.1.3.2. Checking for Missing Data
            3. 11.1.3.3. The INSPECT Statement: Tallying and Replacing Specific Characters With Other Characters to Minimize Errors
          4. 11.1.4. SELF-TEST
            1. 11.1.4.1. Testing for Reasonableness
            2. 11.1.4.2. Condition-Names: Checking Coded Fields for Valid Contents
            3. 11.1.4.3. Sequence Checking
          5. 11.1.5. Using the EVALUATE Verb for Data Validation
          6. 11.1.6. Other Methods for Validating Data
            1. 11.1.6.1. Use of Control Listings for Manual Validation of Input
            2. 11.1.6.2. Verification as a Means of Validating Input
        2. 11.2. WHAT TO DO IF INPUT ERRORS OCCUR
          1. 11.2.1. Print an Error Record Containing the Key Field, the Contents Of the Erroneous Field, and an Error Message
          2. 11.2.2. Stop the Run
          3. 11.2.3. Partially Process Or Bypass Erroneous Records
          4. 11.2.4. Stop the Run if the Number Of Errors Exceeds a Predetermined Limit
          5. 11.2.5. Use Switches
          6. 11.2.6. Print Totals
            1. 11.2.6.1. Print a Count of All Records and a Count of All Errors
            2. 11.2.6.2. Print a Batch Total
        3. 11.3. GLOBAL CONSIDERATIONS IN COBOL
        4. 11.4. WHEN DATA SHOULD BE VALIDATED
        5. 11.5. UNDERSTANDING PROGRAM INTERRUPTS
        6. 11.6. OTHER METHODS FOR IMPROVING PROGRAM PERFORMANCE
          1. 11.6.1. Verifying File-Names With ACCEPT and DISPLAY Statements When Using a PC Compiler for Interactive Processing
          2. 11.6.2. The READ ... INTO Statement in Place of Using READ and MOVE Statements
          3. 11.6.3. Clearing Fields Using the INITIALIZE Statement
          4. 11.6.4. Improving Program Efficiency with the USAGE Clause
            1. 11.6.4.1. Format
            2. 11.6.4.2. USAGE IS DISPLAY
            3. 11.6.4.3. USAGE IS PACKED-DECIMAL or COMPUTATIONAL-3 (COMP-3)—A Common Enhancement
            4. 11.6.4.4. USAGE IS COMPUTATIONAL (COMP)
        7. 11.7. CHAPTER SUMMARY
        8. 11.8. KEY TERMS
        9. 11.9. CHAPTER SELF-TEST
        10. 11.10. PRACTICE PROGRAM
        11. 11.11. REVIEW QUESTIONS
        12. 11.12. DEBUGGING EXERCISES
        13. 11.13. PROGRAMMING ASSIGNMENTS
      3. 12. Array Processing and Table Handling
        1. 12.1. AN INTRODUCTION TO SINGLE-LEVEL OCCURS CLAUSES
          1. 12.1.1. Why OCCURS Clauses Are Used
            1. 12.1.1.1. Using an OCCURS to Define a Series of Input Fields Each with the Same Format
              1. 12.1.1.1.1. Defining Fields with an OCCURS Clause
              2. 12.1.1.1.2. Defining a Subscript
              3. 12.1.1.1.3. Coding Rules for Subscripts
              4. 12.1.1.1.4. A Subscript May Be an Integer or an Identifier
          2. 12.1.2. SELF-TEST
            1. 12.1.2.1. Using an OCCURS in WORKING-STORAGE for Storing Totals
          3. 12.1.3. Rules for Use of the OCCURS Clause
            1. 12.1.3.1. Levels 02–49
            2. 12.1.3.2. Defining Elementary or Group Items with an OCCURS Clause
            3. 12.1.3.3. Accessing a WORKING-STORAGE Area Defined by an OCCURS Clause
              1. 12.1.3.3.1. ADD-RTN
        2. 12.2. PROCESSING DATA STORED IN AN ARRAY
          1. 12.2.1. Using OCCURS with VALUE and REDEFINES Clauses
          2. 12.2.2. Printing Data Stored in an Array
          3. 12.2.3. SELF-TEST
        3. 12.3. USING AN OCCURS CLAUSE FOR TABLE HANDLING
          1. 12.3.1. Defining a Table
          2. 12.3.2. Storing the Table in WORKING-STORAGE Using Data on a Disk
          3. 12.3.3. Storing the Table in WORKING-STORAGE Using the Keyboard
          4. 12.3.4. Looking Up Data in a Table: Finding a Match
        4. 12.4. USE OF THE SEARCH STATEMENT FOR TABLE AND ARRAY PROCESSING
          1. 12.4.1. Format of the SEARCH Statement
          2. 12.4.2. The INDEXED BY Clause and the SEARCH Statement
          3. 12.4.3. Modifying the Contents of an Index
            1. 12.4.3.1. The SET Statement
            2. 12.4.3.2. Initializing an Index Before Using the SEARCH
          4. 12.4.4. Searching a Table–Foreign Exchange Example
          5. 12.4.5. Using Two WHEN Clauses for an Early Exit from a SEARCH
          6. 12.4.6. Searching for Multiple Matches
          7. 12.4.7. Internal vs External Tables
        5. 12.5. LOOKING UP TABLE DATA FOR ACCUMULATING TOTALS
          1. 12.5.1. SELF-TEST
        6. 12.6. THE SEARCH ... VARYING OPTION FOR PROCESSING PARALLEL TABLES
        7. 12.7. THE SEARCH ALL STATEMENT
          1. 12.7.1. Definition of a Serial Search
          2. 12.7.2. The Binary Search as an Alternative to the Serial Search
          3. 12.7.3. Format of the SEARCH ALL Statement
          4. 12.7.4. ASCENDING or DESCENDING KEY with the SEARCH ALL Statement
        8. 12.8. MULTIPLE-LEVEL OCCURS CLAUSE
          1. 12.8.1. Defining a Double-Level or Two-Dimensional Array
          2. 12.8.2. Accessing a Double-Level or Two-Dimensional Array
            1. 12.8.2.1. Using PERFORM . . . VARYING . . . AFTER
          3. 12.8.3. Using a Double-Level or Two-Dimensional Array for Accumulating Totals
          4. 12.8.4. Performing a Look-Up Using a Double-Level OCCURS
        9. 12.9. CHAPTER SUMMARY
        10. 12.10. KEY TERMS
        11. 12.11. CHAPTER SELF-TEST
        12. 12.12. PRACTICE PROGRAM
        13. 12.13. REVIEW QUESTIONS
        14. 12.14. DEBUGGING EXERCISES
        15. 12.15. PROGRAMMING ASSIGNMENTS
    7. IV. FILE MAINTENANCE
      1. 13. Sequential File Processing
        1. 13.1. SYSTEMS OVERVIEW OF SEQUENTIAL FILE PROCESSING
          1. 13.1.1. Master Files
          2. 13.1.2. Typical Master File Procedures: A Systems Overview
            1. 13.1.2.1. Designing a Master File for Sequential Processing in Batch Mode
            2. 13.1.2.2. Creating a Master File for Sequential Processing in Batch Mode
            3. 13.1.2.3. Creating a Transaction File for Sequential Processing in Batch Mode
            4. 13.1.2.4. Updating a Master File for Sequential Processing in Batch Mode
            5. 13.1.2.5. Reporting from a Master File for Sequential Processing in Batch Mode
            6. 13.1.2.6. Creating Original Master and Transaction Files for New Systems
        2. 13.2. SEQUENTIAL FILE UPDATING—CREATING A NEW MASTER FILE USING A PREVIOUS MASTER FILE AND A TRANSACTION FILE
          1. 13.2.1. The Files Used
            1. 13.2.1.1. Input Master File
            2. 13.2.1.2. Input Transaction File
            3. 13.2.1.3. Output Master File
            4. 13.2.1.4. Control Listing or Audit Trail
          2. 13.2.2. The Ordering of Records for Sequential Updates
          3. 13.2.3. The Procedures Used for Sequential Updates
            1. 13.2.3.1. The Main Module
            2. 13.2.3.2. How Input Transaction and Master Records Are Processed
              1. 13.2.3.2.1. T-ACCT-NO IS EQUAL TO M-ACCT-NO
              2. 13.2.3.2.2. T-ACCT-NO IS GREATER THAN M-ACCT-NO
              3. 13.2.3.2.3. T-ACCT-NO IS LESS THAN M-ACCT-NO
            3. 13.2.3.3. Illustrating the Update Procedure with Examples
              1. 13.2.3.3.1. The Use of HIGH-VALUES for End-of-File Conditions
          4. 13.2.4. SELF-TEST
        3. 13.3. VALIDITY CHECKING IN UPDATE PROCEDURES
          1. 13.3.1. Checking for New Accounts
          2. 13.3.2. Checking for Delete Codes and Deleting Records from a Sequential Master File
          3. 13.3.3. Checking for Sequence Errors
        4. 13.4. UPDATE PROCEDURES WITH MULTIPLE TRANSACTION RECORDS FOR EACH MASTER RECORD
        5. 13.5. THE BALANCED LINE ALGORITHM FOR SEQUENTIAL FILE UPDATING
        6. 13.6. SEQUENTIAL FILE UPDATING—REWRITING RECORDS ON A DISK
          1. 13.6.1. The REWRITE Statement for a Disk File Opened as I-O
          2. 13.6.2. Using an Activity-Status Field for Designating Records to Be Deleted
          3. 13.6.3. The EXTEND Option for Adding Records to the End of a Sequential File
        7. 13.7. FILE MANAGEMENT TIPS
        8. 13.8. MATCHING FILES FOR CHECKING PURPOSES
        9. 13.9. INTERACTIVE UPDATING OF A SEQUENTIAL FILE
        10. 13.10. CHAPTER SUMMARY
        11. 13.11. KEY TERMS
        12. 13.12. CHAPTER SELF-TEST
        13. 13.13. PRACTICE PROGRAM
        14. 13.14. REVIEW QUESTIONS
        15. 13.15. DEBUGGING EXERCISES
        16. 13.16. PROGRAMMING ASSIGNMENTS
      2. 14. Sorting and Merging
        1. 14.1. THE SORT FEATURE: AN OVERVIEW
          1. 14.1.1. Format of the SORT Statement
          2. 14.1.2. ASCEDING or DESCENDING KEY
            1. 14.1.2.1. Collating Sequence
            2. 14.1.2.2. Sequencing Records with More Than One SORT Key
          3. 14.1.3. Coding a Simple SORT Procedure with the USING and GIVING Options
          4. 14.1.4. SELF-TEST
        2. 14.2. PROCESSING DATA BEFORE AND/OR AFTER SORTING
          1. 14.2.1. INPUT PROCEDURE
          2. 14.2.2. SELF-TEST
          3. 14.2.3. OUTPUT PROCEDURE
          4. 14.2.4. When to Use INPUT and/or OUTPUT PROCEDUREs
        3. 14.3. THE MERGE STATEMENT
        4. 14.4. CHAPTER SUMMARY
        5. 14.5. KEY TERMS
        6. 14.6. CHAPTER SELF-TEST
        7. 14.7. PRACTICE PROGRAM
        8. 14.8. REVIEW QUESTIONS
        9. 14.9. DEBUGGING EXERCISES
        10. 14.10. PROGRAMMING ASSIGNMENTS
      3. 15. Indexed and Relative File Processing
        1. 15.1. SYSTEMS CONSIDERATIONS FOR ORGANIZING DISK FILES
          1. 15.1.1. Sequential File Organization
          2. 15.1.2. Indexed File Organization
          3. 15.1.3. Relative File Organization
        2. 15.2. FEATURES OF MAGNETIC DISKS AND DISK DRIVES
        3. 15.3. PROCESSING INDEXED DISK FILES
          1. 15.3.1. Creating an Indexed File
            1. 15.3.1.1. The SELECT Statement
              1. 15.3.1.1.1. The ORGANIZATION Clause
              2. 15.3.1.1.2. The ACCESS Clause
              3. 15.3.1.1.3. The RECORD KEY Clause
            2. 15.3.1.2. The INVALID KEY Clause
          2. 15.3.2. Updating an Indexed File Randomly
            1. 15.3.2.1. The SELECT Statement
            2. 15.3.2.2. Opening an Indexed File as I-O
            3. 15.3.2.3. The READ Statement
            4. 15.3.2.4. REWRITE a Disk Record to Update It
            5. 15.3.2.5. Illustrating a Simple Update Procedure for an Indexed File
              1. 15.3.2.5.1. Reading from a Transaction File as Input
              2. 15.3.2.5.2. Accepting Transaction Data from a Keyboard Instead of a Disk File.
            6. 15.3.2.6. Additional Features of an Update Procedure
          3. 15.3.3. Updating an Indexed File with Multiple Transaction Records for Each Master Record
          4. 15.3.4. Accessing or Reading from an Indexed File for Reporting Purposes
          5. 15.3.5. SELF-TEST
        4. 15.4. ADDITIONAL OPTIONS FOR INDEXED FILE PROCESSING
          1. 15.4.1. Using ALTERNATE RECORD KEYS
          2. 15.4.2. The START Statement
          3. 15.4.3. Accessing an Indexed File Dynamically
            1. 15.4.3.1. The ACCESS IS DYNAMIC Clause
            2. 15.4.3.2. ACCESS IS DYNAMIC and the START Statement
            3. 15.4.3.3. The READ ... NEXT RECORD ... Instruction
            4. 15.4.3.4. Sequential Access of Records with the Use of ALTERNATE RECORD KEYs
          4. 15.4.4. SELF-TEST
          5. 15.4.5. A Review of INVALID KEY Clauses
          6. 15.4.6. ALTERNATE RECORD KEYS Reduce the Need for Multiple Copies of a File
          7. 15.4.7. The FILE STATUS Clause
          8. 15.4.8. Exception Handling with the USE Statement
          9. 15.4.9. SELF-TEST
        5. 15.5. USING AN INDEXED DISK FILE AS AN EXTERNAL TABLE
        6. 15.6. PROCESSING RELATIVE DISK FILES
          1. 15.6.1. What Is a Relative File?
          2. 15.6.2. Creating Relative Files
          3. 15.6.3. Sequential reading of relative files
          4. 15.6.4. Random reading of relative files
          5. 15.6.5. Random updating of relative files
          6. 15.6.6. SELF-TEST
        7. 15.7. CONVERTING A KEY FIELD TO A RELATIVE KEY
        8. 15.8. CHAPTER SUMMARY
        9. 15.9. KEY TERMS
        10. 15.10. CHAPTER SELF-TEST
        11. 15.11. PRACTICE PROGRAM
        12. 15.12. REVIEW QUESTIONS
        13. 15.13. DEBUGGING EXERCISES
        14. 15.14. PROGRAMMING ASSIGNMENTS
    8. V. ADVANCED TOPICS
      1. 16. Improving Program Productivity Using The COPY, CALL, and Other Statements
        1. 16.1. COPY STATEMENT
          1. 16.1.1. Introduction
          2. 16.1.2. Entries that Can Be Copied
          3. 16.1.3. An Example
          4. 16.1.4. The Full Format for the COPY Statement
          5. 16.1.5. SELF-TEST
        2. 16.2. CALL STATEMENT
          1. 16.2.1. Why Use a CALL Statement?
          2. 16.2.2. Format of the CALL Statement
            1. 16.2.2.1. Called Program Requirements
              1. 16.2.2.1.1. PROGRAM-ID
              2. 16.2.2.1.2. LINKAGE SECTION
              3. 16.2.2.1.3. PROCEDURE DIVISION USING
              4. 16.2.2.1.4. EXIT PROGRAM
            2. 16.2.2.2. Calling Program Requirements
          3. 16.2.3. Examples
        3. 16.3. TEXT MANIPULATION WITH THE STRING AND UNSTRING STATEMENTS
          1. 16.3.1. The STRING Statement
            1. 16.3.1.1. The Basic Format
            2. 16.3.1.2. OVERFLOW Option
            3. 16.3.1.3. POINTER Option
            4. 16.3.1.4. General Rules for Using the STRING
          2. 16.3.2. The UNSTRING Statement
            1. 16.3.2.1. The Basic Format
            2. 16.3.2.2. General Rules for Using the UNSTRING
        4. 16.4. CHAPTER SUMMARY
        5. 16.5. KEY TERMS
        6. 16.6. CHAPTER SELF-TEST
        7. 16.7. PRACTICE PROGRAM
        8. 16.8. REVIEW QUESTIONS
        9. 16.9. DEBUGGING EXERCISES
        10. 16.10. PROGRAMMING ASSIGNMENTS
      2. 17. The Report Writer Module
        1. 17.1. INTRODUCTION
        2. 17.2. THE BENEFITS OF THE REPORT WRITER MODULE
          1. 17.2.1. For Detail and Summary Printing
          2. 17.2.2. For Control Break Processing
          3. 17.2.3. For Printing Headings and Footings
        3. 17.3. THE REPORT SECTION IN THE DATA DIVISION
          1. 17.3.1. The RD Entry within the REPORT SECTION
            1. 17.3.1.1. CONTROL Clause
            2. 17.3.1.2. PAGE LIMIT Clause
          2. 17.3.2. SELF-TEST
          3. 17.3.3. Clauses Used at the Group Level within a Report Group Description
            1. 17.3.3.1. TYPE Clause—Required
            2. 17.3.3.2. LINE Clause
            3. 17.3.3.3. NEXT GROUP Clause
          4. 17.3.4. SELF-TEST
          5. 17.3.5. Clauses Used at the Elementary Level within a Report Group Description
            1. 17.3.5.1. The SOURCE Clause
            2. 17.3.5.2. The SUM Clause
            3. 17.3.5.3. The RESET Phrase
          6. 17.3.6. REVIEW
            1. 17.3.6.1. Page Heading
            2. 17.3.6.2. Detail Line
            3. 17.3.6.3. CONTROL FOOTING for Printing Control Totals
            4. 17.3.6.4. CONTROL FOOTING for Printing the Final Total
        4. 17.4. PROCEDURE DIVISION STATEMENTS
          1. 17.4.1. INITIATE Statement
          2. 17.4.2. GENERATE Statement
          3. 17.4.3. TERMINATE Statement
        5. 17.5. CHAPTER SUMMARY
        6. 17.6. KEY TERMS
        7. 17.7. CHAPTER SELF-TEST
        8. 17.8. PRACTICE PROGRAM
        9. 17.9. REVIEW QUESTIONS
        10. 17.10. DEBUGGING EXERCISES
        11. 17.11. PROGRAMMING ASSIGNMENTS
    9. VI. APPENDIXES
      1. A. COBOL Character Set and Reserved Words
        1. A.1. COBOL CHARACTERS
        2. A.2. COBOL RESERVED WORDS
        3. A.3. FUNCTION NAMES INCLUDED IN THE EXTENSIONS TO COBOL 85
        4. A.4. NEW COBOL 2008 RESERVED WORDS
      2. B. Differences Among the COBOL Standards
        1. B.1. CHANGES IN THE NEW COBOL STANDARD (2008)
      3. C. Glossary