Skip to content

Other Features

Variable-Length Fields

If any of your report fields are to take up a variable number of columns, use the left-shift (or "squeeze") symbols "<" and ">" in the PICTURE. The examples below show the effect of these symbols:

variable fields

The reason why PIC <9>9 was coded rather than PIC <99> against the child's age is to prevent a value of zero from causing the field to vanish completely. In the other cases, the closing ">" symbol is optional. Now imagine this same code with all the "<" and ">" symbols removed from the PICTUREs. This is what would appear:

member and children ages

Insertion Characters

As well as by using standard PICTURE symbols such as "/", "0" and "B", you can place any additional characters into your report field by placing them within "quotes" (or 'apostrophes' ) within the PICTURE. For example, to print a percentage:

PIC ZZZ9.99"%" SOURCE 100 * COST / TOTAL ROUNDED

Column Center and Right

You can specify the center or the right-hand column as an anchor point, rather than just the left-hand column. To do so, write COLUMN CENTER or COLUMN RIGHT. (CENTRE is an alternative spelling.) In the case of COLUMN CENTER, if your field has an even number of characters, the odd character goes on the right. This feature saves you time when you are working with fields of different lengths, in different lines, that should appear centered or right-aligned in a "stack". It also simply saves you the effort of counting out the length of a field in order to center it. See the following cases, all of which produce the same result:

column center

If your field is variable-length, report writer first takes the actual size of the field before it positions it. In this way a name, title, etc. can be centered or right-aligned:

column center

NEXT GROUP Clause

Use this clause when you want to create extra space between report groups or when you need to ensure that a particular report group is the last on the page, perhaps the CONTROL FOOTING of a major control. With new Report Writer, this clause is necessary only with body groups. It has the useful property that, if there is a higher-level control break, the lower-level CONTROL FOOTING group does not affect the higher-level one, so that, if there is room, they normally remain together on the same page. Write the clause in your 01-level entry for the group. The form NEXT GROUP + integer will create integer extra blank lines following the group, provided it is not the last on the page. The form NEXT GROUP NEXT PAGE causes your group to be the last on its page.

GROUP LIMIT Clause

You may not want some particular report groups to appear below a certain line on the page. For example, a CONTROL HEADING would seem out of place if it were last on the page. Just code GROUP LIMIT IS integer in the 01-level entry of your group. Integer will then be the bottom line number allowed for the last line of the group. See immediately below for an example.

CONTROL HEADING at Top of Every Page

Many report layouts have CONTROL HEADING groups that have to appear at the top of each page as well as after a control break. If this is required, just write the words OR PAGE after the control-name in the TYPE clause of your CH group. The following diagram shows this effect, and also illustrates the GROUP LIMIT clause that we discussed above.

club expenditure

On the first screen, because of the GROUP LIMIT, the CONTROL HEADING will not appear after line 57.

On the second screen, a CONTROL HEADING re-appears because of the new page even though no control break occurred.

club expenditure

Multiple Page Groups

If you have a large vertical table to print, perhaps a summary with one line for each value encountered, you may be concerned that it will not always fit on one page. Perhaps there are usually less than 60 items but you have to allow for anything up to 1000 items! To handle this, code the clause MULTIPLE PAGE on your 01-level. Report writer will then automatically do a page advance whenever the page is full (printing PAGE FOOTING and PAGE HEADING as usual). Thus your code would be:

01 SUMMARY-PAGES TYPE DETAIL MULTIPLE PAGE.
 03 LINE OCCURS 0 TO 1000 DEPENDING ON NO-OF-ITEMS.
... etc.

This feature also handles more complex layouts, perhaps a multi-page personnel profile.

Line WRAP

You may sometimes define a number of relative COLUMN entries in one line and wonder whether they will all fit in the same line. If not, report writer will automatically wrap your data round onto a continuation line, but only if you code a WRAP clause. You can specify the last column before the wrap, the starting column for the continuation and the line advance required. As an example, you may have a series of possible error messages:

03 LINE + 3 WITH WRAP AFTER COL 120 TO COL 82 STEP 2.
 05 COL 1 PIC X(80) SOURCE INPUT-RECORD.
 05 COL + 2 "ACCOUNT NUMBER INVALID" PRESENT WHEN ...
 05 COL + 2 "AMOUNT NOT NUMERIC" PRESENT WHEN ...
 05 COL + 2 "DATES IN REVERSE ORDER" PRESENT WHEN ... etc.

Function

The FUNCTION clause is used when you need to produce a specially formatted or converted report field that cannot be produced by SOURCE, SUM, or VALUE . Each FUNCTION corresponds to a pre-written routine that is either a built-in part of the report writer software or written by a person at your location. Examples of built-in FUNCTIONs are:

  • DATE This outputs today's date, or any given date, in the order: Day-Month-Year.
  • MDATE This produces the same output as DATE, but in the order: MonthDay-Year.
  • TIME This gives the current time.

Here is an example of how to use MDATE. Let's suppose that today is May 7th, 1999.

Then if you write:

function

Information about developing your own functions is in Developing User-Written Functions.

Special Print Attributes (Styles)

Nowadays all large system printers and smaller-scale printers and terminals have the ability to produce special effects which we hardly ever make any use of in COBOL applications. The STYLE clause enables you to make full use of any special effects that are available without affecting your program's portability. Supposing that you wish to highlight any "negative profits". Write:

05 COL 21 PIC -(8)9 SOURCE PROFIT
      STYLE IS HIGHLIGHT WHEN PROFIT < 0.

You will now not need to change your program when moving between, say, a personal system, a mainframe with a laser printer, and a mainframe with an old impact printer, except possibly to change the TYPE clause in the SELECT...ASSIGN if it is not preset as the default. Also, the STYLE clause has no effect on the COLUMN clauses or any other part of your source program.

Independent Report File Handlers

Normally, your report's outputs are directed to a standard print file, as though you had written the program in elementary COBOL using WRITE AFTER ADVANCING...statements. An Independent Report File Handler is a pre-written routine to which all the output for a report file is directed. It may manipulate and output the data in any way the designer chooses. Your program can be made to invoke the file handler each time it has a line of report data, instead of implicitly executing a WRITE...AFTER ADVANCING. Each file handler is identified by a unique "mnemonic-name" of up to four characters. You cause your report program to use a file handler by coding your SELECT clause for the report file in the following way:

SELECT print-file ASSIGN TO assignment-name
 MODE IS mnemonic-name.

The file handler may require you to define a CODE clause in your RD statement. This clause is used to pass additional information to the file handler. Apart from this, no other change need be made to your program.

Multiple Reports

Your program may need to produce several different physical reports. Of course, you may define as many report files as you like, and each may be associated with as many Report Descriptions as you wish. But what if several of the reports have a similar appearance? You will not want to duplicate the code for all the Report Group Descriptions. Instead, you may define the report just once and effectively assign it to several files (although only one FD entry is coded). Just add the following clause to your SELECT clause:

DUPLICATED integer TIMES

with the integer set to the maximum number of distinct reports you need. The DUPLICATED clause causes the special register REPORT-NUMBER to be set up. You can MOVE any value into REPORT-NUMBER from 1 to your maximum number. This causes report writer to channel subsequent output to the corresponding report file. Each report is logically separate. Of course, the contents of each report are different because your program is writing to only one of the set at any given time. The layouts need not all be identical, since you are quite free to vary them conditionally in the usual way. (For example, REPORT-NUMBER could be used as a subscript or within the condition of a PRESENT WHEN clause.) Only one FD entry is required for all the physical files associated with the multiple report. Similarly, only one OPEN and one CLOSE are required to open and close all its files.

Using the Page Buffer

Some layouts are so irregular that you may wish that you could build up the page in any order like a news-sheet editor. The Page Buffer facility enables you to do this. Just add to your SELECT clause:

WITH PAGE BUFFER

Now you can tackle a layout such as the following:

new member details

new member example

The report groups in boxes have been defined separately. Normally you would not be able to place them alongside each other. (The REPEATED clause is not appropriate as NAME-ADDRESS-GROUP and SPORTS-GROUP are instances of different groups, not instances of the same group.) By using the Page Buffer you may now write in the PROCEDURE DIVISION of your program:

SET PAGE STATUS TO HOLD
     GENERATE NAME-ADDRESS-GROUP
     SET LINE TO FIRST DETAIL
     SET PAGE STATUS TO RELEASE
     GENERATE SPORTS-GROUP
You may store the groups on the page in any order. It is also possible to change the left/right positioning of groups by means of the SET COLUMN statement. There are several other variants of SET PAGE and SET LINE (see Report Writer SET statements).

Back to top