ODBC-2028错误SAP B1

时间:2018-05-29 13:10:19

标签: sapb1

我正在尝试通过DI API为SAP B1添加采购订单。我的代码正在我的客户端上运行,但我尝试将其作为另一家拥有不同数据的公司的插件。它给出错误:“找不到匹配的记录(ODBC-2028)”。这是我的代码的一部分:

public void createPOrderFor(int id,
                                string itemCode,
                                string itemName,
                                int qty,
                                int satisSip,
                                string cardCode,
                                string cardName,
                                string releaseDate)
    {
        SAPbobsCOM.Documents BO_item;
        BO_item = (SAPbobsCOM.Documents)getCompany().GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
        base.doConnectionInfo();
        server = base.server;
        database = base.database;
        user = base.user;
        pass = base.pass;

        string year = releaseDate.Substring(0, 4);
        string month = releaseDate.Substring(4, 2);
        string day = releaseDate.Substring(6, 2);
        releaseDate = year + "-" + month + "-" + day;

        BO_item.Lines.ItemCode = itemCode;            
        BO_item.Lines.ItemDescription = itemName;         
        BO_item.Lines.Quantity = qty;          
        BO_item.Lines.ShipDate = DateTime.Parse(releaseDate);           
        BO_item.Lines.UserFields.Fields.Item("U_SatisSip").Value = satisSip;           
        BO_item.Lines.Add();
        BO_item.Comments = satisSip + " numaralı satış siparişine istinaden";
        BO_item.CardCode = cardCode;
        BO_item.CardName = cardName;           
        BO_item.NumAtCard = "";
        BO_item.Series = 13;//birincil
        //BO_item.Segment -- it is read only.
        BO_item.TaxDate = DateTime.Now;
        BO_item.DocDate = DateTime.Now;
        BO_item.DocDueDate = DateTime.Parse(releaseDate);
        BO_item.SalesPersonCode = 4;//default Hakan Yılmaz
        BO_item.DocumentsOwner = 4;
        BO_item.DiscountPercent = 0.0;
        BO_item.Address2 = "TURKEY";
        BO_item.Address = "";
        BO_item.TransportationCode = 1;
        BO_item.AgentCode = null;
        BO_item.JournalMemo = "Satınalma siparişleri - " + cardCode;
        BO_item.GroupNumber = 1;//net30 
        BO_item.PaymentMethod = null;
        BO_item.Project = null;
        BO_item.UserFields.Fields.Item("U_SatSip").Value = satisSip;
        var retVal = BO_item.Add();
        int errorCode = 0;
        string errMsg = "";
        if (retVal != 0)
        {
            getCompany().GetLastError(out errorCode, out errMsg);
            SAPbouiCOM.Framework.Application.SBO_Application.StatusBar.SetText("Error: " + errMsg , SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
        }

1 个答案:

答案 0 :(得分:0)

首先删除所有空字段。如果存在无法为其提供值的DI对象字段,则不应将它们设置为等于null。

    BO_item.AgentCode = null;
    BO_item.PaymentMethod = null;
    BO_item.Project = null;

完全删除它们。另请注意Date.Time.Now,而不是以此格式设置日期:20180531作为测试的所有日期字段。

BO_item.DocDate = "20180531"

如果它返回相同的错误,请尝试在SAP Business One演示数据库中进行测试(可以从sap partneredge获取)。

此外,确保您尝试为新客户的数据库中存在的用户定义字段设置值

让我知道它对你有什么用,所以我们可以继续。