cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Record Offset

benita_perkins
Discoverer
0 Kudos

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?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi benita.perkins,

Can you share the code which you are using?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Accepted Solutions (0)

Answers (2)

Answers (2)

benita_perkins
Discoverer
0 Kudos

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!!

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi benita.perkins,

Glad to know that the issue has been resolved for you.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

benita_perkins
Discoverer
0 Kudos

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;

}

Ro24
Discoverer
0 Kudos
Hi there, I’m a new member of SAP community, I tried to import AR invoices linked to Sale order via DTW facing error code invalid record offset (ODBC-2010/65171). Also, i’m using SAP DI API Business one 10.0 with SQL server 2017. I’m looking for relevant post and solutions to solve it but cannot find any help regarding this error. If any expert member see my inquiry here, please give me some solutions. Best regards,