Set TextFileName with dynamic report data
Hi,
Is it possible to set TextFileName with data from the report in RAP?
The problem is that I want to generate an rtf file, eg a quotation, and name
it '1234 - PeopleSoft.rtf' where 1234 is some quotation identifier and
PeopleSoft is the customer name. This data is retrieved by DADE, but I can't
find an event after retrieving data from the database but before creating
the rtf file.
Using RB11.08
Kind regards,
Jeroen R?ttink
Is it possible to set TextFileName with data from the report in RAP?
The problem is that I want to generate an rtf file, eg a quotation, and name
it '1234 - PeopleSoft.rtf' where 1234 is some quotation identifier and
PeopleSoft is the customer name. This data is retrieved by DADE, but I can't
find an event after retrieving data from the database but before creating
the rtf file.
Using RB11.08
Kind regards,
Jeroen R?ttink
This discussion has been closed.
Comments
The TextFileName property is used much too early to be altered in RAP after
the pipelines have been loaded. The only workaround is to access the
FileDevice.FileName property directly (using a passthu function) perhaps
inside the BeforePrint event.
I will see about adding some of the FileDevice properties to the RAP RTTI
for a future release of ReportBuilder so there is no need for a passthru.
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
That would be great. I now use OnInitializeParameters to set TextFileName.
This can only be used to set it to some static text and add some date
information. I have been playing with the idea to execute some sql by a
passthru function and use the result in the OnInitializeParameters to set
TextFileName.
Is DADE executing its queries before a file name is needed by the report
engine?
Kind regards,
Jeroen.
No. The TextFileName is passed on to the file device before any data is
retrieved but is not used until actual data has been received and report
pages generated. This is simply the order in which the Producer handles
this property.
I believe your idea of accessing the data via Passthru before Dade does (in
the OnInitializeParameters) would work as well.
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
"Jeroen Rottink" wrote in message news:4d38a0db$1@mail....
Hi Nico,
That would be great. I now use OnInitializeParameters to set TextFileName.
This can only be used to set it to some static text and add some date
information. I have been playing with the idea to execute some sql by a
passthru function and use the result in the OnInitializeParameters to set
TextFileName.
Is DADE executing its queries before a file name is needed by the report
engine?
Kind regards,
Jeroen.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I went playing with your idea to use BeforePrint but it does not seem to
work.
I also tested AfterOpenDataPipelines but they are both fired to late. A file
is already created at that time using my default TextFileName.
It seems the internal TppProducer.FPrinting property is already set when
calling AfterOpenDataPipelines.
I use the following Passthru code:
procedure TRapSetOutputFileName.ExecuteFunction(aParams: TraParamList);
var lReport: TppReport;
lFilename: string;
begin
GetParamValue(0, lReport);
GetParamValue(1, lFilename);
if Assigned(lReport)
then begin
// first exchange filename in the current path/filename
lFilename := ExchangeFileName(lReport.TextFileName, lFilename);
// setting TppReport.TextFileName is enough when called from
// OnInitializeParameters()
lReport.TextFileName := lFileName;
// other TextFileName properties need to be set when called from
// AfterOpenDataPipelines() or BeforePrint() DOESNT WORK
if Assigned(lReport.PrintDialog)
then lReport.PrintDialog.TextFileName := lFileName;
if Assigned(lReport.FileDevice)
then lReport.FileDevice.FileName := lFileName;
end;
end;
I'm sorry, I had only tested it with Delphi code and assumed RAP functioned
the same. I forgot that the BeforePrint event fires at a slightly different
time than in Delphi.
A better event to use would be the OnFileDeviceCreate. This will give you
no control over the print dialog however. You may need to create a
different passthru to change the file name of that dialog if you are using
it.
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
"Jeroen Rottink" wrote in message news:4d3d593d$1@mail....
Hi Nico,
I went playing with your idea to use BeforePrint but it does not seem to
work.
I also tested AfterOpenDataPipelines but they are both fired to late. A file
is already created at that time using my default TextFileName.
It seems the internal TppProducer.FPrinting property is already set when
calling AfterOpenDataPipelines.
I use the following Passthru code:
procedure TRapSetOutputFileName.ExecuteFunction(aParams: TraParamList);
var lReport: TppReport;
lFilename: string;
begin
GetParamValue(0, lReport);
GetParamValue(1, lFilename);
if Assigned(lReport)
then begin
// first exchange filename in the current path/filename
lFilename := ExchangeFileName(lReport.TextFileName, lFilename);
// setting TppReport.TextFileName is enough when called from
// OnInitializeParameters()
lReport.TextFileName := lFileName;
// other TextFileName properties need to be set when called from
// AfterOpenDataPipelines() or BeforePrint() DOESNT WORK
if Assigned(lReport.PrintDialog)
then lReport.PrintDialog.TextFileName := lFileName;
if Assigned(lReport.FileDevice)
then lReport.FileDevice.FileName := lFileName;
end;
end;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Just tested but the data I read from the dataview seems empty or closed.
The file that is created is called 'Zincoat - wk4 - inkoopnr 0.pdf'.
procedure ReportOnFileDeviceCreate;
var Filename: string;
begin
Filename := 'Zincoat - wk' + IntToStr(GetWeek(CurrentDate));
Filename := Filename + ' - inkoopnr ' + INKOOPORDER['INKOOPNR'];
SetOutputFileName(Report, Filename);
end;
Regards,
Jeroen.
AfterOpenDatapipelines fires too late. It looks like you will need to
manually open the pipeline/dataset and retrieve the file name.
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
"Jeroen Rottink" wrote in message news:4d3df72c$1@mail....
Hi Nico,
Just tested but the data I read from the dataview seems empty or closed.
The file that is created is called 'Zincoat - wk4 - inkoopnr 0.pdf'.
procedure ReportOnFileDeviceCreate;
var Filename: string;
begin
Filename := 'Zincoat - wk' + IntToStr(GetWeek(CurrentDate));
Filename := Filename + ' - inkoopnr ' + INKOOPORDER['INKOOPNR'];
SetOutputFileName(Report, Filename);
end;
Regards,
Jeroen.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com