BPM Conversion - ABL to C#

Nearing our conversion to E10 from 9.05.702A and of course have a single small BPM that needs to be converted. This BPM simply copies a few UD values from OrderRel to JobHead when a JobProd record is added. I am in no way a programmer, can anyone lend a hand? Current ABL:

FOR EACH ttjobprod where ttjobprod.rowmod=“A”:
Find first Jobhead where ttjobprod.company = jobhead.company and ttjobprod.jobnum=jobhead.jobnum no-lock no-error.
If available Jobhead then Do:
Find First OrderRel where OrderRel.Ordernum=ttjobprod.Ordernum and OrderRel.OrderLine=ttjobprod.orderLine and OrderRel.OrderRelNum=ttJobProd.OrderRelNum No-Lock No-Error.
If available OrderRel then Do:
jobhead.ShortChar03 = Orderrel.ShortChar02.
jobhead.Number01 = Orderrel.Number01.
jobhead.Number02 = Orderrel.Number02.
If OrderRel.ShortChar02 <> “” then Do:
jobhead.CheckBox01 = True.
End.
End.
End.
End.

foreach(var ttJobProd_Row in(from row in ttJobProd where row.RowMod == "A" select row))
{
	var JobHead_Row =(from row in Db.JobHead where ttJobProd_Row.Company == row.Company&& ttJobProd_Row.jobnum == row.JobNum
	select Jobhead_Row).FirstOrDefault();
	if(JobHead_Row != null)
	{
		var OrderRelx_Row =(from OrderRel_Row in Db.OrderRel	where OrderRel_Row.Ordernum == ttJobProd_Row.OrderNum && OrderRel_Row.OrderLine == ttJobProd_Row.OrderLine && OrderRel_Row.OrderRelNum == ttJobProd_Row.OrderRelNum	select OrderRel_Row).FirstOrDefault();
		if(OrderRelx_Row != null)
		{
			JobHead_Row.ShortChar03 = OrderRelx_Row.ShortChar02;
			JobHead_Row.Number01 = OrderRelx_Row.Number01;
			JobHead_Row.Number02 = OrderRelx_Row.Number02;
			if(OrderRelx_Row.ShortChar02 != “”)
			{
				JobHead_Row.CheckBox01 = true;
			}
		}
	}
}
``

Thank you very much Surndrapal…I got a couple of syntax errors…

DJ, there is an BPM ABL convertor available which this was likely using.
You may be missing a few things in this example code (along with the syntax issues).
Try this:

using (var txScope = IceContext.CreateDefaultTransactionScope())
{
	foreach(var tt in ttJobProd.Where(tt => tt.Added()))
	{
		var JobHead_Row = Db.JobHead.Where(J => J.Company == tt.Company && J.JobNum == tt.JobNum).FirstOrDefault();
		if(JobHead_Row != null)
		{
			var OrderRel_Row = Db.OrderRel.Where(O => O.Ordernum == tt.OrderNum && O.OrderLine == tt.OrderLine && O.OrderRelNum == tt.OrderRelNum.Select(O => new {O.ShortChar02, O.Number01, O.Number02).FirstOrDefault();
			if(OrderRel_Row != null)
			{
				JobHead_Row.ShortChar03 = OrderRel_Row.ShortChar02;
				JobHead_Row.Number01 = OrderRel_Row.Number01;
				JobHead_Row.Number02 = OrderRel_Row.Number02;
				if(OrderRelx_Row.ShortChar02 != "")
				{
					JobHead_Row.CheckBox01 = true;
				}
			}
		}
	}
	Db.Validate();
	txScope.Complete();
}
1 Like

Also in Data Directives you can do table.ShortChar02 but in Method Directives you must do table[“ShortChar02”]