I’m trying to make a report scheduler and it’s working fine, except for one thing. I can’t send a filter to the second dataitem in a report. When i set the filter for the first dataitem in a report I use SETTABLEVIEW(Rec), but to set a filter on the second dataitem i have to send Rec to a function in the report. That works fine and I use COPYFILTERS(Rec) to apply the filter on my dataitem. When I debug my code I can see that the filter is set. But while running my report, the filter disappears after the trigger OnOpenForm. I have set all the Save-properties (SaveTableView etc…) on the report to NO. The report I’m trying to run is 295 Combine Shipment. Can someone please help me /Magnus
Could you not pass a record to a function then load the filters into variables then use them in PreDataItem to filter by? It will restrict the number of filters. David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk
My report schedular is a report list that saves the users filters and makes it possible to define the printorder of the reports. First you choose a report, then you define the filters in the report. When the user wants to define the filters, I run the report so the user can set filters, but I exit in OnPreReport. From the Report List you can run the report in two different ways, Filtermode or Normal. This is what happens Filtermode: 1. Set filters from Report List table on Report 2. Run Report in “Filter mode” 3. Exit Report in OnPreReport 4. Get filters set in Report 5. Save filters in Report List table. Normal: 1. Set filters from Report List table on Report 2. Run Report modal
As David told… send the filters first to a function… but keep them on a variable of the report and use them on for setting the filters on the second dataitem’s onpredataitem section. You can also use another variable for having the filters passed saved instead of just saving them in a text variable (by using the copy function) That would be the way: On your calling code: var myreport : report(myreportType); myOtherVariable : Record (secondDataitemType); begin … CLEAR(myreport); myreport.SETTABLEVIEW(Rec); //that’s how you got now… myotherVariable.SETFILTERS(myfilters); myreport.SetMyFilters(myotherVariable); // you’ll call the new function myreport.RUN… … On your report code: var MySavedFilteredVariable : Record (secondDataitemType); Procedure SetMyFilters (VAR mytargetvariable : record (secondDataitemtype)) begin CLEAR(MySavedFilteredVariable); MySavedFilteredVariable.COPY (myTargetVariable); // that should copy also the filters… end; SecondDataItem.OnPreDataItem SecondDataItem.COPYFILTERS(MySavedFilteredVariable); … Hope that helps you. – Alfonso Pertierra apertierra@teleline.es Spain
So far I had the opportunity twice in my life as Navision Programmer to develop a report scheduler. There are some obstacles to be aware of … but let’s start from the beginning. What I wanted to achieve (and think you have the same needs) is a possibility to start several reports - one after the other - by one single mouse-click, the filters already prepared. My approach was based on the following assumptions: * Different users might have their individual lists of reports they want to schedule * All filters needed for the reports are fixed except for the date-filter My first customer for example had to send the same kind of reports every month to his headquarter. Such as:
- Open vendor list
- Open customer list
- trial balance for cost center 1000
- trial balance for cost center 1100
- trial balance for cost center 1200
- purchase statistics
etc. This means that the report scheduler should be able to handle different reports and of course keep track of the different filters applied to each report. Now let’s get into details: First Step: First I set up two tables: “Report Scheduler Header” (rsHeader) and “Report Scheduler Lines” (rsLines). Put together on a form it looks quite similar to the “General Journal” with the exception that a global Variable for GlobalDateFilter will be added (more about that later). The rsHeader contains a template name and username, rsLines containes the primary key of rsHeader, line-No., report-number of the report to be executed as well as all possible filters. (where possible means "all possible filters in all automateable reports). The only filter which is NOT stored in the rsLines are the Datefilter as this filter is usually the only one which is not static and changes every time the report-scheduler is being executed. Instead I applied a Date-Option field, which calculates the date-filter(s) used for the called report according to the actual date (= a global variable which is set in the rsHeader). Examples: Current Period 1.1.2001 … 28.2.2001 Date-Option —> sets filter option::period → 010101…280201 option::untilEnd → …280201 option::quarter → 010101…310301 option::lastweek → 210201…280201 etc. This list is not complete but it might give an idea. Second Step: Every report which should be called needs some preparation: 1) Every report requires two functions SetParameters(rsLines) and GetParameters(Var: rsLines). These functions maintain the interface (as correctly mentioned by Alfonso and David) between the Report Scheduler and the report. 2) And this is important: The property SaveValues must be set to no in the Request form. Otherwise … Quote:
quote:
. But while running my report, the filter disappears after the trigger OnOpenForm.
Third step Depending on the kind of reports you want to schedule, the rsLine table will contain lots of filters and for the end-user it’s quite difficult to determine which filter is used for which report. For example the customerNo. makes sense in the “Open Customer” report but is useless in the trial balance. In order to make life easier for the end-user I provide two modes (= buttons) on the Scheduler form: “Start” which executes all reports one after the other without any further requests to the user and “Learn” which starts the report with request form and retrieves the filters after execution: START-Button is pressed: IF FIND (‘-’) THEN REPEAT CurrForm.UPDATE (FALSE); YIELD; ro.TRANSFERFIELDS (Rec); // ro = “reportOptions” = rsLines record ro.“Datum Filter” := “Global Date Filter”; RunReport (FALSE); // RunReport is a function, see below; FALSE=No request form UNTIL NEXT = 0; LEARN-Button is pressed: ro.TRANSFERFIELDS (Rec); ro.“Datum Filter” := “Global Date Filter”; RunReport (TRUE); // with request form. TRANSFERFIELDS (ro); MODIFY; Fourth step Call the report //*xx: Remarks are explained below RunReport (WithRequest : Boolean); EvalDateFilter; //*01 COMMIT; CASE “Report ID” OF 50005 : BEGIN CLEAR(r50005); //*02 CLEAR(Artikelzusatz); IF ro.Artikelnummer <> ‘’ THEN Artikelzusatz.SETFILTER(Nummer,ro.Artikelnummer); IF ro.Kostenstellenfilter <> ‘’ THEN Artikelzusatz.SETFILTER(“Kostenstelle Filter”,ro.Kostenstellenfilter); IF ro.Lagerortfilter <> ‘’ THEN Artikelzusatz.SETFILTER(“Lagerort Filter”,ro.Lagerortfilter); r50005.SetReportFilter(ro); r50005.USEREQUESTFORM(WithRequest); //*03 r50005.SETTABLEVIEW (Artikelzusatz); r50005.RUNMODAL; IF WithRequest THEN r50005.GetReportFilter(ro); //*04 END; 50040 : BEGIN CLEAR(r50040); etc… to be repeated for every report to be called END; END; Remarks: //*01: EvalDateFilter is a function which sets the date-filter (if any) of the report according to the GlobalDateFilter set on execution time and the Date-Filter-Option. //*02: r50005 is a variable of type reportwhich points to my report 50005 //*03: the WithRequest parameter is set to true in Learn-Mode. //*04: In learn-mode the actual filters set by the user are being transfered back into the rsLines record after execution of the report. — Hey, quite a hell lot to swallow, isn’t it? if you need more, please let me know. Marcus P.S.: Private note to Magnus as you are Swedisch and I am Swiss: I made the first Report-scheduler for the Swiss-Swedish company ABB (Asea Brown Boweri). Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch Edited by - fabian on 2001 Feb 28 01:38:48
Marcus Maybe if you are feeling generous you could upload the objects at www.mynavision.net Save us some time. David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk
Hello! Use this SETTABLEVIEW(firstDataItem) SETTABLEVIEW(secondDataItem) … … . “Run.REPORT” It should work nice greeetings Gayer Rene