COBOL? Did Anyone Say COBOL?

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

From time to time, I hear from readers who wish to see COBOL included in the magazine. And why not? COBOL is a great programming language, second only to RPG in the AS/400 arena. Unfortunately, the number of subscribers who clamor for COBOL coverage is too small to warrant publishing an article every month, and that’s why you don’t see more COBOL articles in the pages of MC.

This month, we decided to do something a little different—a sort of compromise. We still cannot afford to use many pages of the magazine to cover COBOL, but we can afford this one page. And in it, I’ll describe two articles I’ve written that you can read at your leisure on our Web site. So, without much further ado, let’s see what those articles are about.

COBOL Subfile Primer

The first article, “COBOL Subfile Primer,” (available at http://www.midrangecomputing.com/mc/98/11) shows you how to code interactive programs in COBOL. I’ve put a special emphasis on subfiles. To read this article, you’ll need some basic understanding of how subfiles work in RPG. Throughout, I draw parallels between RPG and COBOL to make understanding easier.

You will need this understanding if your shop is going bilingual. One of the chief ideas behind ILE is to enable you to choose the right language for the task at hand—and that’s great since each language has unique strengths. Furthermore, considering the large number of mainframe shops that downsize to AS/400s, you can count on more shops using COBOL as time goes on. Next time you update your résumé, be sure to include COBOL among your skills.

The approach I have taken in this article is to present a project, explain how to code the program, and explain why it’s best done one way rather than another. The project I present is the creation of an interactive program to maintain a State Code database. The display file contains a message subfile as well as a regular list-with-selection subfile,

function keys, numbered options like WRKxxx panels have, and so on. The COBOL program needs to read the file sequentially by key and randomly, also by key. I have segregated into separate COPY members many chunks of code that you would want to use again and again, and I’ve explained how to code a COPY statement in COBOL.

Subfiles are a very important part of interactive programming on the AS/400. If your shop is going to start using COBOL or if you are an RPG programmer curious to learn the language, you owe it to yourself to read this article.

Using the Proper Case in COBOL Code

My second COBOL utility (also available at http://www.midrange computing.com/mc/98/11) is designed to help standardize the capitalization of COBOL code. I firmly believe that writing code using a sound style is an important step toward making your programs easier to decipher and maintain.

You can do many things to achieve code clarity: Use long, meaningful identifiers; avoid nesting code blocks too many levels deep; avoid the GO TO statement if at all possible; and place your program’s paragraphs in alphabetical sequence.

All these things are fine, but to do them you have to examine the code manually; it’s rather difficult to write a program that would fix the code automatically, should any of these rules be violated. There is one rule, however, that can be enforced rather easily from a program: Use the right capitalization.

COBOL/400 accepts lowercase as well as uppercase, so it’s a simple matter to get carried away and code an END-PERFORM in one place, an End-Perform in another, and an end-perform in a third place. Many other bizarre combinations of upper- and lowercase are possible, and the compiler will accept all of them.

The solution is not in using uppercase or lowercase all the time, but in mixing them somehow. My personal preference is to use uppercase letters for all reserved words of the program, and lowercase letters for everything else. I feel that the use of capital letters for the reserved words makes them stand out so I can quickly find a particular statement I am looking for.

This Web article presents a utility that changes the case of COBOL code according to my preferences. Try it out, and see for yourself. If you disagree with my capitalization scheme, by all means change the utility to suit your tastes—but adhere to your standard from then on. (And speaking of capitalization, I’ve always felt that the name of the language ought to be in all caps; after all, it’s an acronym just like RPG and IBM. And who would write Rpg or Ibm?)

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: