on 2021 Aug 27 3:16 PM
We create a delivery with the DI API and update our sql table in the same transaction.
If the update query fails, we also rollback the delivery creation process.
We failed to run update query with Servicelayer.
We want to do these operations in a single transaction with the servicelayer. How can we do this with servicelayer.
public string xx(string HdrId,Company oCompany, Recodset rs)
{
var msj = "";
try
{
oCompany.StartTransaction();
Documents doc = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oDeliveryNotes);
doc.CardCode = "C20000";
doc.Lines.ItemCode = "A00001";
doc.Lines.Quantity = 1;
lRetCode = doc.Add();
if (lRetCode != 0)
throw new Exception("NOT CREATED");
else
{
var sNewObjCode = "";
oCompany.GetNewObjectCode(out sNewObjCode);
rs.DoQuery(" UPDATE \"@TST_TABLE1\" SET \"DocEntryx\" = '" + sNewObjCode + "' WHERE \"UniqueID\" = '" + HdrId + "' ");
if (oCompany.InTransaction)
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
msj = "CREATED";
}
}
catch (Exception ex)
{
if (oCompany.InTransaction)
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
msj = "ERROR (" + ex.Message + ")";
}
return msj;
}
Request clarification before answering.
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.