RE: Codes to set filter

Does anyone know how to set filter as in eg Quantity <> Quantity Invoiced? because for the usual way record.setfilter(field,value) the range is usually a text or figure but it never a field. Thank you ------------------------------------------- moved from Technical Forum by moderator [8D]

I am not sure what you want to achieve, but if I am right, you are looking for something like: Rec1.sSETFILTER(Quantity,’<>%1’,Rec2.“Quantity Invoiced”); Hope I could help.

Well, the main aim is to filter within the same record to get all the sales line where the quantity is not equal to quantity invoiced. It is the same for eg to filter within sales header all the Document Type = Order. Hope it helps. Thank you

this is more difficult, since you have to retrieve every single record from the database in order to see if it complies to your rule. You would have to work with MARK and MARKEDONLY, but the MARKEDONLY-Filter is rather slow, so performance might be an issue. Code would be something like: Rec.FIND’-’); REPEAT if Rec.Quantity <> Rec.“Quantity Invoiced” then Rec.MARK(TRUE); UNTIL Rec.NEXT = 0; Rec.SETMARKEDONLY(TRUE); …do what you need to do with the filtered record set, and if you need the Rec later on, don’t forget: Rec.SETMARKEDONLY(FALSE); Rec.CLEARMARKS; but it is slow…

oh ok … but if it is too slow, don’t think the users will like it or can i use this instead: SalesLineR.RESET; SalesLineR.SETRANGE(SalesLineR.“Document No.”, “No.”); IF SalesLineR.Quantity <> SalesLineR.“Quantity Invoiced” THEN BEGIN IF SalesLineR.FIND(’-’) THEN BEGIN OrderedAmt := (SalesLineR.Quantity - SalesLineR.“Quantity Invoiced”)*SalesLineR.“Unit Price”; EstimatedCost := “Total Estimated Unit Cost”; ActCost := (SalesLineR.Quantity - SalesLineR.“Quantity Invoiced”*SalesLineR.“Unit Cost (LCY)”; EstimatedGP := OrderedAmt - EstimatedCost; EstimatedGPPer := ((OrderedAmt - EstimatedCost)/EstimatedCost)*100; ActGP := OrderedAmt - ActCost; ActGPPer := ((OrderedAmt - ActCost)/ActCost)*100; IF SalesLineR.Quantity <> SalesLineR.“Quantity Invoiced” THEN BEGIN OrderStatus := ‘Partially’; END ELSE BEGIN OrderStatus := ‘Ordered’; END; END; END; But it seems that for this method, the figure does not appear.

Hi yap line 3 of your code will not work. there is no salesliner read before so the result of this line will be dangerous

So is there any possibility to add any other code before line 3 to make it work because it seems there isn’t other ways

There maybe another method for this filtering : Append a flowfield to your table Sumformula : something with exist() Set the filter to this field BUT : this will not much more faster than beavers solution, even for calculation ALL flowfields it works even slower.

you will have to read every line from your PurchRcpt in the line with the FIND and then decide in the IF-statement whether to keep on going with that line or skip it. SalesLineR.RESET; SalesLineR.SETRANGE(SalesLineR.“Document No.”, “No.”); IF SalesLineR.FIND(’-’) THEN REPEAT IF SalesLineR.Quantity <> SalesLineR.“Quantity Invoiced” THEN BEGIN DoCalculations; OrderStatus := ‘Partially’; END ELSE OrderStatus := ‘Ordered’; UNTIL SalesLineR.NEXT = 0; END; You should maybe consider reading the relevant chapters in the Application Designer’s Guide on the product cd about filtering and retrieving records from the database…[;)]

Oops maybe need to clarify abit, that these two fields “Quantity” and “Quantity Invoiced” are not flow field but now I want to set the condition that these two quantities must not be equal before i will calculate and display the result.

Hi yap, in this case beavers solution is the only one …

hi beaver, have a look to the link ‘Forum Code’ at the left of the reply box. There you can find how to post code in the typical code form

you mean: IF Condition THEN DoSomething ELSE DoSomethingElse; thanx!

hey thanks Hans, Beavers, Hee me will really look through the application designer guide again… just a last query because I actually used the method by Beavers but it seems that figures are still 0… Thank you frens…


------------------------------------------- moved from Technical Forum by moderator [8D]

Richard, can you please let me know how you moved this, I just can’t get it to work