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

Access Report.Parameters in a RAP passthrough function

edited November 2006 in RAP
Hi DM,

for compatibility issues i need a passthrough RAP function.

I missing something like this

procedure TCompatibiltyFunctionname.ExecuteFunction(aParams: TraParamList);
Var
MyParameterName : String;
begin
GetParamValue (0, myParameterName);
SetParamValue(1, aParams.WhoCalledMeReport.Parameters[myParameterName]);
end;

I have no idea how i can access the "WhoCalledMeReport". Can you help me?
Becaue i have a multithread environment global parameters a not really a
good choice.

It would be easier if you could show the raFunc.pas interface(!)-part.
(yes, ONLY the Interface - Part).

Working with rap (you have done a good job; nevertheless!) is sometimes like
poking in the fog. The RAP-Help is also in version 10 not very extensive.
;-) From your point of views everything seems clear, but from my side
(working now sine 1998 (i suppose :) ) with ReportBuilder) i still running
in documentation problems :).


Enterprise Evaluation 10.04 and Delphi 7.

Greetings
Sven Heuer

Comments

  • edited November 2006

    - You need to pass the Report as a parameter to the RAP function. (Just as
    you would need to pass the Report as a parameter to a stand alone function
    in Delphi).

    myFunc(aReport, aSecondParam);

    - TraParamList represents a list parameter values. Each parameter value is
    describe by a TraParamRec. TraParamList and TraParamRec are both defined in
    ppRTTI.pas (you have the source code to this unit).

    - The TraSystemFunction class represents a stand alone function. Here is the
    declaration of the TraSystemFunction class, which is the ancestor to all RAP
    pass thru-functions. If you would like the source code to the raFunc.pas
    unit, please send an email to support@digital-metaphors.com.


    TraSystemFunction = class(TraProgramCallValue)
    private
    FParamList: TraParamList;

    procedure BuildParamList;
    procedure CompileSignature(aProgram: TraProgram);
    procedure VariableToParam(aVariable: TraVariableValue);

    protected
    procedure GetParamValue(aIndex: Integer; var aValue);
    procedure SetParamValue(aIndex: Integer; var aValue);

    public
    constructor CreateFunction; virtual;
    destructor Destroy; override;

    procedure Build(aProgram: TraProgram; aToken: TraToken); override;

    function Execute: TraValue; override;

    function EditorText: String;

    class function Category: String; virtual; {abstract; removed for
    CBuilder support}
    class function GetSignature: String; virtual; {abstract; removed for
    CBuilder support}
    class function IsFunction: Boolean; virtual;
    class function HasParams: Boolean; virtual;
    class function GetEditorText: String;

    procedure ExecuteFunction(aParams: TraParamList); virtual; abstract;

    end; {class, TraSystemFunction}



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2006
    Thanks Nard for your fast answer,

    no other way like an additional parameter? This will break all my reports.
    uhhh.


    I think the update to 10 (from 7.04) means a lot of work for me :(

    Almost all reports are not running any more. They are all depening on the
    Global.OnCreate event. This event is now firing to early. I used this to set
    the autosearchvalue via RAP. I have the fear i can change all the reports
    manually.

    Diving into very cold water :)

    Greetings from germany
    Sven Heuer


  • edited November 2006

    - to provide a reference to the report, you might try creating a global
    singleton object or variable. Use the Report.Template.OnLoadend event in
    Delphi to initialize the report reference. Then in your RAP pass-thru
    functions access the global reference.

    - Please create a simple example report using RB 7.04 that demonstrates the
    issue you are encountering when migrating it to RB 10.04 and that we can run
    here. Email in zip format to support@digital-metaphors.com. We can run it
    here and take a look.

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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2006
    The way via a global variable seems the only way (in a highly multithreaded
    environment a little bit ugly :) ) Thx for the tip.

    That the report(s) does not run anymore seems to be a problem of an early
    bird :) Just to the beginning of RAP - life some of the events doesn't fire
    correctly. I had problems with the GetAutosearchvalue. The only event which
    was working was OnCreate (i know, that was wrong but working). In these old
    days the reports were designed and now running by my customers. And they
    have customized it.

    Today the events will do the job as designed but this breaks my reports. In
    the Global.OnCreate-handler i popuped an Delphi form for collecting some
    user data and use them to filter the db-data. I think i have to split this.
    Collecting the data and passing them to filter are now done in two events.

    Sven


  • edited November 2006

    - For a multi-threaded evnironment I would implement a global singleton list
    that tracks the report instance for each thread or each session.

    - Starting with RB 9 we introduced the Report.OnInitializeParameters event
    to enable parameter initialization and/or custom dialog to be shown. And we
    introduced the Report.BeforeOpenDataPipelines event to enable the SQL be
    modified via a new TdaSQLBuilder class. Prior to this, there was no good
    solution to implement this type of functionality from RAP.

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


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.