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

Assigning ppDBPipeLine at runtime

edited June 2006 in General
Is this the proper way to assign a pipeline to two section subreports at
runtime? The subreports are on the detail band of the main report and
the main report has no pipeline.

It's not working for me, it shows a blank infinite (endless pages)
report acting as though my pipelines are not hooked up.

The really wierd thing is that I have a form which I used to design and
test the report with. On this form I placed all the components
(SQLConnection, datasource, dataset, provider, pipeline, report) and
when I got it to the way I liked it I saved the report to a file. Then I
created a new unit with an object (TPendingStatementReport) that creates
all the necessary componets at runtime. This new unit does not use the
form I used to design/test the report with. However the form does use my
formless unit and creates a temp instance of the
TPendingStatementReport. If I put all the controls back on the form and
still uses the TPendingStatementReport object to create everything it
works fine. If I delete those design time components, it acts like the
pipelines are not hooked up and creates an infinite blank report.





var
stlSubReports: TStringList;
begin
FrptPendingStatements.Template.FileName := GetReportsDir +
kPendingStatementsReportFileName;
FrptPendingStatements.Template.LoadFromFile;

stlSubReports := TStringList.Create;
try
FrptPendingStatements.GetSubReports( stlSubReports );
TppSubReport(stlSubReports.Objects[0]).DataPipeline := FPSRpplOPD;
TppSubReport(stlSubReports.Objects[1]).DataPipeline := FPSRpplOPAD;
finally
FreeAndNil( stlSubReports );
end;
end;


Here is how I create all my components.......

procedure TPendingStatementReport.CreatePSRDataComponents;
begin
FPSRsqlOPD := TSQLDataSet.Create( nil );
FPSRsqlOPD.SQLConnection := MIIBConnectionManager.GetDefaultConnection;

FPSRprvOPD := TDatasetProvider.Create( nil );
FPSRprvOPD.DataSet := FPSRsqlOPD;

FPSRcdsOPD := TClientDataSet.Create( nil );
FPSRcdsOPD.SetProvider( FPSRprvOPD );

FPSRdtsOPD := TDataSource.Create( nil );
FPSRdtsOPD.DataSet := FPSRcdsOPD;

FPSRpplOPD := TppDBPipeline.Create( nil );
FPSRpplOPD.DataSource := FPSRdtsOPD;


FPSRsqlOPAD := TSQLDataSet.Create( nil );
FPSRsqlOPAD.SQLConnection := MIIBConnectionManager.GetDefaultConnection;

FPSRprvOPAD := TDatasetProvider.Create( nil );
FPSRprvOPAD.DataSet := FPSRsqlOPAD;

FPSRcdsOPAD := TClientDataSet.Create( nil );
FPSRcdsOPAD.SetProvider( FPSRprvOPAD );

FPSRdtsOPAD := TDataSource.Create( nil );
FPSRdtsOPAD.DataSet := FPSRcdsOPAD;

FPSRpplOPAD := TppDBPipeline.Create( nil );
FPSRpplOPAD.DataSource := FPSRdtsOPAD;

FrptPendingStatements := TppReport.Create( nil );
FrptPendingStatements.OutlineSettings.Visible := False;
FrptPendingStatements.Template.OnLoadEnd := OnLoadEndHandler;
FrptPendingStatements.PreviewFormSettings.WindowState := wsMaximized;
FrptPendingStatements.PreviewFormSettings.ZoomSetting := zs100Percent;
end;

Comments

  • edited June 2006
    when I have problems like this I save the demo report to an ASCII file then
    save the one that isn't working to a different ASCII file (normally in the
    same directory as the first) and then run a comparison (BeyondCompoare does
    a nice job) to see what the difference is.

    HTH,
    Ed Dressel
    Team DM
  • edited June 2006
    Is saving as ASCII a new feature from version 7.04? When I go to save
    the report at design time .RTM is the only option.

    When I place a TppReport on a new form, put on the dataset components,
    open the report at design time, load the .RTM file, then run the program
    and print the report it works just fine.

    If I try to do the same thing at runtime with no form, it doesn't work.
    So I'm missing something somewhere along the lines.

    Do TppReports work without an Owner?
    Is this the proper way to assign pipelines to section subreports?

    stlSubReports := TStringList.Create;
    try
    FrptPendingStatements.GetSubReports( stlSubReports );
    TppSubReport(stlSubReports.Objects[0]).DataPipeline := FPSRpplOPD;
    TppSubReport(stlSubReports.Objects[1]).DataPipeline := FPSRpplOPAD;
    finally
    FreeAndNil( stlSubReports );
    end;



  • edited June 2006

    The Report, Labels, DBTexts, DataPipelines, Data Access components etc that
    you create need to reside in a common container - which in Delphi is
    specified by the Owner.

    Typically the Owner will be the Form/DataModule upon which the Report
    resides.

    Example:

    myReport := TppReport.Create(Self);

    myDBPipeline := TppDBPipeline.Create(Self);




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited June 2006

    - Report.Template.Format can be ftBinary or ftASCII (defined in ppTypes)

    - From the Delphi IDE, you can also put a Report on a Form, load an .rtm,
    and then select the option to view the form as text (I do this all the
    time).

    - You need a common Owner (do not use nil) - see my other reply to this
    thread






    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited June 2006
    So it would be hard to build a custom class that can load and print
    multiple RTM (files) and create the necessary data access components as
    needed, without the use of a form or datamodule?

  • edited June 2006

    - one approach would be for your custom class to descend from TComponent,
    then it can be the Owner

    - another approach would be to create a TDataModule instance for each report

    - ReportBuilder Professional and Enterprise Editions include the ability to
    visually design QueryDataViews - thus the data access components are saved
    as part of the report definition. RB Enterprise includes RAP, the run-time
    Pascal environment that enables event-handler code to be saved as part of
    the report definition also.






    Best regards,

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