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

How can i assign TppDBPipeline MasterFieldLinks by code?

edited October 2004 in General
Hi,

How can i assign ADetailPipeline (TppDBPipeline) MasterFieldLinks (Joined
fields between master and detail) by code?

Greetings,
Filip Moons

Comments

  • edited October 2004
    Hi Filip,

    ---------------------------------------------------------
    Tech Tip: Define Master/Detail DataPipeline Links in Code
    ---------------------------------------------------------

    Defining a Master/Detail relationship for a DataPipeline
    requires that the detail pipeline have the
    following properties defined:

    1. MasterDataPipeline

    2. MasterFieldLinks


    At Delphi design-time you can use the object inspector
    and the DataPipeline's FieldLinks editor to define
    the master/detail relationship.


    The following example illustrates how to define the
    master/detail relationship dynamically at run-time.


    var
    lFieldLink: TppMasterFieldLink;


    begin

    {define the master/detail pipeline relationship}
    plDetail.MasterDataPipeline := plMaster;

    {create a new field link }
    lFieldLink := TppMasterFieldLink.Create(nil);

    lFieldLink.Parent := plDetail;

    {assign the detail field name}
    lFieldLink.DetailFieldName := 'CustNo';

    {assign the master field name}
    lFieldLink.MasterFieldName := 'CustNo';


    end;


    Note: The DataPipeline linking requires the records in the detail dataset to
    be ordered by the linking fields. In the above example, the detail data must
    be ordered by CustNo.



    --
    Regards,

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

    Best Regards,

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

    -How do I delete/clear existing Master/Detail DataPipeline Links at Runtime?
    -Do I have to free the Master/Detail DataPipeline Links when i'm done using
    them or will they be freed automatically by setting the 'FieldLink.Parent'?

    Greetings and thx for your always swift response,
    Filip

  • edited October 2004
    Hi Filip,

    1. You can either just re-assign the links if you need to change them, or
    assign them to nil to clear them out.

    2. Yes, you will need to free the FieldLink.

    --
    Regards,

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

    Best Regards,

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

    Sorry for bothering u again, but i'm still a bit unclear bout the clearing
    and freeing the MasterFieldLinks.
    I have 4 pipelines whichs MasterFieldLinks need to setup at runtime
    depending on what sorting the user wants. Each pipeline needs to get several
    MasterFieldLinks added, again depending on what sorting the user wants. How
    do i delete and free MasterFieldLinks when printing is done? Could u please
    give me a example, i don't find anything bout TppMasterFieldLink in the
    online help. Do i iterate the forms componentcount and freeandnil all
    TppMasterFieldLink class objects from the form?

    Thx,
    Filip Moons

    procedure TLEX33100F.BuildMasterFieldLinks;

    procedure AddFieldLink(APipeLine: TppDBPipeline;
    AMasterFieldName,ADetailFieldName: string);
    var
    AFieldLink: TppMasterFieldLink;
    begin
    // Create a new FieldLink
    AFieldLink := TppMasterFieldLink.Create(nil);
    // Assign the FieldLink Parent
    AFieldLink.Parent := APipeLine;
    // Assign the FieldLink MasterFieldName
    AFieldLink.MasterFieldName := AMasterFieldName;
    // Assign the FieldLink DetailFieldName
    AFieldLink.DetailFieldName := ADetailFieldName;
    end; {AddFieldLink}

    begin
    // Toewijzen MasterFieldLinks Dagboek
    if cbTotDGB.ItemIndex = 0 then
    begin
    AddFieldLink(ppLYACT_TOT_DGB,'LYDCDGB','LYDCDGB');
    if cbTotJR.ItemIndex = 0 then
    AddFieldLink(ppLYACT_TOT_JR,'LYDCDGB','LYDCDGB');
    if cbTotKW.ItemIndex = 0 then
    AddFieldLink(ppLYACT_TOT_KW,'LYDCDGB','LYDCDGB');
    if cbTotMND.ItemIndex = 0 then
    AddFieldLink(ppLYACT_TOT_MND,'LYDCDGB','LYDCDGB');
    end;

    // Toewijzen MasterFieldLinks Jaar
    if cbTotJR.ItemIndex = 0 then
    begin
    AddFieldLink(ppLYACT_TOT_JR,'LYDCYEAR','LYDCYEAR');
    if cbTotKW.ItemIndex = 0 then
    AddFieldLink(ppLYACT_TOT_KW,'LYDCYEAR','LYDCYEAR');
    if cbTotMND.ItemIndex = 0 then
    AddFieldLink(ppLYACT_TOT_MND,'LYDCYEAR','LYDCYEAR');
    if cbTotDGB.ItemIndex <> 0 then
    AddFieldLink(ppLYACT_TOT_DGB,'LYDCYEAR','LYDCYEAR');
    end;

    // Toewijzen MasterFieldLinks Kwartaal
    if cbTotKW.ItemIndex = 0 then
    begin
    AddFieldLink(ppLYACT_TOT_KW,'LYDCKWART','LYDCKWART');
    if cbTotMND.ItemIndex = 0 then
    AddFieldLink(ppLYACT_TOT_MND,'LYDCKWART','LYDCKWART');
    if cbTotDGB.ItemIndex <> 0 then
    AddFieldLink(ppLYACT_TOT_DGB,'LYDCKWART','LYDCKWART');
    end;

    // Toewijzen MasterFieldLinks Maand
    if cbTotKW.ItemIndex = 0 then
    begin
    AddFieldLink(ppLYACT_TOT_MND,'LYDCMONTH','LYDCMONTH');
    if cbTotDGB.ItemIndex <> 0 then
    AddFieldLink(ppLYACT_TOT_DGB,'LYDCMONTH','LYDCMONTH');
    end;

    // Toewijzen MasterFieldLinks Dagboek
    if cbTotDGB.ItemIndex <> 0 then
    AddFieldLink(ppLYACT_TOT_DGB,'LYDCDGB','LYDCDGB');
    end; {BuildMasterFieldLinks}


  • edited October 2004
    Hi Filip,

    You will need to keep track of all the field links you create and free them
    accordingly as you need to clear them. ReportBuilder creates a TList
    component to hold all the links that are created and then iterates through
    the list to free each link when they need to be destroyed.

    --
    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.