on 09-09-2017 1:26 PM - last edited on 02-04-2024 1:21 AM by postmig_api_4
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;
}
}
Hi Nikita,
I don't understand what is your purpose. But with your code, your action will be rollbacked.
Are you sure that your problem is in this function?
Kind Regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
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.