GP Web服务:更新销售订单以包括未正确分配地段的地段信息

时间:2018-11-06 00:32:43

标签: web-services dynamics-gp

我正在为GP编写Web服务集成。我正在使用UpdateSalesOrder方法,使用销售订单ID提取现有的销售订单对象,并提供一组新的SalesOrderLines(已填写手数)。

目标是我们的系统控制订单/批次信息,并且我们正在导出信息以更新GP销售订单及其行。对于订单,我们导出项目键,其批次键,批次数量和项目数量(批次总数),并希望在GP中进行这些分配。

我有一个基本测试:更新具有1个行项目和1个项目的销售订单。在我的C#代码中,我将SalesOrderLine数量,QuantumAllocated,QuantityFulfilled设置为5,并且SalesOrderLine的唯一手数也设置为5。

我收到“已完成的全部数量与已完成的销售线不匹配。 AllocateLotBehavior =1。”

我检查了taSopLotAuto的SQL跟踪,发现@ I_vQUANTITY = 5.00000; @ I_vQTYFULFI =默认(看起来可能是原因)

  • 如果发送的@v_QTYFULFI必须是行项目(5)上的值,我该怎么做? (来自Web服务的SalesLineLot对象仅公开数量)
  • UpdateSalesOrder的“分配批次行为”设置为“手动”。
  • 订单项数量=订单项上的手数总和(在我的测试中,订单项数量= 5,手数= 5)

这是我的代码段,用于生成订单项和批次信息。

        int itemSeq = 0;

        // Create New Sales Order Lines
        foreach (var item in shipmentItems)
        {
          SalesOrderLine gpSalesOrderNewLine = new SalesOrderLine();

          gpSalesOrderNewLine.ItemKey = new ItemKey { Id = item.ItemID };

          gpSalesOrderNewLine.QuantityFulfilled = new Quantity { Value = decimal.Parse(item.Quantity) };
          gpSalesOrderNewLine.QuantityAllocated = new Quantity { Value = decimal.Parse(item.Quantity) };
          gpSalesOrderNewLine.QuantityToInvoice = new Quantity { Value = decimal.Parse(item.Quantity) };
          gpSalesOrderNewLine.Quantity = new Quantity { Value = decimal.Parse(item.Quantity) };

          SalesLineKey slKey = new SalesLineKey();
          slKey.SalesDocumentKey = sdKey;
          slKey.CompanyKey = cKey;

          gpSalesOrderNewLine.Key = slKey;
          gpSalesOrderNewLine.Key.LineSequenceNumber = itemSeq;

          // Get Lots from XML
          var shipmentItemLots = from shipLot in item.Lots.Descendants("Lot")
                                   select new
                                   {
                                     LotID = shipLot.Descendants("LotID").First().Value,
                                     LotQuantity = shipLot.Descendants("LotQuantity").First().Value,
                                   };

          // Loop through item's lots, each lot generates an item line and an item lot line with the lot level quantity.
          if (shipmentItemLots.Count() > 0)
          {
            List<SalesLineLot> inventoryLots = new List<SalesLineLot>();

            int lotSeq = 0;
            foreach (var lot in shipmentItemLots)
            {
              // Create Lot Info
              SalesLineLot inventoryLot = new SalesLineLot();
              inventoryLot.LotNumber = lot.LotID;
              inventoryLot.Quantity = new Quantity { Value = decimal.Parse(lot.LotQuantity) };

              inventoryLot.Key = new SalesLineLotKey();
              inventoryLot.Key.SalesLineKey = slKey;
              inventoryLot.Key.SequenceNumber = lotSeq;
              inventoryLot.Key.CompanyKey = cKey;

              inventoryLots.Add(inventoryLot);
              gpSalesOrderNewLine.Lots = inventoryLots.ToArray();

              lotSeq++;
            }
          }
          else
          {
            string errorMessage = String.Format("Product {0}: Could not find lots in exported XML.", item.ItemID);
            throw new Exception(errorMessage);
          }


          gpSalesOrderNewLines.Add(gpSalesOrderNewLine);
          itemSeq++;
        }

        // gpSalesOrderNewLines is added to a gpSalesOrder object, and UpdateSalesOrder is called below. Everything works, except for getting Lots allocated

我已经对该代码进行了大量调整,并遇到了履行不匹配问题,或者,如果我可以设法更新销售订单,则不会使用我存储在SalesOrder对象中的数量进行批次分配

0 个答案:

没有答案