on 01-09-2011 12:35 PM
调用DI 从SaleOrder 生成Invoices, 部分物料报No matching records found (ODBC -2028 )的错误
如果从SBO GUI 上,手动生成的话,没有错误;
调DI 就会有错误,但也不是所有订单行都有错误, 未发现规律
部分关键调用代码是:
SAPbobsCOM.Documents document = (SAPbobsCOM.Documents)DICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
document.CardCode = ((SAPbouiCOM.EditText)m_SboForm.Items.Item("ECardCode").Specific).Value;
document.DocDate = DateTime.Now;
document.TaxDate = DateTime.Now;
document.DocDueDate = DateTime.ParseExact(((SAPbouiCOM.EditText)m_SboForm.Items.Item("EDocDueD").Specific).Value, "yyyyMMdd", null);
SAPbobsCOM.Documents saleorder = (SAPbobsCOM.Documents)DICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
saleorder.GetByKey(int.Parse(DocEntry));
bool IsFirstSelect = true;
for (int i = 0; i <= OrdrTable.Rows.Count - 1; i++)
{
saleorder.Lines.SetCurrentLine(i);
if (!IsFirstSelect)
document.Lines.Add();
document.Lines.ItemCode = OrdrTable.GetValue("ItemCode", i).ToString().Trim();
document.Lines.Quantity = double.Parse(OrdrTable.GetValue("Qty", i).ToString().Trim());
document.Lines.Price = Math.Round(saleorder.Lines.Price, 2, MidpointRounding.AwayFromZero);
document.Lines.DiscountPercent = saleorder.Lines.DiscountPercent;
document.Lines.PriceAfterVAT = Math.Round(saleorder.Lines.PriceAfterVAT,2, MidpointRounding.AwayFromZero);
document.Lines.VatGroup = saleorder.Lines.VatGroup;
document.Lines.WarehouseCode = OrdrTable.GetValue("WhsCode", i).ToString().Trim();
document.Lines.BaseType = 17;
document.Lines.BaseEntry = saleorder.DocEntry;
document.Lines.BaseLine = saleorder.Lines.LineNum;
document.Lines.Currency = saleorder.Lines.Currency;
doctotal = doctotal + double.Parse(OrdrTable.GetValue("LineTotal", i).ToString().Trim());
IsFirstSelect = false;
}
document.DocTotal = Math.Round(doctotal, 2, MidpointRounding.AwayFromZero); ;
document.SalesPersonCode = saleorder.SalesPersonCode;
int lRetCode = document.Add();
if (lRetCode != 0)
{
int temp_int = 0;
string temp_string = "";
DICompany.GetLastError(out temp_int, out temp_string);
SetStatusBarMessageFrame("u751Fu6210u5E94u6536u53D1u7968u5931u8D25uFF1A" + temp_string, SAPbouiCOM.BoMessageTime.bmt_Short, true);
BubbleEvent = false;
return;
}
else
{
SetStatusBarMessageFrame("u751Fu6210u5E94u6536u53D1u7968u6210u529FuFF1A", SAPbouiCOM.BoMessageTime.bmt_Short, false);
}
1.先确认是否取对了DocEntry
saleorder.GetByKey(int.Parse(DocEntry));
2.把document.Lines.BaseEntry = saleorder.DocEntry;
换成document.Lines.BaseEntry = int.Parse(DocEntry);
很有可能sales order都没找到。。。
最好拷贝到发票前确认找到订单
if (saleorder.GetByKey(int.Parse(DocEntry)) )
//订单找到,添加发票
else
//订单没找到,报错
Kind Regards, yatsea
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
我看代码中,Itemcode和Quantity是从OrderTable中取的,而LineNum等又是从saleorder这个对象中取的。
是否可以先检查一下这两者是不是一致的?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
PL10已经有一些日子了,是不是方便升级到最新的8.8 Patch再试一试?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
忘了说了,版本: 8.8 PL10
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.