COBOL Programmer's Notebook
Authors: Jim Keogh
Venue:  (1998)

From the Book:PREFACE: Preface Many readers associate COBOL (Common Business Oriented Language) with older applications that have been running successfully for decades on mainframe computers and with applications containing the Year 2000 Problem. COBOL is at the center of the Year 2000 Problem because many applications written in COBOL fail to use the century digits. Instead, they use the year digit such as 99 rather than 1999. This works well until the year 2000 when the year becomes 00. Does 00 represent the year 2000 or 1900? If the COBOL program subtracts dates, will 00-99 result in a -99 or will the program stop running altogether? How long will it take a programmer to locate and fix the problem if this occurs? Remember, business and government operations might stop until the problem is fixed. Will it take an hour, a day? Or will this occur in several programs requiring a team of programmers a week or more to address the problem? The answer is no one really knows because the computer industry has never experienced such a problem before. Every line of code in every COBOL program must be reviewed, and fixed if necessary. This book is designed to bring novice COBOL programmers up to speed quickly using COBOL and fixing the Year 2000 Problem. The clock is ticking. There's less than 1000 days remaining. The Picture Book Approach COBOL, as any computer language, is complex and has many rules that must be obeyed. Learning those rules can be time-consuming, especially for readers who already know how to program in a language other than COBOL. Those readers want to jump into the language and begin writing simplecodealmost immediately. Many programmers who learn COBOL as their second language have their own philosophy about learning the language. "Show me sample code and I'll figure out the rest," is a statement that summarizes their approach. And that's what I do in this book. The picture book concept places the focus of the book on a picture of the code. Around this picture are callouts that describe each keyword and statement. The rules are presented in tables that are positioned near the picture. Furthermore, there is a picture for each variation of the topic that is discussed in the chapter. A reader who wants to jump into COBOL can study the picture, then copy the code into a compiler and make the executable program without having to sift through pages of text. The rules can be referenced later, when the reader needs to expand this use of the routine. This approach is not intended to circumvent a thorough presentation of the COBOL language. In fact, this book presents C++ in its completion. Instead, the picture-book approach presents material in the way programmers want to learn a new computer language. Each example is a complete program that is unlike many computer books that show snippets of code, then expect you to know how to assemble all the other necessary pieces into a program that will compile. Navigating This Book I organized this book into traditional chapters. Each chapter covers a topic of COBOL in a logical progression. So, if you are not familiar with the basics of COBOL, then begin with the first chapter and continue through each chapter in progression. At the end of the last chapter you will have a good foundation in COBOL and how to begin solving the year 2000 problem. However, these chapters can be used also for quick reference. Jump to the chapter that discusses the topic that you want to review. The topic within the chapter is presented in its entirety with a focus on examples of code. Each chapter is further divided into two page spreads. That is, careful attention is given to the relationship between the left and right pages. The left page contains text that describes the topic that is illustrated on the right page. The right page focuses on COBOL code that contains callouts describing each facet of the code example. The most efficient way to use a two-page spread is to first study the example on the right page. If you understand the function of each statement in the example, then you can continue and write your own program. However, if a statement or keyword is confusing, then read the callout that describes the item. Still confused? Read the text on the left page. Careful attention is given to clarity of the code example, the right page. You will notice that the syntax of the COBOL code is shown in color. Parts of the statements that are not colored are pieces that the programmer creates. For example, the statement ACCEPT LNAME. reads data from the keyboard and stores it in the variable LNAME.Notice ACCEPT is bold as is the period after the LNAME. They are part of the syntactic of COBOL. The word LNAME, however, is a name of a variable that can be any name that complies with the rule of COBOL.