Fatal Internal Error - Custom Code

gvolkovgvolkov Member Posts: 196
Guys, i have a function that evaluates some conditions and then based on those conditions prints up to 3 reports. At times "Fatal Internal Error" happens and i suspect that this code is causing this error. I can see some obvious enhancements this code could use, but not sure if it would be the cause for "Fatal Internal Error". Do you see anything?
PROCEDURE PrintSingleOrders@1000000011(LOrfulRec@1000000001 : Record 50067);
    VAR
      LTempSalesRec@1000000002 : TEMPORARY Record 36;
      LSalesHeadRec@1000000003 : Record 36;
      SalesLine@1000000000 : Record 37;
      OddOkay@1000000004 : Boolean;
      EvenOkay@1000000005 : Boolean;
      OtherOkay@1000000006 : Boolean;
      Item@1000000007 : Record 27;
      ShelfNumber@1000000008 : Integer;
      ShelfNumberText@1000000009 : Text[30];
      Text50000@1000000010 : TextConst 'ENU=Odd Shelves printed - %1\Even Shelves Printed - %2\Other Shelves Printed - %3';
    BEGIN
      IF LSalesHeadRec.GET(LSalesHeadRec."Document Type"::Order,LOrfulRec."No.") THEN BEGIN
         LSalesHeadRec.SETRECFILTER;
         COMMIT;
         OtherOkay := FALSE;
         EvenOkay  := FALSE;
         OddOkay   := FALSE;
         SalesLine.SETRANGE("Document No.",LSalesHeadRec."No.");
         SalesLine.SETRANGE(Type,SalesLine.Type::Item);
         SalesLine.SETFILTER("Outstanding Quantity",'<>0');
         IF SalesLine.FINDSET THEN REPEAT  //ODD
           IF Item.GET(SalesLine."No.") THEN
            IF STRLEN(Item."Shelf No.") = 0 THEN
            OddOkay := FALSE;
            IF Item."Shelf No." <> '' THEN BEGIN
            IF STRLEN(Item."Shelf No.") > 0 THEN
            IF EVALUATE(ShelfNumber,COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1)) THEN
            ShelfNumber := ShelfNumber ELSE ShelfNumberText := COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1);
            IF ((ShelfNumber MOD 2 = 0) OR NOT
            (EVALUATE(ShelfNumber,COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1)))) OR (Item."Shelf No." = '')  THEN BEGIN
              OddOkay := FALSE;
              IF ShelfNumberText = '' THEN
               OddOkay := FALSE;
            END ELSE BEGIN
              OddOkay := TRUE;
            END;
          END;
         UNTIL (OddOkay = TRUE) OR (SalesLine.NEXT = 0);

         SalesLine.FINDSET;
         IF SalesLine.FINDSET THEN REPEAT  //EVEN
          IF Item.GET(SalesLine."No.") THEN
            IF STRLEN(Item."Shelf No.") = 0 THEN
            EvenOkay := FALSE;
            IF Item."Shelf No." <> '' THEN BEGIN
            IF STRLEN(Item."Shelf No.") > 0 THEN
            IF EVALUATE(ShelfNumber,COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1)) THEN
            ShelfNumber := ShelfNumber ELSE ShelfNumberText := COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1);
            IF ((ShelfNumber MOD 2 <> 0) OR NOT
            (EVALUATE(ShelfNumber,COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1)))) OR (Item."Shelf No." = '')  THEN BEGIN
              EvenOkay := FALSE;
              IF ShelfNumberText = '' THEN
              EvenOkay := FALSE;
            END ELSE BEGIN
             EvenOkay := TRUE;
            END;
          END;
         UNTIL (EvenOkay = TRUE) OR (SalesLine.NEXT = 0);

         SalesLine.FINDSET;
         IF SalesLine.FINDSET THEN REPEAT //Other
          IF Item.GET(SalesLine."No.") THEN
           IF STRLEN(Item."Shelf No.") > 0 THEN
           IF ((Item."Shelf No." <> '') AND
            (EVALUATE(ShelfNumber,COPYSTR(Item."Shelf No.",STRLEN(Item."Shelf No."),1)))) OR (Item."Shelf No." = '') THEN BEGIN
             OtherOkay := FALSE;
           END ELSE BEGIN
            OtherOkay := TRUE;
         END;
         IF Item."Shelf No." = '' THEN
         OtherOkay := TRUE;
       UNTIL (OtherOkay = TRUE) OR (SalesLine.NEXT = 0);
        MESSAGE(Text50000,OddOkay,EvenOkay,OtherOkay);
        IF EvenOkay  THEN REPORT.RUNMODAL(REPORT::"Picking List by Order E",FALSE,FALSE,LSalesHeadRec);
        IF OddOkay   THEN REPORT.RUNMODAL(REPORT::"Picking List by Order O",FALSE,FALSE,LSalesHeadRec);
        IF OtherOkay THEN REPORT.RUNMODAL(REPORT::"Picking List by Order U",FALSE,FALSE,LSalesHeadRec);
         LOrfulRec."Pick Printed Date" := TODAY;
         LOrfulRec."Pick Ticket Printed Time" := TIME;
      END;
    END;
Microsoft Certified Technology Specialist
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist

http://www.navisiontech.com

Comments

  • tinoruijstinoruijs Member Posts: 1,226
    What does the "Fatal Internal Error" say?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • gvolkovgvolkov Member Posts: 196
    well, that is it, there is no more detail, although i did not check the event log, probably should.
    Microsoft Certified Technology Specialist
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified Business Management Solutions Specialist

    http://www.navisiontech.com
  • tinoruijstinoruijs Member Posts: 1,226
    I see nothing strange in your code.
    Maybe it works when you put a SLEEP(1000) or something between the printing of the documents?
    And perhaps this thread can lead you the right way; viewtopic.php?f=23&t=31386&hilit=fatal+internal+error
    Do you have the latest build installed?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
Sign In or Register to comment.