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

Designing ReportBuilder's report template files for n-tier environment.

edited September 2003 in End User
I'm currently using a TDataset descendants component called dbOClientDataSet
for my n-tier application.

At design time, I have created a report this way...
Database <-> ODBC <-> ReportBuilder's Query Designer <-> TppReport

I can preview my report at this stage, I then saved the created report as a
ReportBuilder template file (.rtm), and deployed the template file to the
client machine.

My question is how can I preview my report template file at run time using
the following data connection approch?

Database <-> Mid-tier application <-> TdbOClientDataSet <-> TDataSource <->
TppDBPipeline <-> TppReport

What I'm trying to ask here is, I would like to create a report template
file using client-server way (via QueryDesigner and ODBC) but to preview the
report in n-tier environment. My understanding now is at the design time
the ReportBuilder looks for the datasource itself (and this is the simplet
way to create a report), but at run time I want the report template to get
the data from the TdbOClientDataSet instead. Is it posible???, if so please
give me some ideas how to do this.

Thanks.
Kongthap Thammachat

jeud@yahoo.com
ICQ: 13026976

Comments

  • edited September 2003
    Hi Kongthap,

    When you create a dataview in DADE, the objects of the dataview are saved in
    the report template. You can then load this template at runtime, however,
    the report will create the dataviews at runtime and use those datapipelines
    in the dataviews to access the data. What you'll need to do is load the
    template and then try to switch out the pipelines. Use the
    Report.Template.OnLoadEnd event (this fires after the objects of the report
    are streamed up from the template into objects). You can go into the
    datamodule of the report and loop through the dataviews in code and see what
    they are trying to connect to. Create a class that takes a report and loops
    through its dataviews. Then it can take a dataview and see what data table
    it was trying to connect to. You could then soft code it to do this and then
    go and find the new client dataset that it should use from a regular
    pipeline. Clear out the dataview definition once this information is known
    for the report and its subreports. Then you can connect the report to the
    new pipeline you have defined on the TForm/TDatamodule. Here is an example
    of extracting the SQL object in a dataview.
    http://www.digital-metaphors.com/tips/ExtractSQLObject.zip
    These are internal classes, so there is no documention other than the
    source, but the interface section is located in daSQL.pas. Then you can
    clear the datamodule of the report as shown in this example.

    uses daDataModule;
    ...
    var
    lDataModule: TdaDataModule;
    begin
    lDataModule := daGetDataModule(ppReport1);

    if lDataModule = nil then
    lDataModule := TdaDataModule.CreateForReport(ppReport1);
    else
    lDataModule.Template.New;
    ...

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited September 2003
    Thanks Jim

    Please help again.

    I created a report using Query Designer, I haven't saved the report to .rtm
    file yet because I want to keep it simple at this stage. I also droped
    Table1, DataSource1, ppDBPipeline onto the form and tie them up to my
    ppReport1

    What I am trying to do is when I clicked on a button, I want to replace the
    existing dataview object which was created using QueryDesigner with the one
    from ppDBPipeline (because I plan to retrieve the data via a dataset at
    run-time)

    I have tried this coding for OnButtonClick...

    var
    lDataModule: TdaDataModule;
    begin
    lDataModule := daGetDataModule(ppReport1);

    if lDataModule = nil then
    lDataModule := TdaDataModule.CreateForReport(ppReport1)
    else
    lDataModule.Template.New;

    ppReport1.DataPipeline.DataView := ppDBPipeline1.DataView;
    ppReport1.Print;
    end;

    I believe, I have successfully gotten rid of the existing dataview because
    the report output came up with a blank page, but I still haven't got the
    replacement with new dataview.

    Please suggest me what to do next.

    Thanks for all.
    Kongthap

  • edited September 2003
    Hi Kongthap,

    You'll have to replace the Report's data pipeline, not the dataview. The
    dataview only exists when using DADE.

    Replace your code:

    ppReport1.DataPipeline.DataView := ppDBPipeline1.DataView;

    with this code:

    ppReport1.DataPipeline := ppDBPipeline1;


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.