An apology for my English, I'm insert Invoices but in some I get this error:
Error: (-10) In "To Whse" fields
This is part of the code that I use to add and works fine, only in some Invoices does not work.
public static int syncInvoices(DataRow stObject, DataTable stLinesObject) { oInvoices = (SAPbobsCOM.Documents)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)); oInvoices.Comments = stObject["Comments"].ToString(); oInvoices.DocDate = new DateTime(Convert.ToInt32(stObject["DocDateAnio"].ToString()), Convert.ToInt32(stObject["DocDateMes"].ToString()), Convert.ToInt32(stObject["DocDateDia"].ToString())); oInvoices.NumAtCard = "Fac: " + stObject["NumAtCard"].ToString() +"-"+ stObject["DocDate"].ToString(); oInvoices.CardCode = stObject["CardCode"].ToString(); for (int i=0; i<stLinesObject.Rows.Count; ++i) { oInvoices.Lines.ItemCode = stLinesObject.Rows<i>["ItemCode"].ToString(); oInvoices.Lines.Quantity = Convert.ToDouble(stLinesObject.Rows<i>["Quantity"].ToString()); oInvoices.Lines.UnitPrice = Convert.ToDouble(stLinesObject.Rows<i>["UnitPrice"].ToString()); oInvoices.Lines.DiscountPercent = Convert.ToDouble(stLinesObject.Rows<i>["DiscountPercent"].ToString()); oInvoices.Lines.TaxCode = stLinesObject.Rows<i>["TaxCode"].ToString(); oInvoices.Lines.TaxPercentagePerRow = Convert.ToDouble(stLinesObject.Rows<i>["TaxPercentagePerRow"].ToString()); oInvoices.Lines.Add(); } int DocNum = 0; lRetCode = oInvoices.Add(); if (lRetCode != 0) oCompany.GetLastError(out lErrCode, out sErrMsg); else DocNum = oInvoices.DocNum; return DocNum; }
Any ideas why?
Hi,
In first view i have doubt that you have to changes in your loop as:
for (int i=0; i<stLinesObject.Rows.Count; ++i) { If (i > 0) Then oInvoices.Lines.Add(); End If oInvoices.Lines.ItemCode = stLinesObject.Rows<i>["ItemCode"].ToString(); oInvoices.Lines.Quantity = Convert.ToDouble(stLinesObject.Rows<i>["Quantity"].ToString()); oInvoices.Lines.UnitPrice = Convert.ToDouble(stLinesObject.Rows<i>["UnitPrice"].ToString()); oInvoices.Lines.DiscountPercent = Convert.ToDouble(stLinesObject.Rows<i>["DiscountPercent"].ToString()); oInvoices.Lines.TaxCode = stLinesObject.Rows<i>["TaxCode"].ToString(); oInvoices.Lines.TaxPercentagePerRow = Convert.ToDouble(stLinesObject.Rows<i>["TaxPercentagePerRow"].ToString()); }
also try to post with same data you are passing through this code via UI SAP invoice screen and look whether it prompts anything..
regards:
Sandy
Hello
Do you have a default warehouse set for these items you are issuing in the invoice?
The error messages says, that th warehouse is not defined in the document!
You may add the warehouse into you code in the document lines, and it will work properly
oInvoices.Lines.WareHouse= stLinesObject.Rows<i>["Warehouse"].ToString();
Regards
János
Add a comment