Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The "Ship-to Code" field is empty unexpectedly after you run the Get Sales Order function for a special order in a special purchase order in Microsoft Dynamics NAV 2009


View products that this article applies to.

This article applies to Microsoft Dynamics NAV for all countries and all language locales.

↑ Back to the top


Symptoms

After you run the Get Sales Order function for a special order in a special purchase order in Microsoft Dynamics NAV 2009, the Ship-to Code field in the header of the special purchase order is empty unexpectedly. 
This problem occurs in the following products:
  • Microsoft Dynamics NAV 2009 R2
  • Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)

↑ Back to the top


Resolution

Hotfix information

A supported hotfix is now available from Microsoft. However, it is only intended to correct the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Dynamics NAV 2009 service pack or the next Microsoft Dynamics NAV version that contains this hotfix.

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Technical Support Professional for Microsoft Dynamics and related products determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

↑ Back to the top


Installation information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Note Before you install this hotfix, verify that all Microsoft Navision client users are logged off the system. This includes Microsoft Navision Application Services (NAS) client users. You should be the only client user who is logged on when you implement this hotfix.

To implement this hotfix, you must have a developer license.

We recommend that the user account in the Windows Logins window or in the Database Logins window be assigned the "SUPER" role ID. If the user account cannot be assigned the "SUPER" role ID, you must verify that the user account has the following permissions:
  • The Modify permission for the object that you will be changing.
  • The Execute permission for the System Object ID 5210 object and for the System Object ID 9015 object.


Note You do not have to have rights to the data stores unless you have to perform data repair.

Code changes

Note Always test code fixes in a controlled environment before you apply the fixes to your production computers.
To resolve this problem, follow these steps:
  1. Change the code in the GetDescriptionAndRcptName funtion in the in the ReqJnlManagement codeunit (330) as follows:
    Existing code
    ...
    ELSE
    Description := '';

    // Delete the following lines.
    ReqLine.Type::Item:
    IF Item.GET(ReqLine."No.") THEN
    Description := Item.Description
    ELSE
    Description := '';
    // End of the lines.

    END;
    END;

    IF ReqLine."Vendor No." = '' THEN
    ...
    Replacement code
    ...
    ELSE
    Description := '';
    END;
    END;

    IF ReqLine."Vendor No." = '' THEN
    ...
  2. Add a new global variable in the Req. Wksh.-Make Order codeunit (333), and then specify the variable as follows:
    • Name: DropShptSpecialOrderExists
    • DataType: Boolean
  3. Add a new local variable in the InsertPurchOrderLine function in the Req. Wksh.-Make Order codeunit (333), and then specify the variable as follows:
    • Name: SalesHeader
    • DataType: Record
    • Subtype: Sales Header
  4. Add a new local variable in the InsertPurchOrderLine function in the Req. Wksh.-Make Order codeunit (333), and then specify the variable as follows:
    • Name: DropShptSplOrderDiffAddress
    • DataType: Boolean
  5. Change the code in the InsertPurchOrderLine function in the Req. Wksh.-Make Order codeunit (333) as follows:
    Existing code
    ...
    WITH ReqLine2 DO BEGIN
    IF ("No." = '') OR ("Vendor No." = '') OR (Quantity = 0) THEN
    EXIT;


    IF (PurchOrderHeader."Buy-from Vendor No." <> "Vendor No.") OR
    (PurchOrderHeader."Sell-to Customer No." <> "Sell-to Customer No.") OR
    (PrevShipToCode <> "Ship-to Code") OR
    (PurchOrderHeader."Order Address Code" <> "Order Address Code") OR
    (PurchOrderHeader."Currency Code" <> "Currency Code") OR

    // Delete the following line.
    (PrevPurchCode <> "Purchasing Code")

    THEN BEGIN
    ...
    Replacement code
    ...
    WITH ReqLine2 DO BEGIN
    IF ("No." = '') OR ("Vendor No." = '') OR (Quantity = 0) THEN
    EXIT;

    // Add the following lines.
    DropShptSpecialOrderExists := FALSE;
    IF SalesHeader.GET(SalesHeader."Document Type"::Order,"Sales Order No.") THEN BEGIN
    DropShptSpecialOrderExists := PurchOrderHeader.DropShptSplOrderExists(SalesHeader);
    IF DropShptSpecialOrderExists THEN
    DropShptSplOrderDiffAddress :=
    NOT PurchOrderHeader.CheckAndAddShipToAdd(SalesHeader,FALSE);
    END;
    // End of the lines.

    IF (PurchOrderHeader."Buy-from Vendor No." <> "Vendor No.") OR
    (PurchOrderHeader."Sell-to Customer No." <> "Sell-to Customer No.") OR
    (PrevShipToCode <> "Ship-to Code") OR
    (PurchOrderHeader."Order Address Code" <> "Order Address Code") OR
    (PurchOrderHeader."Currency Code" <> "Currency Code") OR

    // Add the following lines.
    (PrevPurchCode <> "Purchasing Code") OR
    (DropShptSplOrderDiffAddress)
    // End of the lines.

    THEN BEGIN
    ...
  6. Add a new local variable in the InsertHeader function in the Req. Wksh.-Make Order codeunit (333), and then specify the variable as follows:
    • Name: SalesHeader
    • DataType: Record
    • Subtype: Sales Header
  7. Change the code in the InsertHeader function in the Req. Wksh.-Make Order codeunit (333) as follows:
    Existing code
    ...
    PurchOrderHeader.SetShipToForSpecOrder;
    END;

    PurchOrderHeader.MODIFY;
    ...
    Replacement code
    ...
    PurchOrderHeader.SetShipToForSpecOrder;
    END;

    // Add the following lines.
    IF DropShptSpecialOrderExists THEN BEGIN
    SalesHeader.GET(SalesHeader."Document Type"::Order,"Sales Order No.");
    PurchOrderHeader."Ship-to Name" := SalesHeader."Ship-to Name";
    PurchOrderHeader."Ship-to Name 2" := SalesHeader."Ship-to Name 2";
    PurchOrderHeader."Ship-to Address" := SalesHeader."Ship-to Address";
    PurchOrderHeader."Ship-to Address 2" := SalesHeader."Ship-to Address 2";
    PurchOrderHeader."Ship-to Post Code" := SalesHeader."Ship-to Post Code";
    PurchOrderHeader."Ship-to City" := SalesHeader."Ship-to City";
    PurchOrderHeader."Ship-to Contact" := SalesHeader."Ship-to Contact";
    END;
    // End of the lines.

    PurchOrderHeader.MODIFY;
    ...
  8. Change the code in the EnterPurchaseItemCrossRef function in the Dist. Integration codeunit (5702) as follows:
    Existing code
    ...
    IF Found THEN BEGIN
    "Cross-Reference No." := ItemCrossReference."Cross-Reference No.";
    "Unit of Measure (Cross Ref.)" := ItemCrossReference."Unit of Measure";
    "Cross-Reference Type" := ItemCrossReference."Cross-Reference Type";
    "Cross-Reference Type No." := ItemCrossReference."Cross-Reference Type No.";

    // Delete the following lines.
    IF ItemCrossReference.Description <> '' THEN BEGIN
    Description := ItemCrossReference.Description;
    "Description 2" := '';
    END;
    // End of the lines.

    END ELSE BEGIN
    "Cross-Reference No." := '';
    "Cross-Reference Type" := "Cross-Reference Type"::" ";
    "Cross-Reference Type No." := '';

    // Delete the following lines.
    IF "Variant Code" <> '' THEN BEGIN
    ItemVariant.GET("No.","Variant Code");
    Description := ItemVariant.Description;
    "Description 2" := ItemVariant."Description 2";
    END ELSE BEGIN
    Item.GET("No.");
    Description := Item.Description;
    "Description 2" := Item."Description 2";
    END;
    // End of the lines.

    GetItemTranslation;
    ...
    Replacement code
    ...
    IF Found THEN BEGIN
    "Cross-Reference No." := ItemCrossReference."Cross-Reference No.";
    "Unit of Measure (Cross Ref.)" := ItemCrossReference."Unit of Measure";
    "Cross-Reference Type" := ItemCrossReference."Cross-Reference Type";
    "Cross-Reference Type No." := ItemCrossReference."Cross-Reference Type No.";
    END ELSE BEGIN
    "Cross-Reference No." := '';
    "Cross-Reference Type" := "Cross-Reference Type"::" ";
    "Cross-Reference Type No." := '';
    GetItemTranslation;
    ...
  9. Change the code in the GetSpecialOrders function in the Dist. Integration codeunit (5702) as follows:
    Existing code
    ...
    TESTFIELD("Sell-to Customer No.",SalesHeader."Sell-to Customer No.");
    TESTFIELD("Ship-to Code",SalesHeader."Ship-to Code");

    // Delete the following line.
    PurchHeader.SetShipToForSpecOrder;

    PurchLine.LOCKTABLE;
    ...
    Replacement code
    ...
    TESTFIELD("Sell-to Customer No.",SalesHeader."Sell-to Customer No.");
    TESTFIELD("Ship-to Code",SalesHeader."Ship-to Code");

    // Add the following lines.
    IF DropShptSplOrderExists(SalesHeader) THEN
    CheckAndAddShipToAdd(SalesHeader,TRUE);
    // End of the lines.

    PurchLine.LOCKTABLE;
    ...
  10. Change the code in the TransfldsFromSalesToPurchLine function in the Copy Document Mgt. codeunit (6620) as follows:
    Existing code
    ...
    VALIDATE("Direct Unit Cost");
    END;
    ...
    Replacement code
    ...
    VALIDATE("Direct Unit Cost");

    // Add the following lines.
    Description := FromSalesLine.Description;
    "Description 2" := FromSalesLine."Description 2";
    // End of the lines.

    END;
    ...
  11. Change the code in the Code in the Purch.-Get Drop Shpt. codeunit (76) as follows:
    Existing code 1
    ...
    TESTFIELD("Ship-to Code",SalesHeader."Ship-to Code");

    PurchLine.LOCKTABLE;
    ...
    Replacement code 1
    ...
    TESTFIELD("Ship-to Code",SalesHeader."Ship-to Code");

    // Add the following line.
    IF DropShptSplOrderExists(SalesHeader) THEN
    CheckAndAddShipToAdd(SalesHeader,TRUE);
    // End of the lines.

    PurchLine.LOCKTABLE;
    ...
    Existing code 2
    ...
    CopyDocMgt.TransfldsFromSalesToPurchLine(SalesLine,PurchLine);
    PurchLine.Description := SalesLine.Description;
    PurchLine."Sales Order No." := SalesLine."Document No.";
    ...
    Replacement code 2
    ...
    CopyDocMgt.TransfldsFromSalesToPurchLine(SalesLine,PurchLine);
    PurchLine.Description := SalesLine.Description;

    // Add the following line.
    PurchLine."Description 2" := SalesLine."Description 2";

    PurchLine."Sales Order No." := SalesLine."Document No.";
    ...
  12. Change the code in the InsertReqWkshLine in the Get Sales Orders report (698) as follows:
    Existing code
    ...
    "Sell-to Customer No." := SalesLine."Sell-to Customer No.";
    SalesHeader.GET(1,SalesLine."Document No.");
    IF SpecOrder <> 1 THEN
    ...
    Replacement code
    ...
    "Sell-to Customer No." := SalesLine."Sell-to Customer No.";

    // Add the following lines.
    Description := SalesLine.Description;
    "Description 2" := SalesLine."Description 2";
    // End of the lines.

    SalesHeader.GET(1,SalesLine."Document No.");
    IF SpecOrder <> 1 THEN
    ...
  13. Add a new global variable in the Purchase Header table (38), and then specify the variable as follows:
    • Name: NameAddressDetails
    • DataType: Text
    • Length: 512
  14. Add a new global variable in the Purchase Header table (38), and then specify the variable as follows:
    • Name: NameAddressDetails2
    • DataType: Text
    • Length: 512
  15. Add a new text constant in the Purchase Header table (38), and then specify the text constant as follows:
    • Name: Text051
    • ConstValue: The %1 field on the purchase order %2 must be the same as on sales order %3.
  16. Create a new CheckAndAddShipToAdd function in the Purchase Header table (38). To do this, follow these steps:
    1. Add a new local parameter in the CheckAndAddShipToAdd function in the Purchase Header table (38), and then specify the parameter as follows:
      • Var: No
      • Name: SalesHeader
      • DataType: Record
      • Subtype: Sales Header
    2. Add a new local parameter in the CheckAndAddShipToAdd function in the Purchase Header table (38), and then specify the parameter as follows:
      • Var: No
      • Name: ShowError
      • DataType: Boolean
    3. Add a return value in the CheckAndAddShipToAdd function in the Purchase Header table (38), and then specify the return value as follows:
      • Return Type: Boolean
    4. Add a new local variable in the CheckAndAddShipToAdd function in the Purchase Header table (38), and then specify the variable as follows:
      • Name: PurchLine2
      • DataType: Record
      • Subtype: PurchLine2
    5. Add the following code in the CheckAndAddShipToAdd function in the Purchase Header table (38):
      IF ShowError THEN BEGIN
      PurchLine2.RESET;
      PurchLine2.SETRANGE("Document Type","Document Type"::Order);
      PurchLine2.SETRANGE("Document No.","No.");
      IF NOT PurchLine2.ISEMPTY THEN BEGIN
      IF "Ship-to Name" <> SalesHeader."Ship-to Name" THEN
      ERROR(Text051,FIELDCAPTION("Ship-to Name"),"No.",SalesHeader."No.");
      IF "Ship-to Name 2" <> SalesHeader."Ship-to Name 2" THEN
      ERROR(Text051,FIELDCAPTION("Ship-to Name 2"),"No.",SalesHeader."No.");
      IF ("Ship-to Address" <> SalesHeader."Ship-to Address") THEN
      ERROR(Text051,FIELDCAPTION("Ship-to Address"),"No.",SalesHeader."No.");
      IF ("Ship-to Address 2" <> SalesHeader."Ship-to Address 2") THEN
      ERROR(Text051,FIELDCAPTION("Ship-to Address 2"),"No.",SalesHeader."No.");
      IF ("Ship-to Post Code" <> SalesHeader."Ship-to Post Code") THEN
      ERROR(Text051,FIELDCAPTION("Ship-to Post Code"),"No.",SalesHeader."No.");
      IF ("Ship-to City" <> SalesHeader."Ship-to City") THEN
      ERROR(Text051,FIELDCAPTION("Ship-to City"),"No.",SalesHeader."No.");
      IF ("Ship-to Contact" <> SalesHeader."Ship-to Contact") THEN
      ERROR(Text051,FIELDCAPTION("Ship-to Contact"),"No.",SalesHeader."No.");
      END ELSE BEGIN
      // no purchase line exists
      "Ship-to Name" := SalesHeader."Ship-to Name";
      "Ship-to Name 2" := SalesHeader."Ship-to Name 2";
      "Ship-to Address" := SalesHeader."Ship-to Address";
      "Ship-to Address 2" := SalesHeader."Ship-to Address 2";
      "Ship-to Post Code" := SalesHeader."Ship-to Post Code";
      "Ship-to City" := SalesHeader."Ship-to City";
      "Ship-to Contact" := SalesHeader."Ship-to Contact";
      END;
      END ELSE BEGIN
      NameAddressDetails :=
      SalesHeader."Ship-to Name" + SalesHeader."Ship-to Name 2" +
      SalesHeader."Ship-to Address" + SalesHeader."Ship-to Address 2" +
      SalesHeader."Ship-to Post Code" + SalesHeader."Ship-to City" +
      SalesHeader."Ship-to Contact";
      IF NameAddressDetails2 = '' THEN
      NameAddressDetails2 := NameAddressDetails;
      EXIT(NameAddressDetails2 = NameAddressDetails);
      END;
  17. Create a new DropShptSplOrderExists function in the Purchase Header table (38). To do this, follow these steps:
    1. Add a new local parameter in the DropShptSplOrderExists function in the Purchase Header table (38), and then specify the parameter as follows:
      • Var: No
      • Name: SalesHeader
      • DataType: Record
      • Subtype: Sales Header
    2. Add a return value type in the DropShptSplOrderExists function in the Purchase Header table (38), and then specify the return value as follows:
      • Return Type: Boolean
    3. Add a new local variable in the DropShptSplOrderExists function in the Purchase Header table (38), and then specify the variable as follows:
      • Name: SalesLine2
      • DataType: Record
      • Subtype: Sales Line
    4. Add the following code in the DropShptSplOrderExists function in the Purchase Header table (38):
      // returns TRUE if sales is either Drop Shipment of Special Order
      SalesLine2.RESET;
      SalesLine2.SETRANGE("Document Type",SalesLine2."Document Type"::Order);
      SalesLine2.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine2.SETRANGE("Drop Shipment",TRUE);
      IF NOT SalesLine2.ISEMPTY THEN
      EXIT(TRUE);

      SalesLine2.SETRANGE("Drop Shipment");
      SalesLine2.SETRANGE("Special Order",TRUE);
      EXIT(NOT SalesLine2.ISEMPTY);

Prerequisites

You must have one of the following products installed to apply this hotfix:
  • Microsoft Dynamics NAV 2009 R2
  • Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)

Removal information

You cannot remove this hotfix.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

↑ Back to the top


Keywords: kbqfe, kbmbsquickpub, kbmbspartner, kbmbsmigrate, kbsurveynew, kbnoloc, kbmbscodefix, kb

↑ Back to the top

Article Info
Article ID : 2604388
Revision : 3
Created on : 1/31/2017
Published on : 1/31/2017
Exists online : False
Views : 218