Author Topic: Controlling Break Fields for "Totals Only" in Report Definitions  (Read 7124 times)

Tom Pellitieri

  • Rock Star
  • *****
  • Posts: 224
  • Tom Pellitieri - Toledo, Ohio
While SB+ provides many report parameters as @RV.xxx (stored in common variable OTHER( 8 )), one of the useful items that is not available is the "Totals Only" flag.  I usually use the break lines to provide nice formatting/spacing, but this format looks terrible if someone chooses to run a Totals Only report instead of a Detail report.  In the past, I've had to write two different reports.  I just found a way to provide the control I need in a single report.

There are two @RV.xxx items that make this possible.  @RV.LINE has the detail line to be printed.  @RV.BREAK.CNT has a sequential break section number to print.  If both of these are 1, it means that the first break section is being printed as the first line of the report.  I found I could use this to control my break sections.

First, in the Process at Start for the report, I need to set a control flag, e.g., USERDATA(1), to zero.  Then, in the Process Before Break slot, I added this test [Edit:  Added @RV.PAGE]:

IF (@RV.PAGE+0) = 0 AND @RV.LINE = 1 AND @RV.BREAK.CNT = 1 THEN @USERDATA(1) = 1

At this point, @USERDATA(1) can be tested as a "Totals Only" flag.

Here's a sample of how this is useful.  I have a report that prints Invoices for a Customer.  The (trimmed) layout is:


C Cust #  Invoice #  Invoice Amount
D XXXXXX  XXXXXXXXX  999,999,999.99
B                    --------------
B XXXXXX  Total      999,999,999.99
B
G                    ==============
G Grand Total        999,999,999.99


With this layout, a detailed report looks great, with "footer" lines before each total.  However, if I run a totals only report, each customer's summary takes three lines, including a leading "footer" line, which looks terrible.  With the new flag, I can close this up by adding Conditional fields on the non-data break lines with this condition:

IF(@USERDATA(1),1,0)

When I do this, the Totals Only report has just one line per customer, and just the single footer before the Grand Total.

[EDIT] If the Grand Total line is on a page by itself, I can also supress the row of Equal Signs by using IF(@RV.LINE=1,1,0)

Personally, I think IBM should add this flag to @OTHER( 8 )/@RV.xxx list, but at least there's a solution available until that happens.

--Tom Pellitieri
« Last Edit: October 23, 2007, 09:36:21 am by Tom Pellitieri »

precisonline

  • President
  • Administrator
  • Rock Star
  • *****
  • Posts: 1609
    • Precision Solutions
Re: Controlling Break Fields for "Totals Only" in Report Definitions
« Reply #1 on: October 23, 2007, 08:57:18 am »
CLEVER, man!  Thanks for sharing!
-Kevin
Accidents "happen"; success, however, is planned and executed.