- If I move everything in the try block, i get the error ‘The Transaction has aborted’. The update transaction shouldn’t take a while it’s a simple part creation (only one for now)
To get the data to process, I first read the UD08 table rows that aren’t processed yet. For each row, I create the part (try-catch) and I would like to be able to update the UD08 row in the catch block. I guess that you’re right since by reading the UD08 rows, it might put a lock resulting in a timeout when I try to update.
However, even if I do nothing in my catch block, I get ‘The transaction has aborted’
var ud08Lst = from ud08 in Db.UD08
where ud08.Company == callContextClient.CurrentCompany && ud08.Character03 != "Imported"
select ud08;
foreach(var row in ud08Lst)
{
var company = row.Company;
var partNum = row.Key1;
var key2 = row.Key2;
var key3 = row.Key3;
var key4 = row.Key4;
var key5 = row.Key5;
/*Part*/
var partDescription = row.Character01;
var partDescriptionFR = row.Character02;
var type = row.ShortChar01;
var uomClass = row.ShortChar02;
var ium = row.ShortChar03;
var salesUM = row.ShortChar04;
var pum = row.ShortChar05;
var prodCode = row.ShortChar06;
var classID = row.ShortChar07;
var costMethod = row.ShortChar08;
var nonStock = row.CheckBox01;
var qtyBearing = row.CheckBox02;
var usePartRev = row.CheckBox03;
var commercialCategory = row.ShortChar11;
var commercialSubCategory = row.ShortChar12;
var lastUpdate = new DateTime?(DateTime.Now);
/*Create Part*/
var partSvc = ServiceRenderer.GetService<Erp.Contracts.PartSvcContract>(Db);
using(partSvc)
{
try
{
Erp.Tablesets.PartTableset partTS = new Erp.Tablesets.PartTableset();
partSvc.GetNewPart(ref partTS);
type = "data_that_does_not_exist_to_trigger_error";
partTS.Part[0].PartNum = partNum;
partTS.Part[0].PartDescription = partDescription;
partTS.Part[0].TypeCode = type;
partTS.Part[0].UOMClassID = uomClass;
partTS.Part[0].IUM = ium;
partTS.Part[0].SalesUM = salesUM;
partTS.Part[0].PUM = pum;
partTS.Part[0].ProdCode = prodCode;
partTS.Part[0].ClassID = classID;
partTS.Part[0].CostMethod = costMethod;
partTS.Part[0].NonStock = nonStock;
partTS.Part[0].QtyBearing = qtyBearing;
partTS.Part[0].UsePartRev = usePartRev;
partTS.Part[0].CommercialCategory = commercialCategory;
partTS.Part[0].CommercialSubCategory = commercialSubCategory;
partSvc.Update(ref partTS);
}
catch(Exception ex)
{
this.PublishInfoMessage(ex.Message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
}
}
}