1 - A Sales Order draft created with an approval process.
2 - Approver approve the document through the sap client.
3 - The following code snippet gives error on line oDrf.SaveDraftToDocument(); Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();
oCompany.Server = "192.***";
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012;
oCompany.CompanyDB = "SBOTEST";
oCompany.UserName = "username";
oCompany.Password = "password";
int ret = oCompany.Connect();
if (ret == 0)
{
SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService();
SAPbobsCOM.Documents oDrf = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
oDrf.GetByKey(4427);
oDrf.SaveDraftToDocument() != 0
}
I have been trying to solve the problems for ages, but no luck so far.
I have tried to removing DI Api both x32 and x64 versions. I deleted the file called SM_OBS_DLL from all the temps. I removed the reference from the project. I clean the project. I have make sure that there is no Interlop SAPbobsCOM file. I reinstalled the DI Api x32 and x64, reboot the server. Still same issue on the same line.
I have changed the approval process still same issue.
I have tried with different users, no luck.
I have look up almost all similar problems from the sap forum, but couldn't find any solution that works in my case