COBOL programming tools from NORCOM
What RW2 Can Do for You...
Why Report Writer?
Report Writer takes the drudgery out of producing reports and other printed output. You concentrate on getting the job done instead of counting bytes, adjusting FILLER, counting lines, and doing page ejects.
By eliminating most of the PROCEDURE DIVISION code necessary to produce the printed page, Report Writer eliminates much of the opportunity for programming bugs. Why not concentrate your efforts on your report content instead of the format? RW2 handles most report housekeeping such as printing titles, counting and printing page numbers, handling breaks and totals, automatically.
The layout of your report is specified in a REPORT SECTION in your DATA DIVISION. To print your report, all you have to do is load the data in your program, and then GENERATE the report detail (which may consist of anything from a single line, to the entire report!).
Report Writer saves you TIME, not only for initial development, but also for maintenance. Report Writer makes it easy to develop sophisticated reports, in half of the time, with a quarter of the procedural code. If you have to reformat your report, it's usually possible to do it by modifying the REPORT SECTION, without even touching your PROCEDURE DIVISION code!
Report Writer for COBOL
The Report Writer Feature is one of the little-known features of COBOL that will save you large amounts of effort and money. Report Writer first appeared in 1961, and was adopted in the 1968 ANSI standard.
It is often overlooked, however, due to its spotty availability and marginal implementations. It's one of those things that, after you've used it, you can't imagine how you ever got along without it.
Report Writer saves time in development of report programs and much more time in the maintenance of them. Cosmetic changes to reports, which can be so painful with WRITE AFTER POSITIONING logic, are easily accommodated using Report Writer.
RW2 is a precompiler; it processes your program before the COBOL compiler gets a look at it. It then generates code to implement the Report Writer Feature and passes this intermediate code to the compiler. Most compilers will hide this intermediate code from you; you only need to maintain the original Report Writer source statements.
RW2 provides compatibility with COBOL used on large mainframe computers. Programs can be downloaded to the PC, recompiled, and will execute yielding the same results as the mainframe. Additionally, since RW2 provides much better Report Writer diagnostics than IBM's VS COBOL, you will find software development and debugging easier on the PC.
Note that the IBM VS COBOL manual may be used directly with RW2, the compatibility is that close! However you won't want to do this as RW2 comes with a very complete manual including many more examples and helpful hints. Besides, you wouldn't know about all of the RW2 enhancements!
RW2 represents a superset of IBM's VS COBOL Report Writer. It does everything VS COBOL does and much more. (The only danger involved here is that you may become hooked on some of RW2s advanced features which VS COBOL doesn't provide. Relax; the IBM mainframe version of RW2 is available directly from IBM!)
Several new features in RW2 go far toward reducing programmer drudgery and make the task of producing superb output easy. Tasks you couldn't take the time to do before, now come naturally.
Let's start with the low-level enhancements, the simple things that mean so much.
If you're a Report Writer user you've seen code like this:
This code just prints a line of the first 24 letters of the alphabet. We will use this overly simple example to point out some of the enhancements or RW2.
First note that the programmer had to figure out where each group started, painstakingly counting on fingers or forms ruler. With RW2 we only have to "anchor" the first item on the line, the rest we can position as follows:
RW2 provides several additional shortcuts, such as the word COL for COLUMN, and the elimination of the PIC clauses altogether for alphanumeric literals (after all, counting bytes is a job for computers). Even the keyword VALUE is optional! Now a line might look like this:
RW2 also supports a "Multi-Operand" feature. Using this, all those value clauses could just as well be specified in one statement. And since PLUS ONE is the default column position, we only need anchor the first VALUE:
You can even use an OCCURS clause in a report description to print multiple column headings for example. Simple and obvious... but don't try this with IBM VS COBOL, or any other basic Report Writer implementation:
Reduced Procedure Division Code
Not only can you reduce the drudgery of coding the REPORT SECTION, but RW2 also allows for great savings in the PROCEDURE DIVISION by moving most of the coding necessary to produce a report into the REPORT SECTION where it belongs.
An overly simplified example is this: You want to print address labels and your data file contains three lines for the street address, some of which are blank in many records. Normally this leads to blank lines in the labels between the name and the city, unless you write elaborate procedural code to "compact" the labels before printing. With RW2 you just do this:
You can construct elaborate data-driven report layouts using workhorse "PRESENT/ABSENT WHEN" clauses, virtually eliminating the need for much otherwise-needed procedural code.
You can also eliminate virtually all the USE BEFORE REPORTING declaratives that you need for mainframe report writers, because the SUM and SOURCE clauses can now contain arithmetic expressions. For example, you can compute an average "on the fly" in a CONTROL FOOTING:
Powerful Formatting Features
You have probably seen the lengths one must go to in order to have names print out neatly. Typically COBOL files will have fixed fields for Last Name, First Name, and Middle Initial, usually in that order for sorting, etc.
However, it's much nicer if you can print the names without superfluous spaces, which requires a little more effort that RW2 can do for you.
In the old days, names were often printed like this because programmers didn't take the time to format them nicely (it was too much work):
JIM B. SMITH
RW2 supports the SQUEEZE symbol in the PICTURE clause to eliminate this. The SQUEEZE symbol "<" indicates that trailing blanks are to be squeezed out of the data before printing, so the next available printing position will be immediately after the length of the data rather than the length of the field.
With RW2 you would code:
This will yield, depending on data, either:
You can also squeeze suppressed leading zeros out of dollar amounts while retaining the correct insertion characters by coding a PIC clause as <999,999,99>9.99.
RW2 also supports alignment options for the COLUMN clause. The alignment options allow you to center or right-justify the data at a specific column. By combining alignment and squeeze options you can center or right justify text even if you don't know the text length until run time.
For instance assume you want to center a variable length company name at the top of a report:
In the above example, the squeeze symbol gets rid of any trailing spaces so that the CENTER clause will calculate the centering based on the length of the company name rather than the length of the field containing company name.
Full Style & Font Control
It used to be that printed reports from COBOL programs always looked like something that came out of a computer!
Don't get us wrong, this isn't necessarily bad. But at times it would be nice to take advantage of the power of PC printers by using some of the special character fonts (styles) built into most printers.
Using RW2, the control and selection of various styles becomes part of the syntax. If you want a word in a line printed in bold, just code the following:
The key clause here is the "STYLE IS" clause. All text to which this clause applies will be printed in bold. The rest of the text would revert to the "implicit" style for the report.
The styles are defined in an external Printer Definition File, so your program is now printer-independent!
You can apply the style clause at the elementary item or the group level. The styles may also be "conditional" by using the "WHEN" clause. Example:
You can even combine styles (as long as they are not mutually exclusive). For instance, you may want to underline parts of italic text. STYLE IS ITALIC UNDERLINED will accomplish this. The style names can be any non COBOL reserved words of your choice. You can define your own set of styles to accommodate your specific needs.
With more users sharing printers on local area networks these days, you can never rely on the printer being in any given state when you start a report. With laser printers you are as likely to get landscape oriented 48 point helvetica bold on your report as the desired 8 point line printer in portrait orientation.
Even if you don't need the full capabilities of the style clause you can use the "IMPLICIT STYLE FOR REPORT" feature of RW2. The implicit style is transmitted to the printer first, before any other print, thereby setting up the printer in the proper mode.
Transportability of Software
You have probably noticed that when it comes to standards for PC printers, you are strictly on your own. Even if you do manage to write a program that used the double width or enhanced style of print, your first attempt to transport that program to another brand of printer will be a headache.
This has been the traditional reason COBOL programmers avoid programming the escape sequences necessary to use the full style capabilities of printers.
With RW2, you can make a report program for any specific brand of printer by a simple recompile.
What's more, you can make a single version of a report program which will work for any PC printer; even if you don't know the type of printer until run time.
This is done by creating a Printer Description File (PDF) for your printer(s). This file can be created with any text editor, by referring to the manual that came with the printer. Several PDF files come with RW2, and they're a snap to create if you need to define your own.
Is Report Writer New to You?
This program prints labels on standard 3-UP labels (continuous form labels with three gummed labels across). Note that we read and generate one address record at a time, and RW2 takes care of the three-across arrangement. We also makes use of STYLES to underline the names.
Sample Printer Definition File
This is all RW2 needs to run the sample 3-UP label program on any printer. You would convert this file for your printer and make it available at run time under the name SIMPLE.RWP.
To convert this printer definition file to your printer, dig out your printer manual and substitute the escape sequences there-in for the one listed below. If the format looks a little like COBOL to you, it's not by accident. This is a very simple example, you can get as fancy as you want. You can even achieve effects (such as bold and underscore) on printers that do not support these modes. This is accomplished by over-printing which is performed automatically, your program doesn't have to worry about it.
© 2000-2016 Norcom, all rights reserved