将 Bin/Lot/Serial 项目添加到 Acumatica 装运行我能够通过 Web 服务创建 Acumatica 装运,但在为网格中的每一行添加 Bin/Lot Number 时遇到问题。如果我在装运中只有一个文档详细信息行,它可以正常工作,但是当文档详细信息中有多个行时,代码似乎不起作用。请在下面找到我用来实现此目的的 Acumatica 代码。
SO302000Content soShipcontent = content.SO302000GetSchema();
List<Command> scmds = new List<Command>();
List<LineDetails> splits = new List<LineDetails>();
CreateShipmentHeader(soShipcontent, hparams, ref scmds, Ordernumber);
var shipmentresults = content.SO302000Submit(scmds.ToArray());
if (shipmentresults != null && shipmentresults.Length > 0)
{
int linen = 0;
List<Command> cmds = new List<Command>();
foreach (var row in shipmentresults)
{
SO302000Content c = (SO302000Content)row;
cmds.Add(new Value { Value = linen.ToString(), LinkedCommand = soShipcontent.AddSalesOrder.ServiceCommands.RowNumber });
cmds.Add(new Value { Value = "True", LinkedCommand = soShipcontent.AddSalesOrder.Selected, Commit = true });
LineDetails ld = details.Find(x => x.InventoryId == c.AddSalesOrder.InventoryID.Value.ToString().Trim());
if (ld != null)
{
LineDetails splitno = new LineDetails();
splitno.InventoryId = ld.InventoryId;
splitno.Location = ld.Location;
splitno.LotNo = ld.LotNo;
splitno.Quantity = c.AddSalesOrder.Quantity.Value.ToString().Trim();
splitno.LineNumber = (linen).ToString();
splits.Add(splitno);
}
linen++;
}
cmds.Add(soShipcontent.Actions.AddSO);
content.SO302000Submit(cmds.ToArray());
foreach (LineDetails s in splits)
{
List<Command> cmdsplit = new List<Command>();
cmdsplit.Add(new Value { Value = s.LineNumber, LinkedCommand = soShipcontent.BinLotSerialNumbers.ServiceCommands.RowNumber });
cmdsplit.Add(new Value { Value = s.InventoryId, LinkedCommand = soShipcontent.BinLotSerialNumbers.InventoryID, Commit = true });
cmdsplit.Add(new Value { Value = s.Location, LinkedCommand = soShipcontent.BinLotSerialNumbers.Location, Commit = true });
cmdsplit.Add(new Value { Value = s.LotNo, LinkedCommand = soShipcontent.BinLotSerialNumbers.LotSerialNbr });
cmdsplit.Add(new Value { Value = s.Quantity, LinkedCommand = soShipcontent.BinLotSerialNumbers.Quantity });
content.SO302000Submit(cmdsplit.ToArray());
}
}
List<Command> cmds1 = new List<Command>();
string shipmentnbr = string.Empty;
cmds1.Add(soShipcontent.Actions.Save);
cmds1.Add(soShipcontent.ShipmentSummary.ShipmentNbr);
content.SO302000Submit(cmds1.ToArray());
我也试过下面的代码:
cmds.Add(soShipcontent.BinLotSerialNumbers.ServiceCommands.NewRow);
cmdsplit.Add(new Value { Value = s.Location, LinkedCommand = soShipcontent.BinLotSerialNumbers.Location});
cmdsplit.Add(new Value { Value = s.LotNo, LinkedCommand = soShipcontent.BinLotSerialNumbers.LotSerialNbr });
cmdsplit.Add(new Value { Value = s.Quantity, LinkedCommand = soShipcontent.BinLotSerialNumbers.Quantity, Commit = true });
cmdsplit.Add(new Value { Value = s.InventoryId, LinkedCommand = soShipcontent.BinLotSerialNumbers.InventoryID });
cmdsplit.Add(new Key { Value = "='" + s.InventoryId + "'", FieldName = soShipcontent.DocumentDetails.InventoryID.FieldName, ObjectName = soShipcontent.DocumentDetails.InventoryID.ObjectName });