【问题标题】:Updating Location and ShipQty in Acumatica Shipment Lines更新 Acumatica Shipment Lines 中的位置和 ShipQty
【发布时间】:2016-05-17 09:57:31
【问题描述】:

我在 acumatica webservices 中遇到了这个奇怪的问题,我正在使用 webservices 更新 acumatica 中的现有 Shipments。我的代码应该更新 Location 和 ShippedQty 但无缘无故地更新除了最后一个之外的所有项目。当货件有多个物品时会发生这种情况。请帮我解决这个问题,下面是我的代码和发货屏幕的图像,最后一个项目没有更新。

谢谢。

var commands = new List<Acumatica_LSOne_Integration.SO302000.Command>();
        commands.Add(new SO302000.Value { Value = shipmentNbr, LinkedCommand = shipmentSchema.ShipmentSummary.ShipmentNbr });
        commands.Add(new SO302000.Value { Value = shipmentType, LinkedCommand = shipmentSchema.ShipmentSummary.Type });
        commands.Add(shipmentSchema.DocumentDetails.ShipmentNbr);
        commands.Add(shipmentSchema.DocumentDetails.LineNbr);
        commands.Add(shipmentSchema.DocumentDetails.InventoryID);
        commands.Add(shipmentSchema.DocumentDetails.Warehouse);
        commands.Add(shipmentSchema.DocumentDetails.Location);
        commands.Add(shipmentSchema.DocumentDetails.OrderedQty);
        var soLines = context.Submit(commands.ToArray());

        List<Acumatica_LSOne_Integration.SO302000.Command> commandList = new List<Acumatica_LSOne_Integration.SO302000.Command>();
        for (int index = 0; index < soLines.Length; index++)
        {
            string sShipNbr = soLines[index].DocumentDetails.ShipmentNbr.Value;
            string sLineNbr = soLines[index].DocumentDetails.LineNbr.Value;
            string sInventoryID = soLines[index].DocumentDetails.InventoryID.Value;
            string sWarehouse = soLines[index].DocumentDetails.Warehouse.Value;
            string sLocation = soLines[index].DocumentDetails.Location.Value;
            string sOrderedQty = soLines[index].DocumentDetails.OrderedQty.Value;

            commandList.Add(new SO302000.Key
            {
                ObjectName = shipmentSchema.DocumentDetails.ShipmentNbr.ObjectName,
                FieldName = shipmentSchema.DocumentDetails.ShipmentNbr.FieldName,
                Value = sShipNbr.Trim(), Commit = true                    
            });

            commandList.Add(new SO302000.Key
            {
                ObjectName = shipmentSchema.DocumentDetails.LineNbr.ObjectName,
                FieldName = shipmentSchema.DocumentDetails.LineNbr.FieldName,
                Value = sLineNbr.Trim(), Commit = true                    
            });
            commandList.Add(new SO302000.Value
            {
                Value = vLocation.Trim(),
                LinkedCommand = shipmentSchema.DocumentDetails.Location
            });
            commandList.Add(new SO302000.Value { Value = sOrderedQty, LinkedCommand = shipmentSchema.DocumentDetails.ShippedQty,IgnoreError = true, Commit = true });

        }

        commandList.Add(shipmentSchema.Actions.ConfirmShipmentAction);
        context.Submit(commandList.ToArray());

样本输出:

【问题讨论】:

  • 可能是一个愚蠢的问题,但您是否尝试调试代码并确保您的循环按预期设置所有值?
  • 已经尝试过了,它可以很好地循环和设置值....

标签: web-services acumatica


【解决方案1】:

我猜你的库存允许负数量,默认情况下,当特定仓库中的物品数量为零时,位置将设置为,发货数量为零,正如我看到你的代码,检查这一行代码

string sLocation = soLines[index].DocumentDetails.Location.Value;

如果这个 soLine 检索到一个值,因为我猜这行是它不会更新的原因。

【讨论】:

  • 我不这么认为,我使用另一个位置变量来更新 vLocation 字段。 commandList.Add(new SO302000.Value { Value = vLocation.Trim(), LinkedCommand = shipmentSchema.DocumentDetails.Location });
【解决方案2】:

我实际上提出了一个使用基于合同的 Web 服务运行良好的解决方案。以下是我的示例代码:

using (DefaultSoapClient soapClient = new DefaultSoapClient())
                    {
                        InitializeWebService(soapClient,sAUser,sAPass,vCompany,vBranchID);

                        Shipment shipmentToBeFound = new Shipment
                        {
                            Type = new StringSearch { Value = shipmentType },
                            ShipmentNbr = new StringSearch { Value = shipmentNbr },
                        };
                        Shipment shipment = (Shipment)soapClient.Get(shipmentToBeFound);

                        int iLineNbr =  Int32.Parse(sLineNbr);
                        ShipmentDetail shipmentLine = shipment.Details.Single(
                            orderLineToBeUpdated =>                                
                            orderLineToBeUpdated.LineNbr.Value == iLineNbr);
                            shipmentLine.LocationID = new StringValue { Value = vLocation.Trim() };
                            shipmentLine.ShippedQty = new DecimalValue { Value = decimal.Parse(sOrderedQty) };

                            shipment = (Shipment)soapClient.Put(shipment);

                        soapClient.Logout();

                    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-31
    • 2019-10-22
    • 1970-01-01
    • 1970-01-01
    • 2014-10-16
    • 2022-01-16
    • 1970-01-01
    相关资源
    最近更新 更多