没有完整选择 batch/serial 个数字就无法添加行

Cannot add row without complete selection of batch/serial numbers

错误:(-4014) 没有完整选择 batch/serial 个数字就无法添加行。

DI API SaveDraftToDocument() 的默认功能在 MS SQL 数据库但不是 SAP HANA 上运行良好。

我正在发布带有序列号的交货文件。

SAPbobsCOM.Documents oDrafts;
oDrafts = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
oDrafts.GetByKey(Convert.ToInt32(EditText27.Value));
var count = oDrafts.Lines.Count;
var linenum = oDrafts.Lines.LineNum;
//Validation
#region
var RsRecordCount = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
var sQryRecordCount = String.Format("Select * from \"SANTEXDBADDON\".\"@TEMPITEMDETAILS\" where \"U_DraftNo\" = '{0}'", EditText27.Value);
RsRecordCount.DoQuery(sQryRecordCount);
#endregion

if (count == RsRecordCount.RecordCount)
{
    //LINES
    string ItemCode = "", WhsCode = ""; double Quantity = 0; int index = 0;
    for (int i = 0; i < oDrafts.Lines.Count; i++)
    {
        oDrafts.Lines.SetCurrentLine(index);
        ItemCode = oDrafts.Lines.ItemCode;
        //SERIAL NUMBERS
        var RsSerial = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
        string table = "\"@TEMPSERIALS\"";
        var sQrySerial = String.Format(
            "Select \"U_ItemCode\" , \"U_DistNumber\" from \"SANTEXDBADDON\".\"@TEMPSERIALS\" where " +
            "\"U_DraftNo\" = '{0}' and \"U_ItemCode\" = '{1}'", EditText27.Value, ItemCode);
            RsSerial.DoQuery(sQrySerial);
        int serialindex = 1, lineindex = 0;
        #region
        if (RsSerial.RecordCount > 0)
        {
            while (!RsSerial.EoF)
            {
                //OSRN SERIALS
                var RsSerialOSRN = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                var sQrySerialOSRN = String.Format(
                    "Select * from OSRN where \"DistNumber\" = '{0}' and \"ItemCode\" = '{1}'"
                    , RsSerial.Fields.Item("U_DistNumber").Value.ToString(), ItemCode);
                RsSerialOSRN.DoQuery(sQrySerialOSRN);

                oDrafts.Lines.SerialNumbers.SetCurrentLine(0);

                oDrafts.Lines.SerialNumbers.BaseLineNumber = oDrafts.Lines.LineNum;

                oDrafts.Lines.SerialNumbers.SystemSerialNumber =
                    Convert.ToInt32(RsSerialOSRN.Fields.Item("SysNumber").Value.ToString());

                oDrafts.Lines.SerialNumbers.ManufacturerSerialNumber =
                    RsSerialOSRN.Fields.Item("DistNumber").Value.ToString();

                oDrafts.Lines.SerialNumbers.InternalSerialNumber =
                    RsSerialOSRN.Fields.Item("DistNumber").Value.ToString();

                oDrafts.Lines.SerialNumbers.Quantity = 1;
                
                if (RsSerial.RecordCount != serialindex)
                {
                    Application.SBO_Application.StatusBar.SetText("INTERNAL NO  " + oDrafts.Lines.SerialNumbers.InternalSerialNumber, SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
                    oDrafts.Lines.SerialNumbers.Add();
                    serialindex++;
                    lineindex++;
                }
                RsSerial.MoveNext();
            }
        }
        #endregion
        index++;
    }
    var status = oDrafts.SaveDraftToDocument();

    if (status == 0)
    {
        oDrafts.Remove();
        Application.SBO_Application.StatusBar.SetText("Delivery Posted Successfully !", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
    }
    else
    {
        int code = 0; string message = "";
        oCompany.GetLastError(out code, out message);
        Application.SBO_Application.SetStatusBarMessage(message, SAPbouiCOM.BoMessageTime.bmt_Medium, true);
    }
}`

您发布的错误说明了问题所在。您正在尝试交付产品,但未包括所有 serial/batch 个数字。

我认为没有足够的信息可以确定问题出在哪里,但这里有一些提示:

您正在读取自定义 table 的序列号。您正在阅读的值是否有效?例如,另一个用户是否可以将它们添加到不同的订单中?这些值可以用于不同的产品吗?

您指定的序列号数量是否正确?是否有可能该行的商品数量多于您添加的序列号数量?

相信错误信息,直到你能证明它是错误的。这似乎不是 HANA 问题(我们广泛使用 HANA),这是您提供的数据的逻辑问题。

如果您不能轻易确定问题所在,您可能需要捕获更多调试信息来帮助您。