Will this piece of code work?

anushafdoanushafdo Member Posts: 32
customerRecord.RESET;
customerRecord.SETFILTER("Credit Limit (LCY)",'>%1',"Balance (LCY)");
IF customerRecord.FINDSET THEN BEGIN
   customerRecord.Blocked := 2;
   customerRecord.MODIFYALL(TRUE);
END;
customerRecord.RESET
....
....

Here "Balance (LCY") is a Flow Field and I don't do any CALCFIELDS anywhere here.
Or
Is there a better way to block all this customers who meet the condition without repeating through the entire table by REPEAT...UNTIL loop?

Shafdo

Comments

  • vaprogvaprog Member Posts: 1,141
    Hi Shafdo
    anushafdo wrote:
    Here "Balance (LCY") is a Flow Field and I don't do any CALCFIELDS anywhere here.
    That code won't work, not because the CALCFIELDS is missing, mat mainly because the value of "Balance (LCY)" is evaluated and used in the filter at the time SETFILTER is called, not at the time a prospect record is examined as to whether it meats the filter criteria (that was kind of cool =P~).
    anushafdo wrote:
    Is there a better way to block all this customers who meet the condition without repeating through the entire table by REPEAT...UNTIL loop?
    I can't think of one.
  • anushafdoanushafdo Member Posts: 32
    So, it seems that I have loop through the records. This database has around 10,000 customer records and they plan to run this check every day.
    I will suggest to run a batch job during night until I learn a better a way, if there is any.

    Thank you
  • vaprogvaprog Member Posts: 1,141
    What about a check on posting Customer Ledger Entries instead of a batch job?
  • anushafdoanushafdo Member Posts: 32
    vaprog wrote:
    What about a check on posting Customer Ledger Entries instead of a batch job?

    Do you mean to "calculate" the balance from cust. ledger entries by summing? Can you elaborate a bit please.

    Thanks
  • vaprogvaprog Member Posts: 1,141
    anushafdo wrote:
    Do you mean to "calculate" the balance from cust. ledger entries by summing? Can you elaborate a bit please.
    The balance changes only when a Detailed Customer Ledger Entry is added (or changed, but that should not happen in a way that alters the balance). Therefore, if you check the credit limit against the balance at this point you can keep the blocked state current without running a batch job.

    To get the balance you need the sum of detailed customer ledger entries, but rather than adding them up yourself use the FlowField on the customer or use a CALCSUMS command on Detailed Cusomer Ledger Entries to take advantage of the pre-computed sum in the SumIndex/SIFT.

    Of course this still has an impact on performance of posting routines, but because of the SIFT probably not a severe one.
Sign In or Register to comment.