ODBC-2028 错误 SAP B1
ODBC-2028 Error SAP B1
我正在尝试通过 DI API 为 SAP B1 添加采购订单。我的代码适用于我的客户,但我尝试将其作为另一家拥有不同数据的公司的插件。它给出了错误:"No matching records found(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);
}
首先删除所有空字段。如果存在您无法为其提供值的 DI 对象字段,则不应将它们设置为 null。
BO_item.AgentCode = null;
BO_item.PaymentMethod = null;
BO_item.Project = null;
完全删除它们。也不要 Date.Time.Now
尝试以这种格式设置日期:20180531
用于所有日期字段作为测试。
BO_item.DocDate = "20180531"
如果它 returns 同样的错误,请尝试在 SAP Business One 演示数据库(可以从 sap partneredge 获得)中对此进行测试。
此外,请确保您尝试为其设置值的用户定义字段存在于新客户的数据库中
让我知道它是如何为您服务的,以便我们继续。
我正在尝试通过 DI API 为 SAP B1 添加采购订单。我的代码适用于我的客户,但我尝试将其作为另一家拥有不同数据的公司的插件。它给出了错误:"No matching records found(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);
}
首先删除所有空字段。如果存在您无法为其提供值的 DI 对象字段,则不应将它们设置为 null。
BO_item.AgentCode = null;
BO_item.PaymentMethod = null;
BO_item.Project = null;
完全删除它们。也不要 Date.Time.Now
尝试以这种格式设置日期:20180531
用于所有日期字段作为测试。
BO_item.DocDate = "20180531"
如果它 returns 同样的错误,请尝试在 SAP Business One 演示数据库(可以从 sap partneredge 获得)中对此进行测试。
此外,请确保您尝试为其设置值的用户定义字段存在于新客户的数据库中
让我知道它是如何为您服务的,以便我们继续。