Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Report timings

edited December 2004 in General
I have spent several days trying to work out how report builder (7.04)
actually works when it generates groups, subreports and calculates variable
values.
What I mean is how does it work out in which sequence events such as
BeforeGenerate, AfterGenerate, OnCalc, OnPrint etc fire?
The other thing I could not work out is at wchich point during processing
does the RB generate groups?

Also, with respect to the above what is the difference when the report is
set to OnePass and TwoPass?
Is there a document somewhere (I have read all doco that came with RB,
including the demos) that would explain what is actually going on as RB
traverses the master pipeline?

Basically I have two problems.

1) I am stuck with a report that uses memory tables rather then simple SQL
queries.
Because of the way the whole thing is structured I have to calculate running
totals myself.

This is roughly what it looks like

--- detail 1
--- detail 2
--- ...
--- group 1 footer (here I want to save a value X from "any" record in
the detail section since they all have the same value - let's save it in two
variables called VAL1 and also VAL2)

--- group 2 footer (here I need to print sum of all VAL1 so far, but then
reset it to 0 for the next group)

--- group 3 footer (here I need to print sum of all VAL2 so far, but then
reset it to 0 for the next group)

I tried doing the sums in the group's Before and After generate events but I
ether got 0's or accumulated sums.

2) The other problem is with subreports.

I placed 2 subreports in a group's footer band. For the first occurrence of
the group's footer both subreports return the correct data. However in the
subsequent occurrences of the group footers each subreport seems to return
data that is not related to the group and some data is also missing - blank
DBText fields.
Even worse, the subreports print after the actual group footer!

To explain it better let's say there is a master pipeline of all employees.
Each group represents employees within certain department.
In the group footer I need to have 2 subreports followed by a number of
employees in the group. Subreport A lists various $ sums that relate to the
department and subreport B lists some other data that relates to the same
department. I linked the subreports to the master report via the department
ID.
When the group is generated the first time, I see all data in the subreports
correctly. However the next group generated will print $ sums for the
previous group as well, the same is true for the other subreport. It looks
as if the subreports are being printed twice (I only have two groups so I
don't know if the third occurrence of the group would generate each
subreport 3 times but I suspect it would). And the footer prints the number
of employees first, followed by subreports A and B whereas it should be
subreport A, subreport B and finally number of employees.

I know that the data in the pipelines must be sorted for the links to work
properly and as far as I can tell it is sorted.

I am really confused and would appreciate if someone could explain to me
what is going on.

Thank you,

Peter

Comments

  • edited December 2004


    1. This post is way too long. Ask specific questions. Best way to
    illustrated a situation is to create one or more simple examples and send to
    support@digital-metaphors.com and let us examine it. Keep examples focused
    and simple. Use standard Delphi components and DBDemos data.

    2. To learn about event timing, run RBuilder\Demos\Reports\Demo.dpr and
    check out the Event Tracker demos in the Events section. You can create your
    own event-tracker demos.

    3. Calculations should be performed using TppVariables. You can place them
    in each group footer. See the Calculations thread of the Tech Tips newsgroup
    for more information.





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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2004
    I have a group footer containing a subreport.

    For the first record the group and subreport print fine.

    For the second record I get the group footer but without the subreport,
    although there is data for that subreport.
    Then the subreport gets printed after the footer (I know because I have a
    line at the very bottom of the group footer) and it is also repeated several
    times. I get the subreport for the first record, followed bu subreport for
    the second record.

    What could be causing this?


  • edited December 2004

    Make sure the data linking relationship is defined properly. ReportBuilder
    supports two types of data linking.


    ------------------------------------------------------
    Tech Tip: Linking SQL Queries for Master/Detail Data
    ------------------------------------------------------

    The following example shows two options for linking SQL queries to create a
    master/detail relationship.

    In this example, we are using Delphi's DBDemos data to create a
    Customer/Order relationship. Thus we wish to link the Orders detail to the
    Customer master.

    I. Delphi Query Linking
    ------------------------

    a. Set the detail TQuery.DataSource property to point to the master
    query's TDataSource component.

    b. In the SQL "Where" clause for the detail query use a ':' followed by
    the linking field name from the master:

    example
    select *
    from orders
    where orders.CustNo = :CustNo

    Now each time the master record position changes, the detail query will
    automatically be refreshed with the correct result set.


    II. RB DataPipeline Linking
    -----------------------------

    a. Set the detail DataPipeline.MasterDataPipeline to point to the master
    DataPipeline.

    b. Use the detail DataPipeline.MasterFieldLinks property to define the
    linking relationship

    c. In the SQL for the detail, retrieve all records and sort them by the
    linking master field:

    select *
    from Orders
    order by CustNo


    Notes:

    1. Using RB DataPipeline, each query is executed only a single time - thus
    performance is much faster.

    2. RB Professional and Enterprise Editions include a visual Data environment
    for creating SQL queries, defining linking relationships, and creating
    Ask-At-Runtime parameters. Using the RB tools you could create the above
    linked queries in about 10 seconds.


    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com






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



    Best regards,

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