on 01-03-2024 10:03 AM
Hi there
I am relatively new to SAP and during and exercise for training, I get this error while issuing an Add for the .Document method.
Invalid Record Offset (ODBC -2010)
I cannot find any information regarding this error or how to fix it.
I have searched every resource offered and there are posts for a slew of other error codes but not for -2010.
I am using DI API for SAP Business One 10.0 with SQL Server 2019.
The only other question I noticed with this specific error was posted by MD Amall on 2022/07/19 but I do not see a resolution to the question. https://answers.sap.com/questions/13684294/updating-udf-at-row-level-and-approval-new-feature.html
Please could I ask to be pointed in the right direction to resolving this error?
Hi ankit.chauhan1
I figured it out.
I was exceeding the size of the Sales Order Lines.
My for loop initializes the counter to zero and there are 2 line in the Sales Order. This means that the loop was being executed 3 times instead of 2.
I solved the issue by changing the conditions of the for loop to:
for (int i = 0; i <= oSO.Lines.Count -1; i++)
making it while i <= count minus one.
Thank you so much for your help! I truly do appreciate it!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ankit.chauhan1
No problem
The Order_Click generates the order that will be used in Invoice_Click. The variable MySalesInvoice is created to be used globally.
oCompany is set when the connection is created.
I have placed ******** as a suffix on the line where the error occurs.
private void Order_Click(object sender, EventArgs e)
{
SAPbobsCOM.Documents oSO;
oSO = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
oSO.CardCode = "C20000";
oSO.DocDueDate = DateTime.Today;
oSO.Comments = "Insert Sales Order Comment";
// Now Document_Lines...
oSO.Lines.ItemCode = "A00001";
oSO.Lines.Quantity = 2;
oSO.Lines.Price = 100;
oSO.Lines.Add();
oSO.Lines.ItemCode = "A00002";
oSO.Lines.Quantity = 3;
oSO.Lines.Price = 100;
int ret = oSO.Add();
if (ret == 0)
{
oCompany.GetNewObjectCode(out MySalesOrder);
MessageBox.Show("Add Sales Order Successful - " + MySalesOrder);
}
else
{
MessageBox.Show("Add Sales Order Failed: " + oCompany.GetLastErrorDescription());
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSO);
oSO = null;
}
private void Invoice_Click(object sender, EventArgs e)
{
SAPbobsCOM.Documents oSO;
SAPbobsCOM.Documents oInv;
oSO = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
oInv = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oSO.GetByKey(Int32.Parse(MySalesOrder));
oInv.CardCode = oSO.CardCode;
for (int i = 0; i <= oSO.Lines.Count; i++)
{
oInv.Lines.BaseEntry = oSO.DocEntry;
oInv.Lines.BaseLine = i;
oInv.Lines.BaseType = 17;
oInv.Lines.Add();
}
int ret = oInv.Add();
if (ret == 0)
{
oCompany.GetNewObjectCode(out MySalesInvoice);
MessageBox.Show("Added Invoice Successfully");
}
else
{
MessageBox.Show("Add Invoice Failed: " + oCompany.GetLastErrorDescription());********
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSO);
oSO = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject(oInv);
oInv = null;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
109 | |
15 | |
10 | |
5 | |
4 | |
3 | |
3 | |
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.