在Acumatica中使用API​​输入序列号在装运文档(SO302000)中

时间:2015-07-14 02:57:30

标签: acumatica

任何人都可以帮我解决以下代码,这些代码试图输入包含串行和非串行项目的货件。我收到的错误是“PX.Data.PXException:错误#246:无法提交拆分行。”这与序列分配有关但我无法指出问题来自。

SO302000Content SO302000 = oScreen.SO302000GetSchema();
oScreen.SO302000Clear();

SO302000.Actions.AddSO.Commit = true;
SO302000.AddSalesOrder.Selected.LinkedCommand = null;
SO302000.DocumentDetails.InventoryID.LinkedCommand = null;

List<Command> oCmds = new List<Command>();

//Create Header.
oCmds.Add(SO302000.Actions.Insert);
oCmds.Add(new Value { Value = sCardCode, LinkedCommand = SO302000.ShipmentSummary.Customer, Commit = true });
oCmds.Add(new Value { Value = sCardLocation, LinkedCommand = SO302000.ShipmentSummary.Location });
oCmds.Add(new Value { Value = sWhsCode, LinkedCommand = SO302000.ShipmentSummary.WarehouseID });

oCmds.Add(SO302000.Actions.Save);

//Create Lines.
foreach (DataRow dR in ds.Tables[0].Rows)
{
  dPackQty = Convert.ToDouble(dR["QtyPacked"]);

  if (sSONbr == dR["SONbr"].ToString() && sItemCode == dR["ItemCode"].ToString())
  {
    dCount = dCount + 1;
  }
  else
  {
    sSONbr = dR["SONbr"].ToString();
    sItemCode = dR["ItemCode"].ToString().Trim();
    dCount = 0;

    //oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.AddSalesOrderOperation.ServiceCommands.DialogAnswer, Commit = true });
    oCmds.Add(new Value { Value = "SO", LinkedCommand = SO302000.AddSalesOrderOperation.OrderType });
    oCmds.Add(new Value { Value = sSONbr, LinkedCommand = SO302000.AddSalesOrderOperation.OrderNbr });
    oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.AddSalesOrder.ServiceCommands.DialogAnswer, Commit = true });
    oCmds.Add(new Key { Value = sItemCode, FieldName = SO302000.AddSalesOrder.InventoryID.FieldName, ObjectName = SO302000.AddSalesOrder.InventoryID.ObjectName });
    oCmds.Add(new Value { Value = "True", LinkedCommand = SO302000.AddSalesOrder.Selected, Commit = true });

    oCmds.Add(SO302000.Actions.AddSO);

    oCmds.Add(new Key { Value = "='" + sSONbr + "'", FieldName = SO302000.DocumentDetails.OrderNbr.FieldName, ObjectName = SO302000.DocumentDetails.OrderNbr.ObjectName });
    oCmds.Add(new Key { Value = "='" + sItemCode + "'", FieldName = SO302000.DocumentDetails.InventoryID.FieldName, ObjectName = SO302000.DocumentDetails.InventoryID.ObjectName });
    oCmds.Add(new Value { Value = "0", LinkedCommand = SO302000.DocumentDetails.ShippedQty, Commit = true });
  }

  if (dR["IsSerial"].ToString() == "Y")
  {
    oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.Allocations.ServiceCommands.DialogAnswer, Commit = true });
    oCmds.Add(new Value { Value = dCount.ToString(), LinkedCommand = SO302000.Allocations.ServiceCommands.RowNumber, Commit = true });
  oCmds.Add(new Value { Value = dR["Serial"].ToString(), LinkedCommand = SO302000.Allocations.LotSerialNbr, Commit = true });
oCmds.Add(new Value { Value = dPackQty.ToString(), LinkedCommand = SO302000.Allocations.Quantity, Commit = true });
}
else
{
  oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.Allocations.ServiceCommands.DialogAnswer, Commit = true });
  oCmds.Add(new Value { Value = dPackQty.ToString(), LinkedCommand = SO302000.Allocations.Quantity, Commit = true });
}

}
oCmds.Add(SO302000.Actions.Save);
//oCmds.Add(PO302000.DocumentSummary.TotalQty);
//oCmds.Add(PO302000.DocumentSummary.TotalAmt);
oScreen.SO302000Submit(oCmds.ToArray());

在尝试更改处理Non Serial项目的代码时,使用SO302000.DocumentDetails.ShippedQty而不是SO302000.Allocations.Quantity,它会返回另一个错误: “PX.Data.PXRowPersistingException:错误#4:'LineType'可能不为空。” 不确定这意味着什么。

非常感谢帮助:) ģ

1 个答案:

答案 0 :(得分:0)

请看一下

            Content SO302000 = context.GetSchema();
        context.Clear();

        Content[] result = context.Submit(
            new Command[]
            {
                new Value { Value = "001043", LinkedCommand = SO302000.ShipmentSummary.ShipmentNbr, Commit = true },
                new Value { Value = "000819", LinkedCommand = SO302000.DocumentDetails.OrderNbr, Commit = true},
                new Value { Value = "OK", LinkedCommand = SO302000.BinLotSerialNumbers.ServiceCommands.DialogAnswer, Commit = true },
                SO302000.BinLotSerialNumbers.ServiceCommands.NewRow,
                new Value { Value = "0-_", LinkedCommand = SO302000.BinLotSerialNumbers.Subitem },
                new Value { Value = "WR01", LinkedCommand = SO302000.BinLotSerialNumbers.Location },
                new Value { Value = "17SNR000751", LinkedCommand = SO302000.BinLotSerialNumbers.LotSerialNbr },
                SO302000.Actions.LSSOShipLineBinLotSerial,
                SO302000.Actions.Save
            }
        );
        Console.WriteLine();