BPM to prevent over-claiming completed op quantities in MES

I did for my BPM. its a pre-process labor update method directive.

this.lbr = false;


var Lbrqty = ds.LaborDtl.Where(x => x.RowMod != "").FirstOrDefault();
if(Lbrqty != null)
  {
var caller = callContextClient.AssemblyName;
if (caller != null)
  {
if(caller.Contains("EndActivity") && Lbrqty.LaborQty > 0)

{
//var lb = ttLaborDtl.Where(x => x.Updated()).FirstOrDefault();


var ttLDtl = ds.LaborDtl.Where(x => x.RowMod != "").FirstOrDefault();
if(ttLDtl != null)
  {
var oper = (from joper in Db.JobOper
            where joper.JobNum == ttLDtl.JobNum && joper.AssemblySeq == ttLDtl.AssemblySeq && joper.OprSeq == ttLDtl.OprSeq
      select new {joper}).FirstOrDefault();

  if(oper != null) 
    {
bool QtyExceeded = Db.JobOper.Any(x =>
    x.Company == ttLDtl.Company &&
    x.JobNum == ttLDtl.JobNum &&
    x.AssemblySeq == ttLDtl.AssemblySeq &&
    x.OprSeq == ttLDtl.OprSeq &&
    ttLDtl.LaborQty + x.QtyCompleted > x.RunQty);
    
    
    
callContextBpmData.Number01 = Math.Round(oper.joper.RunQty , 2 , MidpointRounding.AwayFromZero);
callContextBpmData.Number02 = Math.Round(  oper.joper.QtyCompleted , 2 ,  MidpointRounding.AwayFromZero) ;
    
 
      
      
    if (QtyExceeded) 


//if(lb.LaborQty > 0)
  {
    lbr = true;
  }
}
}
}
}
}

2 Likes

Mike,
I picked this back up and added the variable but I am getting the following error on my custom code:

Try changing “ttLaborDtl” to “ds.LaborDtl”

1 Like

Ernie,
Do I do change it everywhere or just on that line.
Karen

Everywhere. I’m not a programmer (and actual programmers are rolling over in the aisles when they see me answering questions like this), but I’ve had to make this change a lot.

1 Like

@KBMihaila You only need to change it on the top line.

That code looks like it came from the ABL to C# converter and the code by @Craig is more like how we would approach things now.

Greg,
It doesn’t seem to work?? No errors just no message. If I use Craigs custom code what would I need to change? Any direction is appreciated.
Karen

@gpayne
this is the errors I get when I use Craigs code:

lbr is a global variable. you will need to create that first. its a Bool.

@Craig,
I applied the variable and no errors I will add Labor and see if I get the Exception Message.
Thanks,
Karen

@Craig I am having no luck and am wondering if you can take a look at my BPM? See attached
Ticket 57212.bpm (21.3 KB)

@Craig
Disregard. I think I’ve got it! I will reach out with more questions.
Karen

2 Likes

@KBMihaila Good to hear. I was away from my machine. We are closed today.

Thanks!

1 Like