Dynamics GP 2010 Web 服务问题

发布于 2024-12-01 21:30:40 字数 2149 浏览 2 评论 0原文

我正在尝试使用 Web 服务在 Dynamics GP 2010 中创建采购订单。我收到以下错误 VendorItemNumber not setup for ItemKey 首先,我不确定该错误的实际含义。其次,我不确定为什么我会得到它。我的代码如下。有什么建议吗?

Public Sub PO()
    Dim context As Context
    Dim purchaseOrderKey As PurchaseTransactionKey
    Dim vendorKey As VendorKey
    Dim purchaseOrder As PurchaseOrder
    Dim purchaseOrderLine As PurchaseOrderLine
    Dim warehouseKey As WarehouseKey
    Dim quantityOrdered As Quantity
    Dim purchaseOrderCreatePolicy As Policy

    context = gpr.ws.getContext()

    '// Create a purchase transaction key to identify the purchase order
    purchaseOrderKey = New PurchaseTransactionKey()
    purchaseOrderKey.Id = poId

    '// Create a vendor key object to specify the vendor
    vendorKey = New VendorKey()
    vendorKey.Id = "SYN001"

    '// Create a purchase order object
    purchaseOrder = New PurchaseOrder()

    '// Populate the required properties
    purchaseOrder.Key = purchaseOrderKey
    purchaseOrder.VendorKey = vendorKey

    '// Create a purchase order line object for the purchase order object
    purchaseOrderLine = New PurchaseOrderLine()

    '// Create a quantity object to specify the quantity ordered
    quantityOrdered = New Quantity()
    quantityOrdered.Value = 1

    '// Add the quantity to the purchase order line object
    purchaseOrderLine.QuantityOrdered = quantityOrdered

    '// Specify the inventory item being purchased
    purchaseOrderLine.VendorItemNumber = dvi1

    Dim itemKey As ItemKey = New ItemKey()
    itemKey.Id = dvi1
    purchaseOrderLine.ItemKey = itemKey

    '// Create an array to hold the purchase order line object
    Dim lines As PurchaseOrderLine() = New PurchaseOrderLine() {purchaseOrderLine}

    '// Add the array of purchase order lines to the purchase order object
    purchaseOrder.Lines = lines

    '// Get the create policy for purchase order objects
    purchaseOrderCreatePolicy = gpr.GetWebService.GetPolicyByOperation("CreatePurchaseOrder", context)

    '// Create the purchase order
    gpr.GetWebService.CreatePurchaseOrder(purchaseOrder, context, purchaseOrderCreatePolicy)
End Sub

I am trying to create a purchase order in Dynamics GP 2010 using the webservices. I get the following error VendorItemNumber not setup for ItemKey First off, I am not sure what that error actually means. Second off, I am not sure why I am getting it. My code is below. Any suggestions?

Public Sub PO()
    Dim context As Context
    Dim purchaseOrderKey As PurchaseTransactionKey
    Dim vendorKey As VendorKey
    Dim purchaseOrder As PurchaseOrder
    Dim purchaseOrderLine As PurchaseOrderLine
    Dim warehouseKey As WarehouseKey
    Dim quantityOrdered As Quantity
    Dim purchaseOrderCreatePolicy As Policy

    context = gpr.ws.getContext()

    '// Create a purchase transaction key to identify the purchase order
    purchaseOrderKey = New PurchaseTransactionKey()
    purchaseOrderKey.Id = poId

    '// Create a vendor key object to specify the vendor
    vendorKey = New VendorKey()
    vendorKey.Id = "SYN001"

    '// Create a purchase order object
    purchaseOrder = New PurchaseOrder()

    '// Populate the required properties
    purchaseOrder.Key = purchaseOrderKey
    purchaseOrder.VendorKey = vendorKey

    '// Create a purchase order line object for the purchase order object
    purchaseOrderLine = New PurchaseOrderLine()

    '// Create a quantity object to specify the quantity ordered
    quantityOrdered = New Quantity()
    quantityOrdered.Value = 1

    '// Add the quantity to the purchase order line object
    purchaseOrderLine.QuantityOrdered = quantityOrdered

    '// Specify the inventory item being purchased
    purchaseOrderLine.VendorItemNumber = dvi1

    Dim itemKey As ItemKey = New ItemKey()
    itemKey.Id = dvi1
    purchaseOrderLine.ItemKey = itemKey

    '// Create an array to hold the purchase order line object
    Dim lines As PurchaseOrderLine() = New PurchaseOrderLine() {purchaseOrderLine}

    '// Add the array of purchase order lines to the purchase order object
    purchaseOrder.Lines = lines

    '// Get the create policy for purchase order objects
    purchaseOrderCreatePolicy = gpr.GetWebService.GetPolicyByOperation("CreatePurchaseOrder", context)

    '// Create the purchase order
    gpr.GetWebService.CreatePurchaseOrder(purchaseOrder, context, purchaseOrderCreatePolicy)
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不知所踪 2024-12-08 21:30:40

在 Dynamics GP 中,物料必须先与供应商关联,然后才能从该供应商处购买。您应该添加对 CreateItemVendor 方法的调用才能关联该项目在为其创建采购订单之前与供应商联系。

代码示例如下:

        CompanyKey companyKey;
        Context context;
        ItemVendor itemVendor;
        ItemKey itemKey;
        VendorKey vendorKey;
        ItemVendorKey itemVendorKey;
        Policy itemVendorCreatePolicy;

        // Create an instance of the service
        DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

        // Create a context with which to call the service
        context = new Context();

        // Specify which company to use (sample company)
        companyKey = new CompanyKey();
        companyKey.Id = (-1);

        // Set up the context object
        context.OrganizationKey = (OrganizationKey)companyKey;

        // Create an item vendor object
        itemVendor = new ItemVendor();

        // Create an item key to specify the item
        itemKey = new ItemKey();
        itemKey.Id = "128 SDRAM";

        // Create a vendor key to specify the vendor
        vendorKey = new VendorKey();
        vendorKey.Id = "ACETRAVE0001";

        // Create an item vendor key
        itemVendorKey = new ItemVendorKey();
        itemVendorKey.ItemKey = itemKey;
        itemVendorKey.VendorKey = vendorKey;

        // Populate the item vendor objects key property
        itemVendor.Key = itemVendorKey;

        // Get the create policy for item vendor
        itemVendorCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateItemVendor", context);

        // Create the item vendor
        wsDynamicsGP.CreateItemVendor(itemVendor, context, itemVendorCreatePolicy);

        // Close the service
        if(wsDynamicsGP.State != CommunicationState.Faulted)
        {
            wsDynamicsGP.Close();
        }

In Dynamics GP, an item must be associated to a vendor before it can be purchased from that vendor. You should add a call to the CreateItemVendor method in order to associate the item with the vendor prior to creating a purchase order for it.

Code sample below:

        CompanyKey companyKey;
        Context context;
        ItemVendor itemVendor;
        ItemKey itemKey;
        VendorKey vendorKey;
        ItemVendorKey itemVendorKey;
        Policy itemVendorCreatePolicy;

        // Create an instance of the service
        DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

        // Create a context with which to call the service
        context = new Context();

        // Specify which company to use (sample company)
        companyKey = new CompanyKey();
        companyKey.Id = (-1);

        // Set up the context object
        context.OrganizationKey = (OrganizationKey)companyKey;

        // Create an item vendor object
        itemVendor = new ItemVendor();

        // Create an item key to specify the item
        itemKey = new ItemKey();
        itemKey.Id = "128 SDRAM";

        // Create a vendor key to specify the vendor
        vendorKey = new VendorKey();
        vendorKey.Id = "ACETRAVE0001";

        // Create an item vendor key
        itemVendorKey = new ItemVendorKey();
        itemVendorKey.ItemKey = itemKey;
        itemVendorKey.VendorKey = vendorKey;

        // Populate the item vendor objects key property
        itemVendor.Key = itemVendorKey;

        // Get the create policy for item vendor
        itemVendorCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateItemVendor", context);

        // Create the item vendor
        wsDynamicsGP.CreateItemVendor(itemVendor, context, itemVendorCreatePolicy);

        // Close the service
        if(wsDynamicsGP.State != CommunicationState.Faulted)
        {
            wsDynamicsGP.Close();
        }
反话 2024-12-08 21:30:40

只需转到 GP 界面,并将该项目映射到您为其创建采购订单的供应商,并为其创建库存条目。然后再试一次!

just go to GP interface and map this item to the vendor you are creating purchase order for and make entry in inventory for it. then try again !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文