I’ve been successful in converting our E9 to E10 BPM’s except for the ones that contain a calculation (just a few). I’ve been able to write C# code in the past with success. Here is the ABL code that I’m trying to convert. It is a simple query to check quantity received plus additional, any suggestions is greatly appreciated.
for each ttPartTran no-lock where (ttPartTran.TranType =‘MFG-STK’) ,
each JobHead no-lock where (ttPartTran.Company = JobHead.Company and ttPartTran.JobNum = JobHead.JobNum)
each JobPart no-lock where (ttPartTran.Company = JobPart.Company and ttPartTran.JobNum = JobPart.JobNum and ((JobPart.ReceivedQty + ttPartTran.ThisTranQty) > JobHead.QtyCompleted))
foreach(var pt in ttPartTran.Where(t => t.TranType == "MFG-STK")
{
var jobs = Db.JobHead.Where (j => pt.Company == j.Company && pt.JobNum == j.JobNum && j.ReceivedQty + pt.ThisTranQty > j.QtyCompleted);
//jobs now has all the records meeting the criteria, you can do what you wish, iterate, read, write, etc
foreach(var job in jobs)
{
//do something with job
}
}
Nice code Chris! It will work if I chop out part of the code j.ReceiveQty as it is referring to JobPart that is not referenced. A lot closer than before.
foreach(var pt in ttPartTran.Where(t => t.TranType == "MFG-STK")
{
var jobs = Db.JobHead.Where (j => pt.Company == j.Company && pt.JobNum == j.JobNum);
//jobs now has all the records meeting the criteria, you can do what you wish, iterate, read, write, etc
foreach(var job in jobs)
{
foreach(var jobpart in Db.JobPart.Where(jp => jp.Company == j.Company && jp.JobNum == j.JobNum && jp.ReceivedQty + pt.ThisTranQty > j.QtyCompleted)))
{
// do stuff
}
}
}
This particular case is better suited for a join as opposed to iteration, unfortunately i am little strapped for time so I cant provide code, but here is a basic example from the forum:
var UD02RowList = from UD02Row in Db.UD02.With(LockHint.UpdLock)
join OrderDtlRow in Db.OrderDtl
on new {Company = UD02Row.Company, Character01 = UD02Row.Character01, Date01 = UD02Row.Date01, DeliveryLoad_c = UD02Row.DeliveryLoad_c} equals
new {Company = OrderDtlRow.Company, Character01 = OrderDtlRow.ProjectID, Date01 = OrderDtlRow.NeedByDate, DeliveryLoad_c = OrderDtlRow.DeliveryLoad_c}
into jointData
from jointRecord in jointData.DefaultIfEmpty()
where jointRecord.OrderNum == null
select UD02Row;
Chris, I will revisit this once again next week to see if I can modify the Lambda expressions to also include the other file reference. No time this week, thanks again.