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

DB Pipeline Master Detail

edited November 2005 in Datapipelines
Hello,
I have had problems with records not appearing on reports using Linked
DBPipelines.

A hypothetical report for example to print order numbers (using
OrderPipeline) along with the customer address

OrderPipeline
DataSource = DSOrders
SkipWhenNoRecords = FALSE

CustomerPipeline
DataSource = DSCustomers
MasterDataPipeline: OrderPipeline
MasterFieldLinks: CustomerCode = CustomerCode
SkipWhenNoRecords = FALSE

For most orders the customer address fields from the CustomerPipeline will
print. On some it just comes out blank.

Maybe the Customerpipeline only searches forwards?

If i remove the masterdatapipeline property and field links from the
customer table and code in a Customers.Locate('CustomerCode',CustCode,[]);
everything works ok.

This has caught me out more than once now. Am I using piplines incorrectly
for getting relational data?

Comments

  • edited November 2005
    Hi Steve,

    Be sure that your detail dataset is ordered on the linking field.
    ReportBuilder only traverses both datasets beginning to end to increase
    processing speed. Take a look at the following article for more
    information.

    ------------------------------------------------
    TECH TIP: Fundamentals of Report Data Traversal
    ------------------------------------------------


    1. Single Table Listing Report

    Assign the Report.DataPipeline property and leave the
    DetailBand.Pipeline unassigned.

    The report will traverse the data from start to end (based on the
    datapipeline range settings and honoring any filters you've placed on
    the datset etc.)


    2. Master/Detail Report:

    A. Assign the Report.DataPipeline property to the master. Create a
    subreport in the detail band and assign the childreport.DataPipeline to
    the detail datapipeline.

    Use either the visual linking features available from the Report
    Designer's Data tab, or Use standard Delphi dataset linking to define
    the relationships between the datasets.

    The Report will traverse the master records and for each, the subreport
    will traverse the detail data related to the master.


    3. Master with 2 Details

    Configure as in 2 above. Add an additional subreport to the detailband.
    Set subreport.ShiftRelativeTo property to the point to the first
    subreport. Connect the ChildReport's DataPipeline to the detail data.


    4. Report connected to no datapipelines.

    When Report.AutoStop is set to True, the Report will print a single
    detail band.

    When Report.AutoStop is set to False, the Report will print detail bands
    until instructed
    to stop. You can control when the report stops by setting the
    Report.PageLimit property or by calling Report.DataTraversalCompleted
    method. Otherwise the report will never stop.


    Additional Notes:
    ----------------

    1. SubReports have a Report property that is of type TppChildReport.
    Thus, programmatically you can code SubReport.Report.DataPipeline :=
    myDataPipeline.

    2. ChildReport's traverse data following the same rules as above. A
    ChildReport prints in its entirety each time it gets a turn to print.

    3. For a Child style SubReport use the Title/Summary band rather than
    the Header/Footer (or use a GroupHeader/GroupFooter combo). A standard
    Header/Footer will not work because these always print at the very
    top/bottom of the page.

    4. Do not filter the dataset of modify it any way once the report.Print
    command is issued. If you need to do master/detail and cannot use
    linked datasets, then use the master DataPipeline.OnRecordPositionChange
    event to filter the detail dataset.

    5. The reports and datapipelines use dataset bookmarking. Make sure
    the dataset can support bi-directional navigation.



    Check out the RBuilder\Demos\Reports\Demo.dpr project. Reports 0071,
    0072, 0073 show examples of master w/mutliple detail style reports.
    Number 0072 has two detail reports.


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    Nico,
    I checked this and the dataset's are ordered on the linking field.

    I since modified the code so that i no longer use the MasterDataPipeline and
    linking fields, instead i have a unlinked pipeline and use Locate in the
    code to find record.

    However I still have a problem and would like to understand why I cant get
    this to work:-

    Here is the setup I have a Memory Table that has one field "idHeader" and I
    populate this table with header id's I want to print.

    HeaderIDPipe
    HeaderPipe
    MasterDataPipeline - HeaderIDPipe
    LinkingFields - idHeader
    DetailPipe
    MasterDataPipeline - HeaderPipe
    LinkingFields - idHeader


    The report previews ok.

    Here is the strange thing. After clicking the print button from the preview
    window the report prints out with one detail line per page (and most detail
    lines are missing). After printing, the preview is the same if you change
    pages. However this does not happen with all printers. It appears to work ok
    when printing to some printers. For example for testing I use a PDFCreator
    and that works ok, but if i print to my HP5 it messes up.

    I have again got around the problem by using code (example below) and
    removing the pipe master detail link.

    Also I am not using any master detail links on the dataset.

    Procedure TfrmMasterDetailReport.HeaderPipelineFirst(Sender: TObject);
    begin
    Detail.SetRange([Header.FieldByName('idHeader').AsInteger],
    [Header.FieldByName('idHeader').AsInteger]);
    end;


    Am I doing something wrong when using pipe linking?



  • edited December 2005
    Hi Steve,

    Which database are you using? Are some of the records in your linking field
    null? If possible, please send a small example I can run on my machine in
    .zip format to support@digital-metaphors.com and I'll take a look at it for
    you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    Hi Nico,
    I am using Pervasive SQL.

    The index on the detail pipeline has 3 fields, idHeader, MachineId,
    SerialNo.

    I am linking by the primary field only.

    The second two fields in the key are for retrieval order. None of the fields
    are null.

    It is a bit difficult to send you the whole thing as it is part of a larger
    exe. the example I have given in this post is a hypothetical version to
    demonstrate what i am doing with linking.

    I have sent you the dfm and pas files for the actual report. Hope this is
    useful.

    Regards

  • edited December 2005
    HI Steve,

    Sorry for the delay. Looking at your example, I cannot see anything that
    jumps out as incorrect.

    Looking at your previous posts, I'm a bit unclear about the setup of your
    datasets. Is the in-memory dataset acting as the master dataset in your
    master-detail relationship? This is very strange that it previews ok but
    the printed output is incorrect. As a quick test, try commenting out all
    your event code dealing with the report and see if you can get the data to
    print correctly. If there is event code specifically dealing with the data,
    try tracing into it as the report previews and as the report prints and try
    to find the differences. Perhaps some event code is firing or not firing at
    certain times.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    Hi Nico,

    I have commented out the event code with the exception of the
    LotPipeLineFirst which is needed to perform the Master detail linking
    manually.

    The report still has the same problem. Previews ok, then prints messed up,
    then is messed up in the preview after printing and then using next/previous
    page.

    I will send you 2 screen shots. before print and after print.

    Regards

  • edited December 2005
    Hi Steve,

    You mentioned that this only occurs when printing to an HP5. Have you tried
    printing to other printers? Also, be sure you are not linking both the
    pipeline and the dataset at the same time. If possible, please send a
    simplified version of this app that I can run on my machine to
    support@digital-metaphors.com in .zip format and I'll take a look at if for
    you.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    Hi Nico,

    Yes it does occur with other printers but not all. It was first
    reported to me by our customer who was printing to a dot matrix, but it
    works ok on their laser. I initially put it down to their printer driver
    until i saw it for myself.

    Here I have problems with the HP5 but if I print to PDFCreator (Windows
    Virtual printer to PDF Document) it works ok.

    I did also notice that I had the Master Detail link in place on the
    TransactionPipeline, but that still works ok with or without the link
    provided i use SetRange to limit the Dataset.

    And in the lase message I forgot to mention that yes the master is the
    Memory dataset. so the LotPipeline first fires for each record in the Memory
    dataset.

    It would take some time to get it working as a seperate project. You would
    still need a database (cut down and zipped) and you would also require the
    www.pervasive.com SDK with PDAC (Pervasive Direct Access Components) and (2
    user) Workgroup developer engine from their site.

    Would that be too much for you to set up as a test?

    Thanks for your continued help.

    Regards

  • edited December 2005
    And Just to add to the last message

    I have no master detail links set up on any Dataset's in my Datamodule, I
    intended for RB to do that for me.

    Regards


  • edited December 2005
    Hi Steve,

    Yes, if you can put together a simple example where I can see this behavior,
    I will try to download and install a trial version of Pervasive and see if
    I can find the problem. Please send the example in .zip format to
    support@digital-metaphors.com.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.