Hi
I am trying to rollback the Inventory Transfer Transaction from my code yet the entry is getting saved. I am pasting my code below. Any help will be appreciated.
private string Create_InvTransfer_BeforeSave(SAPbouiCOM.Form oform, string Type, string Warehouse, int QCDocentry) { string DisplayError = ""; try { oEdit1 = (SAPbouiCOM.EditText)oform.Items.Item("txtDocEnt").Specific; oEdit2 = (SAPbouiCOM.EditText)oform.Items.Item("txtDocNum").Specific; oComboBox1 = (SAPbouiCOM.ComboBox)oform.Items.Item("cmbPrdCd").Specific; oEdit4 = (SAPbouiCOM.EditText)oform.Items.Item("txtInspQty").Specific; if (Type == "Approve") { oEdit3 = (SAPbouiCOM.EditText)oform.Items.Item("txtApprQty").Specific; oComboBox = (SAPbouiCOM.ComboBox)oform.Items.Item("cmbAppWH").Specific; } else if (Type == "Sample") { oEdit3 = (SAPbouiCOM.EditText)oform.Items.Item("txtQcSmp").Specific; oComboBox = (SAPbouiCOM.ComboBox)oform.Items.Item("cmbSamWH").Specific; } else if (Type == "Reject") { oEdit3 = (SAPbouiCOM.EditText)oform.Items.Item("txtManRej").Specific; oComboBox = (SAPbouiCOM.ComboBox)oform.Items.Item("cmbRejWH").Specific; } int RetVal = 0; string ErrMsg = ""; int ErrCode = 0; oCompany.StartTransaction(); SAPbobsCOM.StockTransfer oInvTrans = default(SAPbobsCOM.StockTransfer); oInvTrans = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); oInvTrans.DocDate = DateTime.Now; oInvTrans.FromWarehouse = Warehouse; oInvTrans.ToWarehouse = oComboBox.Value.Trim(); oInvTrans.Lines.SetCurrentLine(0); oInvTrans.Lines.ItemCode = oComboBox1.Value.Trim(); oInvTrans.Lines.FromWarehouseCode = Warehouse; oInvTrans.Lines.WarehouseCode = oComboBox.Value.Trim(); oInvTrans.Lines.Quantity = double.Parse (oEdit3.Value); oInvTrans.Lines.UserFields.Fields.Item("U_DocEntry").Value = QCDocentry; if (Type == "Approve") { oInvTrans.Lines.UserFields.Fields.Item("U_ObjType").Value = "Is_OnlQc " + Type; } else if (Type == "Sample") { oInvTrans.Lines.UserFields.Fields.Item("U_ObjType").Value = "Is_OnlQc " + Type; } else if (Type == "Reject") { oInvTrans.Lines.UserFields.Fields.Item("U_ObjType").Value = "Is_OnlQc " + Type; } oInvTrans.Lines.UserFields.Fields.Item("U_InspQty").Value = double.Parse (oEdit4.Value); oInvTrans.Lines.Add(); RetVal = oInvTrans.Add(); if (RetVal != 0) { oCompany.GetLastError(out ErrCode, out ErrMsg); DisplayError = ErrMsg; return DisplayError; } else { oCompany.EndTransaction(BoWfTransOpt.wf_RollBack); return DisplayError; } } catch (Exception ex) { oCompany.EndTransaction(BoWfTransOpt.wf_RollBack); DisplayError = ex.ToString (); return DisplayError; } }