Problem for search

flyingjujuflyingjuju Member Posts: 35
edited 2013-02-18 in Navision Financials
Hello,

I have a problem in finding a code seller.
I look for the most recent sale with a vendor code active. And retrieve this code seller.
Here's what I do:


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

MESSAGE(FORMAT(EnteteFacture.COUNT));
EnteteFacture.FIND('-');

IF EnteteFacture.FIND('-') THEN REPEAT
Vendeur.GET(EnteteFacture."Code vendeur");
MESSAGE(EnteteFacture."Code vendeur");
IF Vendeur.Actif = TRUE THEN BEGIN
"Code vendeur" := EnteteFacture."Code vendeur";
EXIT;
END;
UNTIL NEXT = 0;



My code is good? because I can not get the good result

thank you for the help you can give me

Answers

  • Torben_R.Torben_R. Member Posts: 99
    EnteteFacture.INIT;   // remove this line, there's no need for it
    EnteteFacture.RESET;
    EnteteFacture.SETCURRENTKEY("N° donneur d'ordre");
    EnteteFacture.ASCENDING(FALSE);
    EnteteFacture.SETRANGE("N° donneur d'ordre","N° prospect");
    
    MESSAGE(FORMAT(EnteteFacture.COUNT));   // Do you get a number here?
    EnteteFacture.FIND('-');    // remove this line - you will get an error if the number in the message is 0
    
    IF EnteteFacture.FIND('-') THEN REPEAT
     Vendeur.GET(EnteteFacture."Code vendeur");
     MESSAGE(EnteteFacture."Code vendeur");    // Do you get a vendor number here?
     IF Vendeur.Actif = TRUE THEN BEGIN
     "Code vendeur" := EnteteFacture."Code vendeur";
     EXIT;
     END;
    UNTIL NEXT = 0;
    

    Do you get any messages? Look at my comment in the code
  • flyingjujuflyingjuju Member Posts: 35
    For EnteteFacture.COUNT, I have a number and this is the good number

    For EnteteFacture."Code vendeur", I have a number and this is the good number

    That's why I don't understand why it doesn't work
  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • flyingjujuflyingjuju Member Posts: 35
    I don't have the good result without EXIT
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    May I know what are you expecting from the code and what is not working?
  • flyingjujuflyingjuju Member Posts: 35
    through this code, I search the last active seller who make the sale to a prospect well defined.
    I feel that my REPEAT loop does not work and he does not repeat until it is not a good result

    You will find attached screenshots of examples, as well as the complete code that is executed in the table.
    Anything I add, you will find after //JW
    There may be something else that conflicts but I can not find anything.
    I have to add a function for what I need I call UpdateCodeVendeurCampagneFidé
  • chichi Member Posts: 17
    Hi
    I think "UNTIL NEXT = 0;" should be "EnteteFacture.NEXT = 0;".
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    chi wrote:
    Hi
    I think "UNTIL NEXT = 0;" should be "EnteteFacture.NEXT = 0;".
    yes, good one :thumbsup:
  • flyingjujuflyingjuju Member Posts: 35
    Thank you very much. It works.

    I had not thought about it because I thought the "NEXT" was implicit but thinking a little more, it is logical
Sign In or Register to comment.