New Blog Post: PDF/A and Metadata

How to Set Global Variables using TppReportExplorer

edited January 2014 in End User
I have users who need to set a date for a report to be used in
calcuations. Right now the calcuations use the CurrentDate, but the
end users want to be able to specify a date to be used as if the report
was run on that date. Let's call it ReportRunDate. The date is used
to calculate aging on accounts, balances due as of that date, and also
to calculate inventory depreciation.

What is the best approach when using the TppReportExplorer? What is
the proper syntax?


--

Comments

  • edited January 2014
    On 25/01/2014 19:11, David Miller wrote:

    I would normally write a RAP passthru class for this implement a
    PromptForUserDate() function and have the aforesaid function invoke your
    custom form with date control.
  • edited January 2014
    Paul Toms wrote:

    That seems a little clunky. I was hoping to do the whole thing inside
    ReportBuilder.

    I am thinking about using a single record table with some dummy fields
    so that I can use the autosearch with a parameter and then grab the
    date from the parameter using RAP. I was just hoping for a more
    elegant solution.


    --
  • edited January 2014
    On 28/01/2014 16:57, David Miller wrote:

    I know what you mean, but its only 10 minutes work (or less if you've
    done it before) and....


    ...that's very clunky! :)
  • edited January 2014
    Paul Toms wrote:

    LOL. Well, it would keep it so there is only one popup form when
    running the report.

    I've been thinking more about your suggestion and may add it to my
    existing passthroughs as an option. Can you give some more details
    about how you do it?

    Do you call the function in the OnInitializeParameters event? Does it
    wait for the function calling the form to close the form before
    proceeding?

    --
  • edited January 2014
    On 30/01/2014 15:55, David Miller wrote:

    Here you go (completely untested and just knocked up in notepad). I
    would call it in the reports OnCreate event in RAP but you could try it
    where you said.


    uses
    classes,
    SysUtils,
    raFunc,
    ppRTTI,
    ppUtils,
    ppClass,
    ppTypes,
    ....

    TDaveMillerFunctions = class(TraSystemFunction)
    public
    class function Category : String; override;
    end;

    class function TDaveMillerFunctions.Category : String;
    begin
    Result := 'Dave Miller Functions';
    end;


    TppDatePrompt = class(TDaveMillerFunctions)
    public
    procedure ExecuteFunction(aParams : TraParamList); override;
    class function GetSignature : String; override;
    class function HasParams : Boolean; override;
    class function IsFunction : Boolean; override;
    end;


    procedure TppDatePrompt.ExecuteFunction(aParams: TraParamList);
    var lResult : TDateTime;
    begin

    With TmyDateForm.create(nil) do
    begin
    Showmodal;
    lResult := DateControl.Date;
    Free;
    end;

    SetParamValue(0, lResult);
    end;

    class function TppDatePrompt.GetSignature: String;
    begin
    result := 'function ShowDatePrompt : TDateTime;';
    end;

    class function TppDatePrompt.HasParams: Boolean;
    begin
    result := False;
    end;

    class function TppDatePrompt.IsFunction: Boolean;
    begin
    result := True;
    end;

    Initialization

    raRegisterFunction('ShowDatePrompt', TppDatePrompt);

    Finalization

    raUnRegisterFunction('ShowDatePrompt');
This discussion has been closed.