Error Cust. Ledger Entry Entry No. '0' when running dataport

yugi200186yugi200186 Member Posts: 20
Hi guys, i'm new to this dynamic nav thing and probably gonna need your help on this.

I created some dataport with Sales Invoice Line as data item and my objective were to export the data along with field remaining amount (LCY) in cust ledger entry. Here is a few code that i use in "before export trigger".

IF "Document No." <> '' THEN BEGIN
SalesInvoiceHeader."No." := "Document No.";
SalesInvoiceHeader.FIND;
CustLedgerEntry."Document No." := "Document No.";
CustLedgerEntry.FIND;
Rem_Amt := CustLedgerEntry."Remaining Amount";
Rem_Amt_LCY := CustLedgerEntry."Remaining Amt. (LCY)";
END

When i run the dataport it shows me error like this
Cust. Ledger Entry Entry No. '0' does not exist.

Can someone telling me what to do ? I'm currently using NAV 4.0sp3.

Comments

  • krzychub83krzychub83 Member Posts: 120
    FIND without any parameters is trying to get a record based on the primary key value. In case of the SalesInvoiceHeader you have set the primary key (NO.) to some value, thus FIND was able to find that record. However in case of the CustomerLedgerEntry you have set "Document No.", which is not a primary key there. The primary key there is Entry No., which on your variable still equals 0. In a result when you executed the FIND function you have tried to get record which entry no. is set to 0. Entry No. is populated by posting routines in that table and it never equals 0 (if it does than it means that somebody opened that table directly in Object Designer and accidentially inserted an empty record there...).

    Please read this How-To! It will really help you: http://www.mibuso.com/howtoinfo.asp?FileID=22
    //I don't remember if FINDFIRST/GET was used in NAV4.03... If not then replace FINDFIRST with FIND('-') and GET with FIND. Try to read NAV's help regarding all statements used here too. 
    IF "Document No." <> '' THEN BEGIN
     // SalesInvoiceHeader."No." := "Document No.";
     // SalesInvoiceHeader.FIND;
     SalesInvoiceHeader.GET("Document No.");
     CustLedgerEntry.RESET; 
     CustLedgerEntry.SETCURENTKEY("Document No.");
     CustLedgerEntry.SETRANGE("Document No.","Document No.");
     CustLedgerEntry.FINDFIRST;
     CustLedgerEntry.CALCFIELDS("Remaining Amount","Remaining Amt. (LCY)"); 
     Rem_Amt := CustLedgerEntry."Remaining Amount";
     Rem_Amt_LCY := CustLedgerEntry."Remaining Amt. (LCY)";
    END
    
Sign In or Register to comment.