Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Copy document error

Posted on by Microsoft Employee

HI everyone, I'm trying to copy a document (sales shipment document) but I'm always the error "The sales shipment line does not exist. Document no x, line no 10000"

After a little debug I found that in Item Ledger Entry table, this document have the document type "Sales Shipment". if i change this to "Sales Invoice" the error don't appear.
With the debugger the error occurs in this line:

Codeunit CopyDocument

function GetAsmDataFromSalesInvLine , line   SalesShipmentLine.GET(ItemLedgerEntry."Document No.",ItemLedgerEntry."Document Line No.");

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Copy document error

    The document exists.. this error is raise ALWAYS... so is not the case that one could be deleted understand?

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Copy document error

    Do you have the sales shipment? if you don't have the sales shipment then did somebody delete the shipment

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Copy document error

    I understand but how can I solve this? I need to ignore the document type issue understand? In nav 2009 this option was very used but the document type field does not exist...

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Copy document error

    Check these two lines:

    IF ItemLedgerEntry."Document Type" <> ItemLedgerEntry."Document Type"::"Sales Shipment" THEN

    EXIT(FALSE);

    SalesShipmentLine.GET(ItemLedgerEntry."Document No.",ItemLedgerEntry."Document Line No.");

    Here, if you reach the GET instruction it's because your Item Ledger Entry record has Document Type = Sales Shipment. If so, the Document No should be a Sales Shipment (so the GT can't fail) and not a Sales Invoice No. (like it seems in your case).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Copy document error

    Some problem like what?

    My code in code unit Copy document is this

    LOCAL GetAsmDataFromSalesInvLine(DocType : 'Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order') : Boolean
    
    CLEAR(PostedAsmHeader);
    
    IF TempSalesInvLine.Type <> TempSalesInvLine.Type::Item THEN
    
     EXIT(FALSE);
    
    ValueEntry.SETCURRENTKEY("Document No.");
    
    ValueEntry.SETRANGE("Document No.",TempSalesInvLine."Document No.");
    
    ValueEntry.SETRANGE("Document Type",ValueEntry."Document Type"::"Sales Invoice");
    
    ValueEntry.SETRANGE("Document Line No.",TempSalesInvLine."Line No.");
    
    IF NOT ValueEntry.FINDFIRST THEN
    
     EXIT(FALSE);
    
    IF NOT ItemLedgerEntry.GET(ValueEntry."Item Ledger Entry No.") THEN
    
     EXIT(FALSE);
    
    IF ItemLedgerEntry."Document Type" <> ItemLedgerEntry."Document Type"::"Sales Shipment" THEN
    
     EXIT(FALSE);
    
    SalesShipmentLine.GET(ItemLedgerEntry."Document No.",ItemLedgerEntry."Document Line No.");
    
    IF NOT SalesShipmentLine.AsmToShipmentExists(PostedAsmHeader) THEN
    
     EXIT(FALSE);
    
    IF ValueEntry.COUNT > 1 THEN BEGIN
    
     ValueEntry2.COPY(ValueEntry);
    
     ValueEntry2.SETFILTER("Item Ledger Entry No.",'<>%1',ValueEntry."Item Ledger Entry No.");
    
     IF NOT ValueEntry2.ISEMPTY THEN
    
       ERROR(Text032,TempSalesInvLine."Document No.");
    
    END;
    
    GenerateAsmDataFromPosted(PostedAsmHeader,DocType);
    
    EXIT(TRUE);


  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Copy document error

    I think you have some problems in your Value Entry table. The standard code is ok. It searches the Value Entry, the retrieves the Item Ledger Entry and then if the Document Type is not "Sales Shipment" it exits.

    Standard code:

    ValueEntry.SETCURRENTKEY("Document No.");

    ValueEntry.SETRANGE("Document No.",TempSalesInvLine."Document No.");

    ValueEntry.SETRANGE("Document Type",ValueEntry."Document Type"::"Sales Invoice");

    ValueEntry.SETRANGE("Document Line No.",TempSalesInvLine."Line No.");

    IF NOT ValueEntry.FINDFIRST THEN

     EXIT(FALSE);

    IF NOT ItemLedgerEntry.GET(ValueEntry."Item Ledger Entry No.") THEN

     EXIT(FALSE);

    IF ItemLedgerEntry."Document Type" <> ItemLedgerEntry."Document Type"::"Sales Shipment" THEN

     EXIT(FALSE);

    SalesShipmentLine.GET(ItemLedgerEntry."Document No.",ItemLedgerEntry."Document Line No.");

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans