Options

problem to exit a loop

flyingjujuflyingjuju Member Posts: 35
edited 2013-10-03 in Navision Financials
Hello,

I search the last active seller for a specific customer.
I wish to exclude from the seller's result that the code "33", "13", "0", "1", starting with "I".
How should I do to move to the next record if the code is part of the vendor codes out?

Here is my code :


EnteteFacture.RESET;
EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
EnteteFacture.ASCENDING(FALSE);
EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");

IF EnteteFacture.FIND('-') THEN REPEAT
Vendeur.GET(EnteteFacture."Code vendeur");
IF Vendeur.Actif = TRUE THEN BEGIN
IF "Code vendeur" = 33 OR "Code vendeur" = 13 OR "Code vendeur" = 0 OR "Code vendeur" = 1 "Code vendeur" = I* THEN BEGIN
//I do not know what to put in this place to jump to the next record
END;
"Code vendeur" := EnteteFacture."Code vendeur";
EXIT;
END;
UNTIL EnteteFacture.NEXT = 0;

Thank you for the help you can give me

Answers

  • Options
    einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Why not exclude those records in first place?
    EnteteFacture.RESET;
    EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
    EnteteFacture.ASCENDING(FALSE);
    EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");
    EnteteFacture.SETFILTER("Code vendeur",'<>%1&<>%2&<>%3&<>%4&<>%5*','33','13','0','1','I');
    
    IF EnteteFacture.FIND('-') THEN REPEAT
    Vendeur.GET(EnteteFacture."Code vendeur");
    IF Vendeur.Actif THEN BEGIN
    ...
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • Options
    flyingjujuflyingjuju Member Posts: 35
    Thank you. I had not thought of this solution
  • Options
    flyingjujuflyingjuju Member Posts: 35
    after multiple tries, it does not work.
    In fact, I would go to the next record if I come across a seller that has a code equal to 33, 13, 0, 1 or I *.

    How do I do that?
  • Options
    chichi Member Posts: 17
    Hi
    In my opinion, the code should be something as below:

    EnteteFacture.RESET;
    EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
    EnteteFacture.ASCENDING(FALSE);
    EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");

    IF EnteteFacture.FIND('-') THEN REPEAT
    IF NOT (("Code vendeur" IN = 'I')) THEN BEGIN
    Vendeur.GET(EnteteFacture."Code vendeur");
    ......
    END;
    UNTIL EnteteFacture.NEXT = 0;
  • Options
    flyingjujuflyingjuju Member Posts: 35
    Thank you for this solution but it does not work.
    I always record with these codes sellers.

    Nevertheless, I think this is the right path.
    Should maybe I put an else because if I get one of these codes sellers, I have to go to the next invoice.

    How can I do that?

    thank you
  • Options
    flyingjujuflyingjuju Member Posts: 35
    Have still not found a solution to my problem, I'll explain again what I do.

    We do loyalty campaigns.
    Through my code, I get information about our prospects (name, address, code vendor area code, etc ...)
    In these loyalty campaigns, I must search for each prospect the last sale of an active seller and get the code seller.
    If unfortunately, the last active seller for a code 33, 13, 0, 1 or I *, I have to go to the next active seller.
    If unfortunately, I have no active seller, I owe nothing to the code seller.


    This is the part that is written in red I have a problem.
    Someone would have a solution to offer me aside from what has already been
  • Options
    einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    It's not possible in an easy way to step to the next record in a loop that is based on the same recordset. What if the next record also doesn't match your conditions?

    Both mentioned solutions should work in certain situations. If they don't you probably miss something. Why don't they work? How do your table relations and fields look like?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • Options
    DenSterDenSter Member Posts: 8,304
    The computer thinks in yes/no, it does not understand "maybe this"/"maybe that". As a developer, it is YOUR job to translate the problem into yes/no, so you can program it to do what it needs to do.

    To me this looks like you still have some translating to do. You have to go deeper into the detail in what steps are taken. Do you have a senior that you can ask for help? This is typically something that you would do working with someone standing at a white board or with pen and paper.

    You will have to be more specific than "it doesn't work", that does not say anything about what is really wrong.
  • Options
    flyingjujuflyingjuju Member Posts: 35
    Firstly, I do not have senior who can help me. That is why I am using this forum.

    In addition, it is not that not everything works but my test I can still have codes Sellers 33 and I *

    I realized also that my test IF NOT (("Salesperson Code" IN ) OR ("Salesperson Code" [1] = 'I') ) THEN BEGIN is useless because with or without I get the same result with no filter.
    There is the STEFILTER happens to limit my results

    If I take the example of the vendor code 33, I get 765 prospects without filter and with SetFilter only 7 but it is still too 7
  • Options
    DenSterDenSter Member Posts: 8,304
    I still don't understand what you want. to jump to the next record, you use NEXT, which is at the end of a REPEAT UNTIL loop. Anything you need to do during the loop you can program, but you have to be able to determine each step in the process.

    You also need to be able to look at the same problem from a different angle. Instead of thinking "jump to the next record if something is TRUE", think about "only do something if the same thing is FALSE" and let the loop do its work.
  • Options
    AlbertvhAlbertvh Member Posts: 516
    Hi,
    Late reply but.....
    Change your code to
    IF EnteteFacture.FIND('-') THEN
       REPEAT
          Vendeur.GET(EnteteFacture."Code vendeur");
          IF Vendeur.Actif = TRUE THEN BEGIN
             IF (EnteteFacture."Code vendeur" = '33') OR 
                 (EnteteFacture."Code vendeur" = 13') OR
                 (EnteteFacture."Code vendeur" = '0') OR
                 (EnteteFacture."Code vendeur"[1] = 'I') THEN BEGIN
    

    Hope you still have the problem
Sign In or Register to comment.