Report gets infinite loop when it executes a Doc no.

efficeon007efficeon007 Member Posts: 31
edited 2009-05-27 in Navision Financials
Hi I have a report gets infinite loop when it executes a document no.. I have checked several tables which contain this document no., but I did not find anything strange. Do you think what would be the root cause for this? I can not paste the *.fob file here, if somebody interested in this, I can send the *.fob file to her/his mailbox. Thanks.

Thanks.
I am a expert of questions, not the solution provider, but questions submitter.

Answers

  • BeliasBelias Member Posts: 2,998
    The output doesn't help us at all...have you got an integer dataitem in your report?If so, investigate about it: a lot of "endless loops problems" are due to bad integer dataitem designer.
    Another possible reason is that you have done some find('-') or similar in some onaftergetrecord trigger (or onpresection of body): this changes the pointer and screws up the report because you read the first, print it, re-read the first, re-print it...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • efficeon007efficeon007 Member Posts: 31
    Belias wrote:
    The output doesn't help us at all...have you got an integer dataitem in your report?If so, investigate about it: a lot of "endless loops problems" are due to bad integer dataitem designer.
    Another possible reason is that you have done some find('-') or similar in some onaftergetrecord trigger (or onpresection of body): this changes the pointer and screws up the report because you read the first, print it, re-read the first, re-print it...

    Sorry. I just checked the report and I found there is "REPEAT" syntax, and only one "REPEAT" in this report:

    SETRANGE("Autodocumento generado",TRUE);
    IF FIND('-') THEN;
    IF i = 1 THEN BEGIN
    REPEAT
    MovIVATemporal.INIT;
    MovIVATemporal.COPY(MovIVA6);
    MovIVATemporal.INSERT;
    MovIVATemporal.NEXT;
    UNTIL MovIVA6.NEXT = 0;
    IF FIND('-') THEN;
    i := 0;
    END;


    So I doubt this is the control you mean. But if let the report jump (let it <> document no. 09BB94), the report runs very well.
    To fix this problem, I have tried to modify the code as below, but the result still shows infinite 09BB94 records. Could you do me a favor to improve the below code? Thanks.

    IF i = 1 THEN BEGIN
    MovIVATemporal.SETRANGE("Nº documento",MovIVA6."Nº documento");
    MovIVATemporal.SETRANGE("Nº documento",'09BB94');
    IF MovIVATemporal.FIND('-')
    THEN
    BEGIN
    IF FIND('-') THEN;
    i := 0;
    END
    ELSE
    BEGIN
    REPEAT
    MovIVATemporal.INIT;
    MovIVATemporal.COPY(MovIVA6);
    MovIVATemporal.INSERT;
    MovIVATemporal.NEXT;
    UNTIL MovIVA6.NEXT = 0;
    IF FIND('-') THEN;
    i := 0;
    END;
    END; :-k
    I am a expert of questions, not the solution provider, but questions submitter.
  • BeliasBelias Member Posts: 2,998
    in what trigger did you put this code?
    did you already try to debug it in order to see where the infinite loop is?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • efficeon007efficeon007 Member Posts: 31
    Belias wrote:
    in what trigger did you put this code?
    did you already try to debug it in order to see where the infinite loop is?

    OnPreDataItem()

    Sorry, i am using 2.60 version and I don't find a place to manually put breakpoint in code.

    But I guess the REPEAT...UNTIL caused this problem.
    I am a expert of questions, not the solution provider, but questions submitter.
  • BeliasBelias Member Posts: 2,998
    you do this
    UNTIL MovIVA6.NEXT = 0;
    
    but i can't find this
    MovIVA6.FIND('-');
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • efficeon007efficeon007 Member Posts: 31
    Belias wrote:
    you do this
    UNTIL MovIVA6.NEXT = 0;
    
    but i can't find this
    MovIVA6.FIND('-');
    

    Yes. But it has:

    IF FIND('-') THEN;

    The code I show you above exists in MovIVA6 data item, so no need quote table name?
    I am a expert of questions, not the solution provider, but questions submitter.
  • BeliasBelias Member Posts: 2,998
    First of all, it's useless to PM me, i receive e-mail notifications ;)
    I am working too, and sorry, but i prefer to solve my own problems before :mrgreen: ...anyway...
    i didn't know what was the dataitem, but it should be ok to not quote it.
    Maybe it's better if you post the whole report (export the txt file): there can be a lot of reasons for your problem if we haven't found it up to now. A common practice is not to loop the dataitem variable inside himself (e.g.: repeat...until the moviva6 "variable" inside moviva6 dataitem)
    Last thing(this is not related to the endless problem): I can't understand why do you do this
    MovIVATemporal.NEXT;
    

    after this
    MovIVATemporal.INSERT;
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • efficeon007efficeon007 Member Posts: 31
    Go table Mov. IVA (Table ID=254), find Document No. = 09BB94, select this field, press Ctrl + F8, zoom in it, copy the data into excel; Then find other document no. which can be shown in report normally, copy their data into excel as well. Make comparison, I found invoice 09BB94 has two clients No. in it, whereas other inovices have one client only. I think this is the reason the report went to infinite loop, since I have tried in "trail database": there are two lines for this invoice, then make two lines have the same customer no., finally the report goes normal.
    I have to say the report itself has no problem, does it make sense if one sales invoice has two customers' No. into it? Therefore I am wondering if user can adjust / replace the two clients as one, then this problem can be solved. In future, if we have two customers, I think it is better issue two separate invoices.

    Anyway, thanks for help!!!
    I am a expert of questions, not the solution provider, but questions submitter.
Sign In or Register to comment.