将Bin / Lot / Serial项目添加到Acumatica装运行

时间:2014-08-19 16:13:42

标签: erp acumatica

将Bin / Lot / Serial项目添加到Acumatica装运行 我可以通过Web服务创建Acumatica货件,但是在为网格中的每一行添加Bin /批号时遇到问题。如果我在发货时只有一个文档明细行,它工作正常,但当文档详细信息中有多行时,代码似乎不起作用。请在下面找到我用来实现此目的的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 });

1 个答案:

答案 0 :(得分:0)

实际上我并没有真正关注你的代码,但我会说acumatica一个指定SN自动取决于项目设置。否则,您可以手动分配SN。

最简单的示例是在详细级别上有qty = 1时,请参阅下面的代码

            Content[] result = context.Submit(
            new Command[]
            {
                new Value { Value = "000200", LinkedCommand = SO302000.ShipmentSummary.ShipmentNbr, Commit = true },

                //navigate to line
                new Key
                {
                    ObjectName = SO302000.DocumentDetails.InventoryID.ObjectName,
                    FieldName = SO302000.DocumentDetails.InventoryID.FieldName,
                    Value = "='INCLUTA009'"
                },

                new Value { Value = "20SP0610", LinkedCommand = SO302000.DocumentDetails.LotSerialNbr, Commit = true },

                SO302000.Actions.Save
            }
        );