Initialisation of a report

How do I initialise a report - totally! I don’t think that CLEAR(report) is enough in my case?..

quote:


Originally posted by jensthomsen
How do I initialise a report - totally! I don’t think that CLEAR(report) is enough in my case?..


What did you mean with initialise?

CLEAR is a compant to clear the contents of a variable. If you have a variable of type Reprot, then you are just reseting that Variable, not the report it self, so you may come into a problem with values stored in the ZUP file. I would recommend modifying the report property SaveValues to NO. So that the values are not stored.

A seemingly easy task [:)], but then again…[V] David is right, but setting SaveValues to No won’t clear stored filters or Sorting Orders set on the dataitems, though. In order to do that you have to something like this: CLEAR(MyReport); CLEAR(MyReportDataItem1); CLEAR(MyReportDataItem2); .. etc. MyReport.SETTABLEVIEW(MyReportDataItem1); MyReport.SETTABLEVIEW(MyReportDataItem2); MyReport.RUNMODAL;

Hy Steffen It sounds like something right…But if my report is declared as REPORT and I’m calling a function FUNCTION I can’t just say CLEAR(REPORT.FUNCTION)? But it is something like this that I’m looking for - a total resetting of all variables and a removal of all filters on the report! There must be an easy way to do this???

Hi, It looks like you need to create a function inside the Report which you can call to reset all the internal variables of the Report. Something like: Report.Clear() //ReportDataItemRecord.RESET; // edited ReportVariableInteger := 0; // or CLEAR(ReportVariableInteger); ReportVariableText := ''; // or CLEAR(ReportVariableText); etc... I think this is what you need, but I don’t understand why you need something like this. Do you want to shed some light on it?

Sorry Nelson, I’m afraid that won’t work. You can’t clear dataitems within the report. Filters will be loaded from the .zup file after any code is executed via the OnInitReport() Trigger. Same thing if you call a function within the report prior to running it.

Hi Steffen, Yes, you are right on the DataItems [8)] but you can use a function to assign values to variables in a Report. For example, that’s how Navision does it in the Add/Remove Contacts functionality in Relationship Management Segments, for example. It is true that variable values are saved in the ZUP file, but only if the RequestForm has the property SaveValues set to True. However this property defaults to False, so I don’t this is the problem here. I think we need more info… [:I]

Well, here’s a little further information: The code I want to execute looks like this: lWarehouseActivityLine.VALIDATE(lWarehouseActivityLine.“Qty. to Handle”,Temp2PurchaseLine.“Autoudfyld Antal”); lWarehouseActivityLine.MODIFY; COMMIT; CLEAR(WhseCreatePick); WhseCreatePick.SetWhseActivLine(lWarehouseActivityLine); WhseCreatePick.USEREQUESTFORM(FALSE); WhseCreatePick.RUNMODAL; WhseCreatePick.GetResultMessage; Where lWarehouseActivityLine is a .rec variabel and WhseCreatePick is a report. When I run the code once, there is no problems, but when I run it repeatedly (in a “Repeat - Until” statement)I get an error?

What sort of error do you get?

I get an “Nothing to handle”. But why does it work ones and not twice??? I guess it must be the report who “holds a filter”! I have also tried creating a function on the report with just one line: CLEARALL; and then calling this function right after the line WhseCreatePick.GetResultMessage; but this doesn’t work either!! Arrrrgh!! (Maybe I should try writing a letter to Bill Gates)…

I’m not sure that Bill Gates is the culprit here[;)] Are you sure you have an active record the second time around? Have You tried debugging? You could try something like this: lWarehouseActivityLine1.COPY(lWarehouseActivityLine); lWarehouseActivityLine1.SETRECFILTER; CLEAR(WhseCreatePick); WhseCreatePick.SETTABLEVIEW(lWarehouseActivityLine1); WhseCreatePick.USEREQUESTFORM(FALSE); WhseCreatePick.RUNMODAL; WhseCreatePick.GetResultMessage;

Hi Everybody I’ve found a solution to my problem: It hadn’t anything to do with a “hanging filter” on the report. The function on the report: WhseCreatePick.SetWhseActivLine(lWarehouseActivityLine); only uses the filter set on the record, and since I hadn’t placed any filters on the record, it didn’t work![:)]