sapb1 - ODBC-2028 错误 SAP B1
问题描述
我正在尝试通过 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);
}
解决方案
首先删除所有空字段。如果存在无法为其提供值的 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 获得)。
此外,确保您尝试为其设置值的用户定义字段存在于新客户的数据库中
让我知道它是如何为您工作的,以便我们继续。
推荐阅读
- c++ - C++ 线性分配器和容器边界
- javascript - 在 Browserslist 中为 Babel 添加“未死”会产生不同的结果,即使浏览器是相同的?
- python - AttributeError:当我运行我的代码时,'NoneType' 对象在 python 中没有属性'split'
- c - 应该返回 -1 的 sprintf 的编码错误是什么?
- go - 如何将kafka连接到外部server.ip
- matlab - 如何让我的算法依赖于时间?
- python - pd.DataFrame(list of dicts) 显示 NaN 的干净输入
- react-native - 组件未在本机反应中显示
- java - 类未找到异常 org//h2//Driver
- python - 在熊猫中枢轴后折叠双索引