Is this possible with ReportBuilder?
Problem: I want to create a form wherein the user can select a report from a
list, preview the report, execute a dialog from the preview form from which
(i.e., the dialog) the user would specify a range of changes, then save the
changes and re-execute the print preview using the new report. The specific
changes are yet to be defined by the requirements, but an example would be
something similar to what is available in Quicken. Currently, .rtm files are
saved to a database and loaded at runtime.
Questions:
(1) Is it possible, at runtime, to have a user preview a selected report,
execute a dialog to select how the report would be modified, then
dynamically change and save the changes as a new .rtm and then reload the
changed/new .rtm into preview, again?
(2) If this is possible, is the range of changes to .rtm file limited and to
what extent? For example, can the report have data pipelines added, as well
as additional subreports?
(3) Is this capability specific to all version of ReportBuilder?
This discussion has been closed.
Comments
1. Yes, there is an AutoSearch feature in ReportBuilder that allows you to
bring up a dialog (custom if you want) and accept information from the user,
and regenerate the report based on that information. See the AutoSearch
demos located in the \RBuilder\Demos\5. AutoSearch\... directory.
2. If you have the Professional or Enterprise editions of ReportBuilder, it
has a complete end-user report explorer and designer included. This way you
can give your users complete access to the Report Designer where they can
create new datasets (using DADE), add event handlers and small methods
(using RAP) and design or alter existing templates using the designer. To
see the full end-user capabilities of ReportBuilder, see the end user demos
located in the \RBuilder\Demos\3. EndUser\... directory.
3. See the above answer. The end-user capabilities are available in the
Professional, Enterprise, and Server editions of ReportBuilder.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Are you familiar with such functionality in Intuit's Quicken? The user can
modify existing reports by selecting a range of options from a dialog and
save or "memorize" the report. I need to create similar report
functionality.
I am aware that the Report Designer is available to the end-user at runtime.
But, that is not what I need to do. The end-users do not want to design or
otherwise modify reports.
I need to design a custom dialog with a range of pre-defined options that
can be selected to change existing reports. Then based upon the selected
options, I need to change and save an existing .rtm as a new report. So, at
runtime, I am modifying an existing report and saving the changes to an.rtm.
I do not know how to persist changes to an existing .rtm, at runtime, such
as adding a subreport, associated Pipeline, and any necessary event code,
then saving .rtm under a new name. These requirements do not appear
possible, using ReportBuilder, to me and therefore this is the reason for my
post.
Sorry about the misunderstanding. It is definitely possible to create a
report dynamically in code at runtime based on options you give your users
in a dialog. You would first need to load your report template into a
TppReport object, then using the dialog you give you users add new report
components or change the existing report components using a report object
loop. The article below should get you started. If you have any questions
about dynamically creating or altering any report components, I will be more
than happy to help.
---------------------------------------------
Tech Tip: Create Reports in Code
---------------------------------------------
A ReportBuilder report is composed of a set of components. Like other
standard Delphi components, the components which make up the report layout
have a run-time interface. That is they can be created and configured using
Object Pascal code.
A complete example of creating a report entirely in code is contained in the
Developers Guide.
The Developers Guide is located in the ..\RBuilder\Developers Guide\
directory.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Let me make sure that I have got this.
After I load a template into the report component, then I can add components
in code, etc. Thereafter, I just, for example, just do:
{ save template using a new name}
TppReport.Template.Name := "New Report Name";
{ save template to database }
TppReport.Template.SaveToDatabase;
{ done}
Is that about the size of it?
It doesn't seem possible to me, but would there be a way to add events and
associated code to a template, at runtime?
Yes, that's about it. You will need to define the Template.DataBaseSettings
properties before your template will be saved to database successfully.
You can add code specifically to a report template using RAP. RAP (Report
Application Pascal) is available with the Enterprise edition of
ReportBuilder and is more or less a built in Pascal-style language and
compiler in ReportBuilder that gets JIT compiled and executed when the
report is printed. It is a very elegant way to keep your templates
completely portable.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
But isn't RAP only available using via the user interface, either at
run-time or at design-time, within the Enterprise-edition? That is, how
would I access or otherwise use RAP in conjunction with Object Pascal (i.e.,
Delphi) at runtime? Just to refresh, I will be providing a dialog interface
for the user to select options that will be the basis of modification of a
given template, at runtime. Modification of the template made require event
code. So, how will RAP be accessed or otherwise used in this kind of
configuration?
Sorry, I'm still getting a feel for what you are trying to do.
No, it is possible to edit and add RAP code in Delphi code, however this
sort of defeates the purpost of RAP, which is to keep all report code local
to the template. If you want to add code to a report on the fly at run
time, you could also do this in normal Delphi code after the template has
been loaded using the template event OnLoadEnd. Below is an article on
accessing the Report Template events.
----------------------------------------------
Tech Tip: Using Template Events
----------------------------------------------
The Report.Template object has several events that can be used for
customizing what happens when a report is loaded or saved:
- OnLoadStart
- OnLoadEnd
- OnNew
- OnSaveStart
- OnSaveEnd
The OnLoadEnd and OnNew events are often used to perform actions related to
report and data initialization.
The OnSaveEnd event is often used to save additional descriptive ("meta")
data to the database each time the report is saved.
Example:
The Report.Template events are public and therefore must be assigned at
run-time.
1. In the private section of your form declaration you can declare an
event-handler method:
TForm = class(TForm)
private
procedure myTemplateOnLoadEndEvent(Sender: TObject);
public
end;
2. In the Form.OnCreate event, you can assign the event-handler to the
event:
procedure TForm1.FormCreate(Sender: TObject);
begin
ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;
end;
3. Implement the event-handler method:
procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
begin
{add code here to initial the report or data, etc. }
ppReport1.PrinterSetup.MarginTop := 0.5;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for your persistence in helping me understand.
I think there is a solution here.
I was not sure how RAP could figure in here, if at all. If I understand
correctly, any code to configure changes to templates at runtime, assuming
my configuration of having a dialog available to the user for this, must be
Delphi code. So, there is no way to otherwise incorporate that code as part
of the template (i.e., as part of RAP).
Further, if my understanding is correct, RAP is code that is part of the
template but must be added via the RAP interface within the Enterprise IDE -
correct? Therefore, the two solutions are mutually exclusive and there is no
possible communication between Delphi code and RAP code, at runtime - at
least with respect to the Delphi code modifying the RAP code - correct?
Yes, what you mention below is what RAP was intended to do. However, as you
probably well know, there is always an exception to every rule in our
profession. It is possible to access RAP code from Delphi. See the
following example on editing RAP code in Delphi.
www.digital-metaphors.com/tips/RAPModifyPrograms.zip
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com