Home RAP

Getting summary data out of subreports

edited October 2003 in RAP
Hi,

RB 6.03

We have the following

pl_Master : master pipeline
pl_FirstChild : child pipeline (linked to pl_master)
pl_SecondChild : child pipeline (linked to pl_master)

On the main report page we have placed two subreports in the detail
section, each linked to a single child pipeline.

We need to do the following using RAP
In both the subreports we calculate summary totals using a dbcalc in the
summary section. We need to be able to add these two totals and display
the sum in the detail section of the main report.
We also need to maintain a running total based on the sum described
above and display the outcome of the running total in the summary
section of the main report.

What we have done so far
declared two variables in the main report
var_sum_firstchild : float;
var_sum_secondchild : float;

added a TppVariable in the summary section of each subreport.
cvar_FirstChild : TppVariable
cvar_SecondChild : TppVariable;


In each of the subreports we set the respective variables to 0 in the
ReportOnStartPage of the subreport.
In the OnPrint event of each TppVariable we copy the value of the DbCalc
element (located in the same summary section) to the TppVariable;

In the main report we can now sum the two TppVariables and display the
outcome. We can also keep a running total by
var_RunningTotal := var_sum_firstChild + var_sum_SecondChild;
This is done on the DetailBeforePrint event

Furthermore var_RunningTotal is set to 0 in the ReportOnFirstPass and
ReportOnSecondPass event;

To display the outcome of the running total we added a TppVariable
(cvar_RunningTotal) to the summary section of the main report and in the
OnGetText event of cvar_RunningTotal we display the value of
var_RunningTotal.

Our problem is that the running total in the main report will change
depending on which pages the user visits. Please note that we also use
Report.TwoPass to display a correct count of pages.
When the user opens the report and looks at the first page and
afterwards goes to the second page and then to the last page the outcome
is different from when the user looks at the first page and goes to the
last page.

So far we have found out that when we move between pages the
DetailBeforePrint event is fired and thus the running total is changing.
I have a nasty feeling that this has to do with the subreports or with
the way these are handled.

So my big question is how can I do what I described above and use
subreports??


regards
Paul Sjoerdsma

Comments

  • edited October 2003

    1. You could try setting Report.CachePages to true. However you may still
    encounter issues, due to the events you are using.

    2. An Alternative approach:

    Try modifying the global variables from floats to references to
    TppVariables:

    Global Declarations:

    var_sum_firstchild : TppVariable
    var_sum_secondchild : TppVariable;

    Use the GlobalOnCreate event of the main report to establish the object
    references:

    var_sum_firstchild := cvar_FirstChild;
    var_sum_secondchild := cvar_SecondChild;

    In the SubReports use TppVariables rather than DBCalcs. In the SubReport
    Variable.OnCalc event, increment the main report's variables.





    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2003
    Hi Nard,

    Thanks for the fast reponse. However cvar_FirstChild and
    cvar_SecondChild are TppVariables placed on the summary section of the
    subreports and I can't figure out how to establish the object references
    in the OnGlobalCreate in the main report.

    Would it be possible to send a small demo. We need to use the behaviour
    explained earlier in financial reports end these need to work

    TIA

    Paul

    In article <3f858cdd$1@dm500.>, "Nard Moseley \(Digital Metaphors\)"
  • edited October 2003
    Hi Nard,

    1- In reference to my earlier posts, we can only work from within the
    Report Designer. This is an end user report that we need to create at
    their site
    2- Is there any in depth documentation on how the events work, when they
    are fired etc. At the moment we sometimes use OnCalc and sometimes
    OnGetText. Not always sure why things behave they do, which makes
    creating a solid report difficult

    regards
    Paul Sjoerdsma

    In article ,
    paul.sjoerdsma@redsnapper.nl says...
  • edited October 2003
    Hi Nard,

    We finally found the solution, using references to Tppvariables.

    Thanks for the support

    regards
    Paul

    In article <3f858cdd$1@dm500.>, "Nard Moseley \(Digital Metaphors\)"
  • edited October 2003

    Run the RBuilder\Demos\Reports\Demo.dpr project and select the "Events"
    category. Demos 141 thru 147 visually show various events as they are being
    generated. You can easily adapt the techniques shown here to create your own
    "event tracker" examples that focus on the exact events you in which you are
    interested.

    See the Calculations thread of the Tech Tips newsgroup for articles on
    performing calculations.

    OnGetText: fires whenver any code in ReportBuilder tries to access the
    Component.Text property. This means that the event fires quite frequently.

    OnCalc: Use the TppVariable timing settings to control how this event fires.
    (Right mouse over the Variable and select the Timing... option). Most often
    use the default of traversal. The report engine will fire this event when a
    traversal is performed. The Variable has the ability to save/restore
    intermediate results to its internal cache. Thus it saves the results as of
    the end of each page and at the beginning of the next page, restores them.
    This enbables RB to jump around in the viewer from page 40 back to page 1,
    etc. Also complexity arise when using options such as KeepTogether.


    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.