PurchCrMemoHeader.RESET; PostedPurchInvoice.SETRANGE("ACW Service Order No.", "No."); IF PostedPurchInvoice.FINDSET THEN REPEAT PurchCrMemoHeader.SETRANGE("Adjustment Applies-to",PostedPurchInvoice."No."); LinkedPostedPCM += PurchCrMemoHeader.COUNT; IF PurchCrMemoHeader.FINDFIRST THEN REPEAT PurchCrMemoHeader.MARK(TRUE); UNTIL PurchCrMemoHeader.NEXT = 0; UNTIL PurchCrMemoHeader.NEXT = 0; PurchCrMemoHeader.SETRANGE("Adjustment Applies-to");
PurchCrMemoHeader.MARKEDONLY(TRUE); FORM.RUN(FORM::"Posted Purchase Credit Memos",PurchCrMemoHeader);
Answers
But on SQL, it is best to avoid MARK because it is a performance killer. It is best to save the records in a temptable and then run the form with the temptable.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Many thanks for your detailed answer. It was my lucky day. I had not known MARK was not good for SQL performance. Point noted. And for several reasons a temptable sounds much better. Easier to debug, more flexibility with sorting etc. I will go with that.
Also thanks for pointing out the anomalies in my code. I was always under the impression that since FINDFIRST was implemented it was better for performance than FIND('+'), but now I see with a loop that is not the case. Also a very elegant method with the IF SETCURRENTKEY(....) THEN.
Much food for thought today, I am humbled.
Bruce Anderson
Be careful for an indigestion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
But a temporary table... brilliant.
Raymond