Assigning an array to a JITPipeline
Hi,
A newbie here, using string arrays instead of TStringList (sorry, I'm
an old DOS programmer not totally OPP savvy).
I've just created my first report using a JITPipeline as a subreport
that is dynamically created for each master record. I create 4 string
arrays (based on logical fields within the master record doing data
lookups to a third database which contains the printable string). I
got the report to work fine by converting my arrays to TStringLists
following the demo example, but I'd like to eliminate this extra code.
Lets say one array is T1Names[n] and the logic to fill-in the values
exists in a datamodule and is used on other sections of the program.
By trial and error I determined that the JITPipeline needed the record
count prior to calling the RB Print, so I do in the FormCreate:
T1List := TStringList.Create;
for i := 1 to 5 do begin {empty out the arrays}
T1Names[i] := ' ';
.......
populateLists;
ppJITPipeline1.RecordCount := 5;
In ppDetailBand1BeforeGenerate I do:
MaxNames := 0;
dmod.Build_Name_Arrays(recnum,MaxNames);
populatelists;
ppJITPipeline1.RecordCount := MaxNames;
In PopulateLists I do:
T1List.Clear;
for n := 1 to 5 do begin
T1List.Add(T1Names[n]);
In MyGetFieldValue I do:
if (lsFieldName = 'JITPipeline1ppField1') then
lList := T1List
Now how can I eliminate T1List.Add logic and assign the array
T1Names directly to the JITPipeline field?
Thanks, Marie
A newbie here, using string arrays instead of TStringList (sorry, I'm
an old DOS programmer not totally OPP savvy).
I've just created my first report using a JITPipeline as a subreport
that is dynamically created for each master record. I create 4 string
arrays (based on logical fields within the master record doing data
lookups to a third database which contains the printable string). I
got the report to work fine by converting my arrays to TStringLists
following the demo example, but I'd like to eliminate this extra code.
Lets say one array is T1Names[n] and the logic to fill-in the values
exists in a datamodule and is used on other sections of the program.
By trial and error I determined that the JITPipeline needed the record
count prior to calling the RB Print, so I do in the FormCreate:
T1List := TStringList.Create;
for i := 1 to 5 do begin {empty out the arrays}
T1Names[i] := ' ';
.......
populateLists;
ppJITPipeline1.RecordCount := 5;
In ppDetailBand1BeforeGenerate I do:
MaxNames := 0;
dmod.Build_Name_Arrays(recnum,MaxNames);
populatelists;
ppJITPipeline1.RecordCount := MaxNames;
In PopulateLists I do:
T1List.Clear;
for n := 1 to 5 do begin
T1List.Add(T1Names[n]);
In MyGetFieldValue I do:
if (lsFieldName = 'JITPipeline1ppField1') then
lList := T1List
Now how can I eliminate T1List.Add logic and assign the array
T1Names directly to the JITPipeline field?
Thanks, Marie
This discussion has been closed.
Comments
You do not want to populate your arrays inside the DetailBand.BeforPrint
event. This is not the way Pipeline Linking works in ReportBuilder (as
opposed to using parameterized queries in Delphi). Please see the articles
below for more help on how the JITPipeline archececture works in
ReportBuilder.
----------------------------------------------------
Tech Tip: Use Master/Detail JITPipelines
----------------------------------------------------
To use Master/Detail relationship with the JITPipeline:
1. Check out the demo dm0139 in the main demo reports app
for an example.
2. Make sure you have the Detail JITPipeline.MasterFieldLinks
defined to specify the relationship. In dm0139 the detailed it
linked to the master using the CustNo field from each pipeline.
3. Once you have things setup like the above, then you will need
to connect the Report.DataPipeline property to the master JITPipeline
and the SubReport.DataPipeline property to the detail JITPipeline.
4. In the FormCreate event set each JITPipeline.RecordCount
property to the total number of records for each.
You should not need to reset anything.
6. ReportBuilder expects the data in the detail dataset
to be in sorted order of the field links.
In dm0139, the linked field is the CustNo, therefore
the detail data must be order like this:
CustNo OrderNo
------ -------
1 001
1 002
1 003
2 010
2 009
2 005
----------------------------------------------------
Tech Tip: Manual Master/Detail JITPipelines
----------------------------------------------------
In some applications, you may want to implement a master/detail JITPipeline
relationship in which you programmtically control the detail data that is
available for each master record.
1. Create two JITPipelines and implement the OnGetFieldValue event in the
standard way.
2. For the detail JITPipeline, leave the MasterDataPipeline and
MasterFieldLinks properties unassigned.
3. For the master JITPipeline, use the OnRecordPositionChange event to
initialize the detail JITPipeline:
myJITDetail.Close;
myJITDetail.RecordCount := {get detail record count}
myJITDetail.Open;
--
Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
Delphi Informant Readers Choice awards!
http://www.delphizine.com/ballot2004/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks. I'll look at your suggestions but I'm not using the
BeforePrint event, I'm using the BeforeGenerate event. I'm also not
using the Master/Detail Links. Everything works fine, for 2 test
records at least, but I'll have to add more data to see if it holds.
In any case, how do I eliminate assigning the arrays to TStringLists
and then to the JITPipeline. I'd like to be able to assign the arrays
directly to the JITPipeline, something like
JITPipeline1ppField1 := T1Names where T1Names is a string array.
Marie
Sorry I confused you in the last post. If this is simply a matter of
traversing data in an array of String using a JITPipeline, all you need to
do is assign the Result value of the GetFieldValue event to
Array[JITPipeline.RecordIndex]. Below is a link to a quick example I just
created for you showing this in action.
http://www.digital-metaphors.com/tips/JITPipelineWithArray.zip
Moving back to my last post. The fact that you are calling the
dmod.Build_Name_Arrays(recnum,MaxNames) method inside the
DetailBand.BeforeGenerate event (sorry typo last post) indicates that you
are populating an array for each master record, similar to the way Delphi
parameterized queries work. Changing this was simply a recommendation but
hey, if it works, no reason to fix it . Let me know if you have any more
questions.
--
Thanks for supporting ReportBuilder! Please vote for ReportBuilder in the
Delphi Informant Readers Choice awards!
http://www.delphizine.com/ballot2004/
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
As I said before, I'm not very good at OOP stuff. I know just enough
to most of the time to get things to work, but probably not very
efficiently. And yes, I am populating the array for each master
record mainly because not every master record would have the same
number of detail lines. I'll study your suggestions to see if they
would work better.
Marie