cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 - The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

0 Kudos

Hi,

I am trying to update more than 500 Delivery documents but I am getting RPC error. It's working on the sap b1 server but not working on the workstation. I am using SAP B1 v10 FP2105.

This is the error.

System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) at SAPbobsCOM.IDocuments.Update()

This is my code. I noticed that the memory is increasing every time it loops. I don't know why because I am releasing the object every loop.

oCompany.StartTransaction();
String newCost = oForm.DataSources.UserDataSources.Item("dsCost").Value.ToString();
var updateErrorCode=0;
for (int i = 0; i < dtData.Rows.Count; i++)
{
	if (dtData.Rows[i]["CheckBox"].ToString() == "Y")
	{
		SAPbobsCOM.Documents oDeliveryNote;
		SAPbobsCOM.Document_Lines oLines;
		oDeliveryNote = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);
		oApp.SetStatusBarMessage("Updating Delivery No. " + dtData.Rows[i]["DocNum"].ToString(), SAPbouiCOM.BoMessageTime.bmt_Short, false);
		if (oDeliveryNote.GetByKey(Int32.Parse(dtData.Rows[i]["DocEntry"].ToString())))
		{
			SAPbobsCOM.Field f1 = oDeliveryNote.UserFields.Fields.Item("U_UPDATED");
			f1.Value = "YES";
			oLines = oDeliveryNote.Lines;
			for (int x = 0; x < oLines.Count; x++)
			{
				oLines.SetCurrentLine(x);
				if (oLines.ItemCode == dtData.Rows[i]["ItemCode"].ToString())
				{
					oLines.GrossBuyPrice = Double.Parse(oForm.DataSources.UserDataSources.Item("dsCost").Value);
				}
			}
			updateErrorCode =oDeliveryNote.Update();
			System.Runtime.InteropServices.Marshal.ReleaseComObject(oDeliveryNote);
			System.Runtime.InteropServices.Marshal.ReleaseComObject(oLines);
			System.Runtime.InteropServices.Marshal.ReleaseComObject(f1);
			oDeliveryNote = null;
			oLines = null;
			f1 = null;
			GC.Collect();a

		}
	}
}
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);<br>

Thank you.

Regards,

Raphael

amontella96
Active Contributor
0 Kudos

Hi raelmendoza

just a comment, try to check this thread which is very similar

hope it helps!A

View Entire Topic
ozer_aydin
Explorer
0 Kudos

Hi,

i think the transaction crashed the system. you can try without transaction..

Or you can execute the program with only 1 user login the system.