How to pass parameters from report to dataport?

Aravindh_NavisionAravindh_Navision Member Posts: 258
Hi Friends,

I have designed 3 dataports: Dataport-A, Dataport-B, Dataport-C and a report: Report-A.

From report, I am running these 3 dataports. My requirement is, I need to give FromDate and ToDate in request form of Report-A. In these data range, I need to extract data through dataports Dataport-A, Dataport-B, Dataport-C.

It is passing the date parameters (FromDate; ToDate) from Report-A to the dataports Dataport-A, Dataport-B, Dataport-C to filter the records. Can anyone tell me how to pass parameters from report (request form) to dataport?

Thanks in advance.
Aarvi

Comments

  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    Hi,
    1. Create in each dataport 2 global variables: FromDate , ToDate
    2. Create in each dataport a function with two parameters, and assign the values of these parameters to the global variables
    3. In the report, before executing the dataport, call the function in that dataport [you need to define a variable of type Dataport to be able to do this]
    Jan Veenendaal
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Thank you Jan for your reply.

    I could not able to understand the point no 3. Can you please explain in detail?
  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    Hi,

    Let's assume the function you created is called PassDateFilter.
    In your report, create a (global) variable for each or the dataports:
    variable 1: name=DpA, type=Dataport, Subtype=Dataport-A
    variable 2: name=DpB, type=Dataport, Subtype=Dataport-B
    variable 3: name=DpC, type=Dataport, Subtype=Dataport-C

    In the code where you want to execute the dataports, write:

    DpA.PassDateFilter(FromDate,ToDate);
    DpA.RUN; // or DpA.EXPORT;
    DpB.PassDateFilter(FromDate,ToDate);
    DpB.RUN;
    DpC.PassDateFilter(FromDate,ToDate);
    DpC.RUN;

    I hope this helps?
    Jan.


    P.S.: Of course, regarding my first post, you also need to write code in the dataports to apply the data filter
    Jan Veenendaal
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Thanks Jan, It worked..!

    One more doubt. How can I get the FromDate and Todate values in OnPreDataItem() from the function in dataport?
  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    1. You created 2 global variables in the dataport, called ToDate and FromDate.
    2. You created a function PassdateFilter(FromDatePar, ToDatePar) with a body that should look something like:
    BEGIN
    FromDate := FromDatePar;
    ToDate :=ToDatePar;
    END;

    3. You can use the variables FromDate and ToDate in any trigger in the dataport. Since you will call the function before running the dataport, the variables should have the value that you entered in the request form of your report.

    Jan
    Jan Veenendaal
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Thanks Jan, It worked perfectly.. :thumbsup:

    Did a silly mistake in assigning record variables. :roll:
  • Jan_VeenendaalJan_Veenendaal Member Posts: 206
    I have written code with a few :bug: :bug: sometimes, too :shock:
    Jan Veenendaal
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.