COBOL programming tools from NORCOM

     Products     Prices and Purchasing     Support     News     Partnerships     Home   Contact Us   Downloads

 

 

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!

  • RW2 supports the full IBM VS COBOL Report Writer syntax.  IBM mainframe COBOL programs using Report Writer programs will generally run on your PC COBOL without change.
  • RW2's powerful extensions to mainframe Report Writer features will spoil you forever. You no longer have to count bytes in many of your literals or worry about counting lines and pages to make sure that your formatting works out.  RW2 makes printing unbelievably EASY!
  • RW2 produces fast and efficient code.  None of the speed or efficiency of your COBOL is sacrificed.  RW2 consists of a preprocessor and an associated object library that contains runtime support. 
  • RW2 has full font/style control. You can now use the full stylistic capabilities of any PC printer. Boldface, italics, underscore, different font sizes and styles are easy to use - all without memorizing obtuse escape sequences for printer control.
  • RW2 supports hardware independence via external Printer Control Files, so you don't have to include printer dependent code in your program.  You can refer to generically named styles such as BOLD, UNDERLINE, ITALIC, or whatever you please, and then equate the printer-specific codes to those styles in your Printer Control File.

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.

Mainframe Compatibility

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!

New Features

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.

Reduced Coding

If you're a Report Writer user you've seen code like this:

       10 COLUMN 10 PIC X(6) VALUE 'ABCDEF'.
       10 COLUMN 16 PIC X(6) VALUE 'GHIJKL'.
       10 COLUMN 22 PIC X(6) VALUE 'MNOPQR'.
       10 COLUMN 28 PIC X(6) VALUE 'STUVWX'.

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:

       10 COLUMN +1 PIC X(6) VALUE 'GHIJKL'.

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:

       10 COL +1 'GHIJKL'.

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:

       10 COL 10 'ABCDEF' 'GHIJKL' 'MNOPQR' 'STUVWX'.

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:

     05  COL +3 OCCURS 12 VARYING MONTH
                PIC XXX SOURCE MONTH-NAME (MONTH).

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:

    05  LINE +1 ABSENT WHEN STREET-2 = SPACES.
      10  COL 1 PIC X(30) SOURCE STREET-2.

    05  LINE +1 ABSENT WHEN STREET-3 = SPACES.
      10  COL 1 PIC X(30) SOURCE STREET-3.

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:

 01  CONTROL FOOTING FOR MONTH.
     05  LINE +1.
       10  COL +1 'Total:'.
       10  TOT COL +2 PIC $$$,$$$,$$$.99 SUM SALES-AMOUNT.
       10  COL +2 'Sales Made:'.
       10  CNT COL +2 PIC ZZZ9 COUNT OF SALES-DETAIL.
       10  COL +2 'Average Sale:'.
       10  COL +2 PIC $$$,$$$.99 SOURCE (TOT / CNT) ROUNDED.

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:

     05  LINE +1.
       10  COL 1 PIC <X(12) SOURCE FIRST-NAME.
       10  ABSENT WHEN MIDDLE-INITIAL = SPACE.
         15  COL +2 PIC X   SOURCE MIDDLE-INITIAL.
         15  COL +1         VALUE '.'.
       10  COL +2 PIC X(30) SOURCE LAST-NAME.

This will yield, depending on data, either:

JIM B. SMITH or JIM SMITH

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:

     05  COL CENTER 40 PIC <X(45) SOURCE COMPANY.

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:

       10  COL +1 VALUE 'Attention' STYLE IS BOLD.

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:

     05  LINE +1 STYLE IS BOLD.
       10  COL +1 'Your Current Balance Is:'.
       10  COL +2 PIC <999,999,99>9.99 SOURCE WS-BALANCE
               STYLE IS UNDERLINE WHEN WS-BALANCE > 100.

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.

Printer Initialization

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.

 IDENTIFICATION DIVISION.
 PROGRAM-ID. THREEUP.
 ENVIRONMENT DIVISION.
 INPUT-OUTPUT SECTION.
 FILE-CONTROL.
     SELECT MAIL-LABEL ASSIGN TO 'LPT1'
                       TYPE IS SIMPLE.
                       FILE STATUS IS PRINT-STATUS.
     SELECT NAME-FILE ASSIGN TO 'NAME.DAT'
                      FILE STATUS IS NAME-STATUS.
*----------------------------------------------------------
 DATA DIVISION.
 FILE SECTION.
*
 FD  NAME-FILE        LABEL RECORDS ARE STANDARD.
 01  NAME-RECORD.
     05  LAST-NAME             PIC X(20).
     05  FIRST-NAME            PIC X(12).
     05  MIDDLE-INITIAL        PIC X.
     05  ADDRESS-LINE OCCURS 3 PIC X(30).
     05  CITY                  PIC X(18).
     05  STATE-PROV            PIC XXX.
*
 FD  MAIL-LABEL LABEL RECORDS ARE STANDARD
                REPORT IS THREE-UP-LABELS.
*----------------------------------------------------------
 REPORT SECTION.
 RD  THREE-UP-LABELS  LINE LIMIT IS 132
                      FIRST DETAIL 1
                      PAGE LIMIT 6
                      CONTROL IS FINAL.
*
 01  MAILING-LABEL TYPE IS DETAIL
                   FIXED REPEATED 3 TIMES EVERY 44 COLUMNS.
     05  LINE 1.
       10  COL 1 PIC <X(12)  SOURCE FIRST-NAME
                             STYLE IS UNDERLINE.
     05  ABSENT WHEN MIDDLE-INITIAL = SPACE.
        10  COL +2 PIC X     SOURCE MIDDLE-INITIAL
                             STYLE IS UNDERLINE.
        10  COL +1 VALUE '.'.
        10  COL +2 PIC X(20) SOURCE LAST-NAME
                             STYLE IS UNDERLINE.
*
     05  OCCURS 3 TIMES VARYING LINE-IDX.
       10  LINE +1 ABSENT WHEN ADDRESS-LINE (LINE-IDX) = ' '.
         15  COL 1 PIC X(30) SOURCE ADDRESS-LINE (LINE-IDX).
     05  LINE +1.
       10  COL 1 PIC <X(18)  SOURCE CITY.
       10  COL +1 ','.
       10  COL +2 PIC <XXX   SOURCE STATE-PROV.
       10  COL +2 PIC 9(5)   SOURCE ZIP-CODE.
       10  ABSENT WHEN ZIP-PLUS-FOUR = ZERO.
         15  COL +1 '-'.
         15  COL +1 PIC 9(4) SOURCE ZIP-PLUS-FOUR.
       10  A5  ZIP.
       10  ZIP-CODE PIC 9(5).
       10  ZIP-PLUS-FOUR PIC 9(4).
*----------------------------------------------------------
 WORKING-STORAGE SECTION.
 01  PRINT-STATUS PIC XX.
 01  NAME-STATUS PIC XX.
*----------------------------------------------------------
 PROCEDURE DIVISION.
     OPEN OUTPUT MAIL-LABEL INPUT NAME-FILE.
     READ NAME-FILE.
     INITIATE THREE-UP-LABELS.
     PERFORM UNTIL NAME-STATUS NOT = '00'
       GENERATE MAILING-LABEL
       READ NAME-FILE
     END-PERFORM.
     TERMINATE THREE-UP-LABELS.
     CLOSE MAIL-LABEL NAME-FILE.
     GOBACK.

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.

* Report Writer Printer Definition File (SIMPLE.RWP)
* Used with the sample 3-UP label program
TYPE SIMPLE IS EPSON-FX-80
----------------------------------------------------------*
* CLASSES are defined to so that RW2 can prevent the      *
* inadvertant selection of mutually-exclusive styles.     *
*---------------------------------------------------------*
CLASS QUALITY IS NEAR-LQ DRAFT
*Classified STYLEs:
STYLE DRAFT BEGINS X"1B47"
STYLE NEAR-LQ BEGINS X"1B48"
*General styles:
STYLE PICA BEGINS X"1B501B35"
STYLE UNDERLINE BEGINS X"1B2D31" ENDS X"1B2D30"
IMPLICIT STYLE FOR REPORT IS NEAR-LQ PICA
 



 

 

 

 

 

 

 

 



 

COBUG 
 Bringing COBOL
Together

 


2000-2016 Norcom, all rights reserved 

Contact Norcom