Cover image for COBOL : from micro to mainframe : preparing for the new millenium
COBOL : from micro to mainframe : preparing for the new millenium
Grauer, Robert T., 1945-
Personal Author:
Third edition.
Publication Information:
Upper Saddle River, N.J. : Prentice Hall, [1998]

Physical Description:
xiii, 896 pages : illustrations ; 28 cm
General Note:
Includes index.

Micro Focus coverage included.
Format :


Call Number
Material Type
Home Location
Central Library QA76.73.C25 G734 1998 Book and Software Set Non-Fiction Area-Oversize

On Order



A complete introducion to the COBOL package, including the Microfocus Personal COBOL for Windows compiler. This machine independent introduction covers all of the basic COBOL elements and special features.

Author Notes

DR. ROBERT T. GRAUER is an Associate Professor in the Department of Computer Information Systems at the University of Miami, where he has been honored with the Outstanding Teacher Award in the School of Business. A prolific author known for his unparalleled pedagogy, reader-friendly writing style, and Exploring Windows series, Dr. Grauer has written 30 books on programming and information systems, with more than million books in print. Dr. Grauer can be reached at

CAROL VAZQUEZ VILLAR, an instructor in the Department of Computer Information Systems at University of Miami for eight years, currently works for Andersen Consulting. She has developed and trained high performance teams on team building and communications and is currently planning and developing leadership training seminars.

DR. ARTHUR R. BUSS is Associate Professor of Computer Studies at William Jewell College, where he teaches Information Technology courses. Prior to coming to Jewell, he worked at Kmart Corporation and McDonnell Douglas as a programmer, systems analyst, and project leader. He is currently conducting studies in the Year 2000 problem and in Object-Oriented COBOL.



Preface COBOL: From Micro to Mainframe is a truly comprehensive work, providing in a single source all subjects normally covered in the one-year COBOL sequence. The scope is extensive, ranging from an introduction to COBOL, to maintaining sequential files and nonsequential files. The text also shows the new directions for COBOL in a chapter about Object-Oriented COBOL and an appendix devoted to the proposed changes in the COBOL 2000 standard. All programs in the book can be run on personal computers or with minor modifications on mainframes or other platforms. The beauty of COBOL is that it can operate on any platform. This text provides instruction in ANS XOPEN standard COBOL. The one exception is the use of Micro Focus Object-Oriented COBOL in Chapter 20, since the final ANS standard has not yet been adopted. Improvements in the Third Edition The third edition responds to the requests of many students and instructors to provide access to Windows-based tools while maintaining the proven approach to teaching COBOL. Features of this edition include the following: The text has been modified to show the development of programs in a Windows environment. While the essential characteristics of COBOL remain unchanged, the development tools have not. This edition provides examples using one of the most popular Windows development tools available: Micro Focus (r) Personal COBOL(tm) for Windows(tm). Chapter 19 has been added to explain the Year 2000 problem. This chapter discusses the sources of the problem, shows why it is a problem, and discusses several techniques to correct the problem. At the end of the chapter, we provide a list of World Wide Web sites where further information may be obtained. Another new chapter (Chapter 20) demonstrates the concepts of Object-Oriented COBOL. This new approach to COBOL promises to be a way for companies to maintain the value of their legacy COBOL programs while still being able to use the benefits of object-oriented programming. Appendix A provides extensive coverage of the Micro Focus Personal COBOL for Windows. In addition to explaining every menu item and button, this appendix also includes a brief tutorial allowing the student to experience process of creating a program. Appendix B provides a guide to installing Personal COBOL for Windows and several techniques to make using the product easier. Coverage of COBOL 2000 and intrinsic functions has been added in Appendix E. The 1989 extensions to COBOL 85 allow the use of predefined functions that had been missing in COBOL. This appendix also discusses the changes anticipated in COBOL 2000. In Appendix G, there are 32 new projects for student programming assignments. Many of these projects build on previous tasks allowing the student to experience the development of systems and the performance of maintenance. Various chapters have been changed to incorporate the changes in debugging and editing techniques used with a Windows programming environment as opposed to using a DOS compiler and debugger. Benefits and Features All of the features that have made the second edition successful have been retained and carried over into the third edition. These include: Immediate entry into COBOL programming, beginning in Chapter 1. Programming is learned by doing, and the book has students writing a complete program from the very beginning. Chapter 2 continues the discussion by having them execute the program of Chapter 1 in a thorough introduction to the programming process. Over 30 illustrative COBOL programs reinforce the discussion in the text and serve as both pedagogical aids and subsequent reference material. Every program is presented in a uniform and detailed format, including program narrative, record layouts, report layouts, test data, and processing specifications. A thorough discussion structured methodology, hierarchy charts, pseudocode, and top-down testing is presented in Chapter 3 and followed throughout. Students learn the proper way to develop programs early on and follow the procedure throughout the text. Every COBOL program in the text as well as data files for the student projects are available for download from a special World Wide Web site: The availability of the sample listings enables students to reproduce and/or modify any of the programs without the tedium of data entry and further enhances the learning experience. An abundance of short-answer (true-false and fill-in) questions, COBOL problems, and programming projects for every chapter, with answers to the odd-numbered questions provided in Appendix F. Programming tips, dispersed throughout the text, that go beyond the syntactical rules of COBOL, and suggest stylistic considerations to make programs easier to read and maintain. Extensive use of graphic aids, featuring a two-color presentation, with figures to further clarify the presentation. Where Micro Focus Personal COBOL is discussed, actual pictures of the screens assist the student in understanding the user interface. System concept presentation at the beginning of most chapters, as COBOL instruction has come to require additional material beyond the language itself. There are detailed discussions of control breaks, data validation, techniques for table lookups and initialization, storing, the balance line algorithm for file maintenance and the organization of indexed files. While focusing on the proven techniques of structured programming and the established syntax of COBOL 85, the text also introduces the concepts of object-orientation and previews the significant changes in COBOL 2000. Software and Supplements The following software and supplements are available from Prentice Hall: SOFTWARE - Micro Focus Personal COBOL for Windows 3.1 with object-orientation and Personal Dialog System. Compatible with Windows95 and WindowsNT, Personal COBOL provides all the tools to help you learn and use COBOL. The software includes an integrated editor, compiler and animator for creating, debugging and executing COBOL programs. Prentice Hall offers an affordable package of COBOL: From Micro to Mainframe, Third Edition with the Micro Focus Personal COBOL Compiler. Please order ISBN 0-13-975178-5. WEB SITE - Download every COBOL program in the text as well as data files for the nearly on hundred student projects from the COBOL: From Micro to Mainframe web site at: Instructor's Resource Manual (ISBN# 0-13-081513-6) Prentice Hall Custom Test. Based on the powerful testing technology developed by Engineering Software Associates, Inc. (EAS), Prentice Hall Custom Test allows the educator to create and tailor the exam to their own needs. Please order ISBN# 0-13-081515-2 Acknowledgments We are especially grateful to our editors at Prentice Hall, Laura Steele, Alan Apt, and Marcia Horton, without whom this project would not have been possible. We also want to thank the many other individuals who helped produce the third edition. Irwin Zucker, who supervised the production, Kate Kaibni, editorial assistant, who worked hard to provide us with timely chapter reviews, and Joel Berman, our marketing manager at Prentice Hall, who developed the innovative campaign to make this book a success. We also want to acknowledge our reviewers, who through their comments and constructive criticism, made this a far better book: Robert V. Binder, Robert Binder Systems Consulting, Inc. Dinon Boyer, University of Akron Georgia Brown, Northern Illinois University Jan De Lassen, Brigham Young University Ida M. Flynn, University of Pittsburgh Frank T. Gergelyi, NJIT Ken Goldsmith, University of Miami Tom Gorecki, St. Charles Community College Carol C. Grimm, Palm Beach Community College Monica Holmes, Central Michigan University Ann W. Houck, Pima Community College David Lee James W. Payne, Kellogg Community College Nicholas Ross, University of Illinois at Chicago Wendell I. Pope, Utah State University Daniel H. Rindfleisch, Computer Specialist with Federal Government Daniel R. Rota, Robert Morris College Richard H. Saracusa, Northeastern University Ron Teemley, DeVry Institute of Technology Donat Valcourt, Northeastern University Ron Williams, McLennon Community College Jackie Zucker, University of Miami A final word of thanks to you, our readers, for choosing this book. Please feel free to contact us with any comments or suggestions via email. Robert Grauer Carol Vazquez Villar Arthur R. Buss Excerpted from COBOL: From Micro to Mainframe by Robert T. Grauer, Arthur R. Buss, Carol Vasquez Villar All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.

Table of Contents

1 Introduction
2 From Coding Form to Computer
From Coding Form to Computer
The COBOL Coding Form
Use of an Editor
The Compile, Link, and Execute Sequence
Learning by Doing
Errors in Entering the Program
Errors in Operating System Commands
Errors in Compilation
Errors in Execution
Errors in Data Input
Evolution of COBOL
There's Always a Reason
3 A Methodology for Program Development
The Tuition Billing Problem
Structured Design
Evaluating the Hierarchy Chart
Span of Control
Structured Programming
4 The Identification, Environment, and Data Divisions
COBOL Notation
Identification Division
Environment Division
Configuration Section
Input-Output Section
Data Division
File Section
Working-Storage Section
The Tuition Billing Program
Programming Specifications
COBOL Entries
Limitations of COBOL-74
5 The Procedure Division
Placement of the READ Statement
Stop Run
Restrictions on the Move Statement
Alphanumeric Field to Alphanumeric Field
Numeric Field to Numeric Field
Group Moves
The ELSE Clause
Arithmetic Statements
The ROUNDED Clause
Programming Tip: Use the COMPUTE Statement
Assumed Decimal Point
The Tuition Billing Program
Test Data
Hierarchy Chart
COBOL Program Skeleton
Limitations of COBOL-74
6 Debugging
Errors in Compilation
Common Compilation Errors
Errors in Execution
File Status Codes
Another Run Time Error
Logic Errors
Tips for Debugging
DISPLAY Statement
The Structured Walkthrough
7 Editing and Coding Standards
The Decimal Point
Zero Suppression
Dollar Signs
Asterisks for Check Protection
Insertion Characters
Signed Numbers
CR and DB
Plus and Minus Signs
Blank When Zero Clause
The Tuition Billing Program Revisited
Coding Standards
Data Division
Programming Tip: Avoid Literals
Procedure Division
Programming Tip: Use Scope Terminators
Both Divisions
A Well-Written Program
8 Data Validation
System Concepts: Data Validation
The IF Statement
Relational Condition
Class Test
Sign Test
Condition-Name Test (88-Level Entries)
Compound Test
Hierarchy of Operations
Implied Conditions
Nested Ifs
Next Sentence
Accept Statement
Calculations Involving Dates
The Stand-Alone Edit Program
Programming Specifications
Error Messages
Hierarchy Chart
The Completed Program
Limitations of COBOL-74
9 More About the Procedure Division
Test Before/Test After
In-line Perform
Performing Sections
Perform Thru
Programming Tip: Perform Paragraphs, Not Sections
False-Condition Branch
Read Into
Write From
String Processing
Reference Modification
Duplicate Data Names
Move Corresponding
The Car Billing Program
Programming Specifications
Program Design
The Completed Program
Limitations of COBOL-74
10 Screen I-O
Programming Tip: Micro Focus Level 78-The Use of COBOL Constants
The Tuition Billing Program Revisited
Programming Specifications
Hierarchy Chart
The Completed Program
Programming Tip: The Hidden Power of the Alt key
Car Validation and Billing Program
Programming Specifications
The Screen Section
Hierarchy Chart
The Completed Program
Limitations of COBOL-74
11 Introduction to Tables
Introduction to Tables
Processing a Table
Perform Varying
A Second Example
Problems with the OCCURS Clause
Rules for Subscripts
Relative Subscripting
USAGE Clause
Occurs Depending On
The Student Transcript Program
Programming Specifications
Program Design
The Completed Program
Indexes versus Subscripts
The SET Statement
Limitations of COBOL-74 322
12 Table Lookups
System Concepts
Types of Codes
Characteristics of Codes
Sequential Table Lookup
Binary Table Lookup
Positional Organization and Direct Lookups
Initializing a Table
Hard Coding
Input-Loaded Tables
Table Lookups
Perform Varying Statement
SEARCH Statement
Programming Tip-Restrict Subscripts and Switches to a Single Use
SEARCH ALL Statement
Direct Lookup
Range-Step Tables
A Complete Example
Programming Specifications
Program Design
The Completed Program
Limitations of COBOL-74
13 Multilevel Tables
System Concepts
COBOL Implementation
One-Level Tables
Perform Varying
Two-Level Tables
Errors in Compilation
Perform Varying
A Sample Program
Programming Specifications
Program Design
The Completed Program
Three-Level Tables
Perform Varying
A Sample Program
Programming Specifications
The Completed Program
Table Lookups
A Calorie Counter's Delight
Programming Specifications
Range-Step Tables
The Completed Program
Limitations of COBOL-74
14 Sorting
System Concepts
Collating Sequence
Embedded Sign
COBOL Implementation
SORT Statement
SD (Sort Description)
Programming Specifications
Input Procedure/Output Procedure Option
Comparing Options
MERGE Statement
Limitations of COBOL-74
15 Control Breaks
System Concepts
Running versus Rolling Totals
One-Level Control Breaks
Programming Specifications
Hierarchy Chart
The Completed Program
Two-Level Control Breaks
Hierarchy Chart
The Completed Program
Three-Level Control Breaks
Hierarchy Chart
The Completed Program
Programming Tip: How to Write a Control Break Program
Limitations of COBOL-74
16 Subprograms
Called and Calling Programs
COPY Statement
Calling By Content And By Reference
Programming Tip: Use COPY to Pass Parameters
A System for Physical Fitness
Programming Specifications
Hierarchy Chart
The Completed Programs
Main Program (FITNESS)
Input Program (INPUTSUB)
Weight-Range Program (WGTSUB)
Training Program (TRAINSUB)
Display Program (DSPLYSUB)
Time Program (TIMESUB)
The Linkage Editor
Problems with the Linkage Editor
Limitations of COBOL-74
17 Sequential File Maintenance
System Concepts
Sequential versus Nonsequential Processing
Periodic Maintenance
Data Validation
Programming Specifications
Designing the Program
The Completed Program
Sequential File Maintenance
Programming Specifications
The Balance Line Algorithm
Designing the Hierarchy Chart
Top-Down Testing
The Stubs Program
The Completed Program
18 Indexed Files
System Concepts
COBOL Implementation
Creating an Indexed File
Programming Specifications
The Completed Program
Additional COBOL Elements
Maintaining an Indexed File
Programming Specifications
Hierarchy Chart
The Completed Program
Alternate Record Key
Programming Specifications
Concatenated Key
The START Statement
Limitations of COBOL-74
19 The Year 2000 Problem
The Year 2000 Problem
Date Arithmetic
COBOL Intrinsic Calendar Functions
Leap-Year Problem
Retirement Program Revisited
20 Object-Oriented COBOL Programming
The Next Generation of COBOL
The Development of Structured Programming
The Object-Oriented versus Structured Paradigm
Student-Look-UP Program
The Registrar Class
Classes and Inheritance
ProcessRequests Method
The StudentDM Class
The StudentDM Instance Definition
The Student Class
The Person Class
The Student UI Class
The Student PRT Class
Appendix A Micro Focus Personal COBOL for Windows: UsersGuide and Tutorial
Appendix B Getting Started
Appendix C Reserved Words
Appendix D COBOL-85 Reference Summary
Appendix E COBOL 1997, 1998, 1999, 2000, or ...?
Appendix F Answers to Odd-Numbered Exercises
Appendix G Projects

Google Preview