Removing Filters in Report

Hi all! We have reports (processing only) that are executed in 2 ways: First, manually - run by user. Second, automatically - run by a batch-processor, unattended. The problem is, that if a user has set some filters on a DataItem, this filter is also active when the batch-job is done (filter is saved in ZUP-file!?) - and that’s the problem: When the report is executed in the batch-process, it has to run without any filters! The batch-processor can not call the report with a specified table, the call is REPORT.RUNMODAL(ReportID, FALSE); So how can i remove all filters before the report runs? Remarks: I do not want to delete the ZUP-file ;c) and i do not want to create different reports for user- and batch-processing. Best Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP Edited by - stryk on 2001 Jun 20 10:28:36

Joerg If you put a RESET on the OnPreDatitem then filters are ignored. So you need to testif the report is being run from a batch process and reset the records. Paul Baxter

You can also run the batch job with a different zup-file using th command line option “id=MyZupfile”.

Joerg, The as mentioned by Paul, Reset should definately do the trick for you Vishal

Jörg, The only solution is to set the SaveControlInfo property on the Request Form to “no”. This is the only way to make sure that no values from the Request form (Table Filters as well as developer-defined variables) are set. ------- With best regards from Switzerland Marcus Fabian

If you set the report as a vaiable then you can call a procedure on the report to set a boolian variable on the report. Then Call the report if the variable is set then it was run by the batch process if not it was run by the user. When the value is TRUE you remove the filters on the tables on the report and set the variables on the option form to suitable values. Paul Baxter

Let’s take the following example: You have “MyReport” which processes the Customer ledger entries (CLE) and takes as filters CustomerNo and Posting Date. The report can be called “manually” or via an external object. Let’s also assume that the filters of the batch call are not fixed. Step 1: User calls the report manually and sets the filters CustomerNo=1* and Posting Date=0101…3103 Step 2: Your Batch is calling MyReport with CustomerNo=20*; Posting Date=0106…3108 To set these filters in the Report the Report contains a function “SetFilter(par_Custno, par_DateFilter)”. This function is being called just before the report is started without Request Form: MyReport.SetFilter(‘20*’,‘0106…3108’); MyReport.ShowRequestForm (False); MyReport.RunModal; If you have “SaveControlInfo” property set to yes, the following will happen. The filters are passed correctly to the report but just before processing the saved “ControlInfo” will overwrite your Batch-filters therefore executing the report for CustomerNo=1* and Posting Date=0101…3103!! Setting “SaveControlInfo=No” is a save method to make sure that your filters do not get overwritten on the way. You could also have the function SetFilter save the filter-parameters in global variables which you use in OnPreDataItem to overwrite possible saved filters. However your report would be in an undetermined state: What if the user has last time used an additional filter on Customer Group? If you only setrange CustomerNo and Posting Date this Customer Group filter would remain intact and if you use a Reset OnPreDataItem the user wouldn’t have a chance to enter his own filters. ------- With best regards from Switzerland Marcus Fabian

Use SETTABLEVIEW to set the table view for the report: NyRec.RESET; MyRec.SetFilter(Number,‘20*’); MyRec.SetFilter(Date,‘0106…3108’); MyREPORT.SETTABLEVIEW(NyRec); MyReport.ShowRequestForm (False); MyReport.RunModal; This way you will also remove whatever filters the user has on other fields and also if there are 2 tables with request-fields, just set table view for each table. Regards, Lennart Nielsen

Hi all! Thank you very much for your advices! Paul’s solution works best to solve my problem, so now the report finds out, if it is run in a batch-process and then resets the specified tables. Setting the property “SaveControlInfo” or “SaveTableView” has not the effect i need … Calling the report as a variable and pre-calling a reset-function is not practicable, because the users can decide, which reports should be processed, and so it would be to expendable to define every report as a variable … Thanx again & best regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP

You don’t even need to use the Variable from Paul’s idea. If you are calling the report in some un-attended process, you are not using the request form. In that case, you can look at the value of CurrReport.USEREQUESTFORM on the PreReport trigger. If it’s false…automated, If it’s true…manual

That is a very good idea. The USEREQUESTFORM can be set when you call the report. It is the second TRUE /FALSE in REPORT.RUN(X , TRUE ,TRUE, rec) so you can descide if a report need user interaction at that point and write the report acordingly. That would make a very good standard interface for reports that may or may not require user interaction. Paul Baxter Edited by - triff on 2001 Jun 25 17:58:36

Hi again! It’s not the problem, wether to show the RequestForm or not, it’s not the problem to clear the values in the RequestForm on the “Options”-Page, the problem is … uh … WAS to delete/reset filters that a user´has set on a DataItem. E.g. A report does some processing with the Item-Table (27). A user runs this Report manually, the RequestForm is shown, and he puts a filter on a special Item-No., e.g. 0815, the report runs for 0815… ok, so far so good. Now, the same user (same ZUP) decides to run that report in the batch … The batch-processor calls the Report without RequestForm: … REPORT.RUNMODAL(ReportID, FALSE, FALSE); … But now, the report is STILL filtered on item no. 0815 (even when the RF was not shown!), and that shouldn’t happen! So the only real working solution is - Paul’s advice - when the Report finds out, if it’s run in the batch and then resets the filters: OnPreReport() IF ReportIsJob THEN Item.RESET; Thanx a lot, again! Best Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP

So, all you really need is OnPreReport() IF NOT CurrReport.USEREQUESTFORM THEN Item.RESET;

Hi Chris! Now I got you! Ouch … (that was my hand on my forehead) … maybe it’s to hot here to think clear … As always: The simple solutions are the best solutions! Thank you VERY much for “enlightenment” ;c)) BEST Regards, Jörg Joerg A. Stryk Apollo-Optik, IT/ERP

Navision resets any filters the user sets on a data item prior to processing the data item. Therefore if you reset the data item in the OnPreReport trigger nothing will happen. This needs to be done in the OnPreDataItem trigger.