2016-05-13 33 views
0

我在acumatica webservices中遇到這個奇怪的問題,我正在使用webservices更新acumatica中的現有貨件。我的代碼應該更新Location和ShippedQty,但沒有理由更新除最後一個之外的所有項目。它發生在貨件有多個項目時。請幫我解決這個問題,下面是我的代碼和最後一個項目未更新的貨件屏幕圖像。更新Acumatica貨運線的地點和發貨量

謝謝。

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()); 

樣本輸出: enter image description here

+0

可能是一個愚蠢的問題,但您是否嘗試調試代碼並確保您的循環設置了所有預期的值? – Hybridzz

+0

試圖已經和它循環,並設置好值.... –

回答

0

我已經想出了一個可以很好地使用基於合同的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(); 

        } 
0

我猜你已經可以在你的庫存負值,默認情況下,當一個項目有一個特定倉庫的位置將作爲集和的出貨數量數量爲零零和正如我所看到你的代碼,檢查此行代碼

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

如果這soLine retreives一個值,因爲我猜這條線是它不會更新的原因。

+0

我不這麼認爲,即時通訊使用另一個位置變量來更新字段是vLocation。 'commandList.Add(new SO302000.Value { Value = vLocation.Trim(), LinkedCommand = shipmentSchema.DocumentDetails.Location });'' –