5: Creating the Demonstration System Reports

5.6 Printing Totals

Most reports that show a column of numbers also show sub-totals and a grand total. An example of a sub-total would be the total of all invoices for a particular customer. An example of a grand total would be the total of all invoices for all customers. In either case, the total is always reset to zero after printing the amount. Thus, the customer sub-total only contains the total for a particular customer because it is reset to zero before to processing the next customer.

Some reports need to show a cumulative total. An example might be printing an account balance after each transaction. For these types of totals the amounts should not be reset to zero after printing. The Report Generator refers to this type of total as a Running Total.

To illustrate total fields, we will add to the example used in the preceding section a total count of subscriptions to all magazines which are printed at the end of the report. (Note: Currently our report shows only the number of subscriptions to each magazine.) This total field should be placed in the Report Footing section, as this is the section which is printed only at the end of the report.

We want our total to be ‘lined up’ under the column labeled Subscribers. An easy way to do this is to start with the detail line itself (i.e., the line contained in the Detail section). With the Report Section screen displayed, press the NEXT key <F3> or the PREVIOUS key <F2> until the Detail section is displayed.

Now simply position the cursor on the starting column of the field to be totaled (i.e., the subscriber field) and use the PREVIOUS or NEXT function to display the appropriate Report Section screen (in this case, the Report Footing section).

Notice that the cursor did not move when you changed sections. The cursor is still in the same column as the starting column of the subscriber field. At this point, you could press the ADD key <F6> and add the total field, but first we should consider how this would affect the printing of the report.

The report has (among other columns) a column of numbers, with each row re-presenting a record in the RMSfile. These rows would then be followed by an additional row containing a number with no indication as to its significance. The whole purpose of displaying a total, however, is to highlight a summary piece of information. Therefore, we need some way to highlight the total.

Perhaps the most common way of highlighting totals is to draw a line between the column of numbers and the total. This can be done in a report by using the minus sign (-)

We must also consider the likelihood that our field total may require one or more additional digits than the individual totals did and format the report accordingly. (Note: In our example we will allow room for 1additional digit.)

First, press the Left Arrow key once. Next, press the minus sign 6 times. Once this has been done, use the Arrow keys to reposition the cursor one line below, but in the same column as, the left-most minus sign. Now press the ADD key <F6> to display a new Field Description form and enter the necessary information to process the desired total.

A total field differs from all others in that the Field Name field of the Field Description screen is left blank . The name of the field being totaled is instead entered into the field labeled Sum of?.

Pressing the STORE key <F5> stores the contents of this Field Description and redisplays the current Report Section screen.

At this point, you may once again select the PICTURE function (by pressing the GOLD key <F1> followed by the P key) to make sure things are ‘lined up’ as they should be.

You have now successfully recreated the report which is run by selecting choice 5 - List Magazines from the Demonstration Subscription System menu. Press a key (i.e., any key) to redisplay the current Report Section. Once this has been done you may press the EXIT key <F8> to save the reportfile and return to the Report Generator Menu.