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

JIT Pipeline Fields created @ runtime

edited September 2008 in End User
Hello all,
I am running Delphi 7 and RB 10.06. I have a JIT pipeline that has no
fields at design time for which I am dynamically creating the fields at
runtime by creating a TppField and calling the AddField method of the JIT
pipeline. I am loading a template from the DB and using a ppDesigner
component to invoke the report designer for the end user. Everything works
fine with the fields in the report, they appear as options for the data
aware components and also appear as fields of the pipeline in the calc tab
to the right of the coding area. My problem is that if a user attempts to
drag a field from that right pane into the coding area of the Calc tab, an
access violation is raised:

Type : EAccessViolation
Message : Access violation at address 0086F631 in module 'MyApp.exe'. Read
of address 00000000.

The call Stack traces back to:
ppTB2Hook.pas Get Message Hook Line 129[9]
ppPopupMenus.pas TppVariablePopupMenu CalculationsMenuClick
1610[16]
ppTB2Item.pas TppTBCustomItem Click Line 1468[22]
ppTB2Item.pas TppTBCustomItem ClicnWndProc Line 1418[27]

If I type the calculation out as if I had done the drag and drop of the
field it works great. Something just seems to be broken when the fields are
dragged into the calculation code.

Thanks All,
Branden Johnson

Comments

  • edited September 2008
    Hi Branden,

    Try updating your version of ReportBuilder to the latest (10.09) and test
    with that. If you are still able to recreate the problem, please send me
    the exact steps I can take here to see it on my machine.

    Email info@digital-metaphors.com with your serial number and purchasing
    email address for upgrading instructions.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2008
    I upgraded to 10.09 and am still having the same issue and have found
    another.

    To setup a test app:

    Start a new project and add TppReport, TppJITPipeline, and TppDesigner
    components to the main form.

    Set the desiner to use the report and the report to use the jit pipeline.

    Add ppTypes and raIDE to the Uses clause.

    Add a button to the form and the following code to the OnClick event:

    procedure TForm1.Button1Click(Sender: TObject);
    var
    plField: TppField;
    begin
    //Create Field and add to JIT Pipeline
    plField := TppField.Create(Self);
    with plField do
    begin
    FieldName := 'DN_Field1';
    FieldAlias := 'DN_Field1';
    DataType := dtString;
    DisplayWidth := 50;
    end;

    ppJITPipeline1.AddField(plField);
    Application.ProcessMessages;

    //Show Report Designer
    ppDesigner1.ShowModal;
    end;

    Problem #1:
    If you drag the field from the DataTree on the design tab onto the detail
    band the TppLabel and TppDBText components are created and look correct but
    if you click the DBText component you'll notice that the pipeline component
    is not assigned. Assigning it fixes this but that us a bit arduous for
    clients to have to remember.

    Problem #2:
    If you go into the Calc tab and drag the field from the Data tab of the
    Code Toolbox into the coding area on any event you will get an access
    violation each time you attempt it and then one when closing the
    application.

    NOTE: This does not happen if the Fields are added to the JITPipeline at
    design time. Only when they are created at runtime. It is like a
    registration process of sorts is being skipped?

    Thank you,
    Branden













  • edited September 2008

    1. Simplest way to dynamically add fields is to call the
    DataPipeline.DefineField method. For an example, see demo 135 in the main
    reports demo app.

    The declaration of the DefineField method looks like this

    function DefineField(aFieldName: String; aDataType: TppDataType;
    aFieldLength: Integer): Integer;

    Example:

    uses
    ppTypes;

    myJITPipeline.DefineField('Company', dtString, 30);

    2. The other approach is similar to what you are doing now, but do /not/
    call the AddField method. Instead set the Field.DataPipeline property. This
    establishes the proper parent/child relationship. I think that will fix the
    errors you are encountering.

    Example:

    myField.DataPipeline := myJITPipeline

    I think all the composites in RB uses this same pattern. For example if you
    want to add a Label to a Band,

    myLabel.Band := myReport.Detailband;


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2008
    That took care of it.

    Thank you guys,
    Branden

This discussion has been closed.