Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Brush up on COBOL basics

COBOL might be one of the oldest programming languages, but that doesn't mean developers know all there is to know. We have expert insights on COBOL basics.

COBOL isn't a new programming language, but it still presents challenges in a modern data center. And COBOL newbies and veterans can always benefit from brushing up on their skills. These answers will help even the most seasoned mainframe programmers.

Should I check FILE STATUS after READ/WRITE in program (having IF FILE STATUS = 00), or will the operating system handle it?
-- Robert Crawford, systems programmer

Always check FILE STATUS after each input/output (I/O) operation. If the error is bad enough, the OS will interrupt and abend your program. Otherwise, if your program receives control after the I/O, the program needs to know what happened to react properly.

Is compiling still necessary with application development tools that can clean up scripts before production?
-- Wayne Kernochan, analyst, Infostructure Associates

COBOL compilers handle a lot of optimization and perform checks that development tools either can't do, or don't do as well as a compiler. But compiling sometimes takes a long time. Some applications won't get a perceptible performance boost from the rigorous optimization, syntax checking and semantics review of a compiler, but for applications handling big data or online transactions, the additional step is worth it.

Are there options for COBOL akin to ARCH and TUNE?

Crawford: ARCH and TUNE used to be IBM's compiler options only for the C++ programming language in its Language Environment (LE) compiler. IBM has opened up the LE optimization to COBOL and PL/I, so you can use ARCH and TUNE on COBOL application code.

The ARCH level helps generate object code with performance-enhanced machine instructions. TUNE makes code work best with the processor's instruction pipeline and cache.

There's one critical application that is based on COBOL left in our IT organization. Most everything else has moved to Java. What can we (as COBOL programmers) do to make sure the app still works?
-- Judith M. Myerson, systems architect and engineer

You have a couple of options for converting old COBOL programs, but none are completely pain-free.

Depending on skills, timeframe and the underlying program code, you can manually rewrite the legacy code from COBOL to C/C++, and automatically convert it or rehost the legacy system on a new platform.

Is there a way to replace the first two characters in all fields from a file? I have a copy-dds from a file where the fields have TRxxxx (where 'xxxx' is different from field to field). I want to replace the 'TR' by 'SP'.
-- Tom Liotta, ITKnowledgeExchange contributor and systems programmer

There's no good way to replace only a portion -- or an existing 'prefix' -- of a name in a COPY DDS statement. To make the names the same, use the same COPY DDS statement for both files. If the record formats are structured differently, then you might want to make source member from one of the files and change the prefix characters with an editor, e.g. the Source Entry Utility (SEU). Use the modified COPY member instead of the COPY DDS member.

I haven't used an AS/400 in 18 years. I can start SEU but don't remember what to do next. How do I insert lines of code?
-- Todd Nashville and Ross Howatson, ITKnowledgeExchange contributors

You'll need to re-familiarize yourself with COBOL basics. Go to the line number and type 'IP?' to show all line prompt types. Click F1 then F2 to display the help screen description of each prompt type.

Tools such as IBM's Rational Developer for i have screen developer and report developer tools, which makes working in the code faster and easier.

Also, if you're using the AS/400 for the long term, try these techniques to code in a way that won't slow down the program's performance.

Next Steps

Browse related COBOL troubleshooting tips for more help

Visit our COBOL user forum

Why some say COBOL is irrelevant

This was last published in October 2014

Dig Deeper on IBM system z and mainframe systems



Find more PRO+ content and other member only offers, here.

Join the conversation


Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

I'd be curious as to how many shops out there are using COBOL. I have not worked with it since 1983-84. The same with the other language Fortran. What business type are most likely to use these languages.
Cobol is all over the banks. 70 - 80% of trans are back ended in CICS or IMS ... and most of that is Cobol. I don't see much Fortran but I'm more in the business side.
I saw a stat the other day that there are still more lines of Cobol code out there than all other languages combined. I am sure some of the reason is that it takes more lines of code to do something in Cobol.
Yes. Cobol is a much more lengthy coding language. IT allows for very descriptive field names, wich can be a plus. On the other side punctuation can be a killer. One missing period in the code can cause it not to function properly. They are easily missed when reviewing code for errors during the debug process.
The COBOL job market in major cities remains surprisingly strong.  
I'm a cobol programmer (aged 37) and have always programmed on a Mainframe. I find cobol a doddle to write - missing full stops? just don't use them except for end of sections!!! Given that banking makes most of this world turn, and the numbers involved are getting bigger, nothing beats a Mainframe for crunching those numbers!!! With the modernisation of the 'big irons' from IBM these days, there's very little (if anything) a mainframe can't do... except make me a cuppa
COBOL might not be flashy, but mainframes and COBOL programming still make the F 500 world go 'round. Here's an interesting WSJ blog on COBOL's myths and reality: