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.
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.
Browse related COBOL troubleshooting tips for more help
Visit our COBOL user forum
Why some say COBOL is irrelevant