BPM - Employee# in MES

I am having the worst time trying to figure out BPM. I am tying to create a BPM on our MES that will not allow employees to start production on a job if they are active on another. The BO is Labor and Method is StartActivity. There are a dozen ways to solve this problem, my approach was to have a condition option:

The query looks for a row in the labordtl table for a row with the employee# and ActiveTrans = true. If I hard code the employee# it works, but I can’t figure out how to supply the employee#. I think the trace file indicates it is returned in the variable ds. Which I am Assuming is the ttlaborhed table. But it’s not working.

Questions.

  1. Where/how can I access the Employee#
  2. Am I approaching this problem wrong?

Thanks to everyone for reading. Very much appreciated.

If you are adding a LaborDtl row it has ActiveTrans=true. LaborDtl.EmployeeNum is the employee, so you are looking for another row with the same EmployeeNum that does not have this rows SysRowID.

I would do this in code as I don’t know the widgets. It was on my Insight’s list. Oh, Well.

I am trying to stop it before it adds a row to labordtl. I hope to prevent the form where they select a job/operation from loading of condition is true.

labor.startactivity preprocess take the incoming employee ID and do a query condition where labordtl.activetrans =1 for that employee. Warning do not join the tt table to the db table directly in the query editor that is a recipe for massive slow downs. You might have to use other widgets to extract the employee ID into a variable first. Once you have your query squared away for 1 or more results throw an exception on true.

I need to check in SSMS but isn’t the employee info all in empBasic? Can you access that in the query widget?

EDIT:

yeah, unless I misunderstood your quesiton, if you want to use the employee identifier as a condition you can join empBasic on LaborDtl where empbasic.empID = laborDtl.employeenum

here’s what I use to detect people who didn’t clock out:


select
	lbr.company,
	lbr.EmployeeNum,
	emp.Name,
	lbr.LaborHedSeq,
	lbr.LaborDtlSeq,
	lbr.LaborTypePseudo,
	lbr.JobNum,
	lbr.AssemblySeq,
	lbr.OprSeq,
	lbr.JCDept,
	lbr.ResourceGrpID,
	lbr.OpCode,
	lbr.Complete,
	lbr.activetrans,
	lbr.timestatus,
	lbr.PayrollDate

from
	Erp.labordtl lbr
	inner join erp.EmpBasic emp 
               on lbr.EmployeeNum = emp.EmpID
where
	lbr.Complete = '0'
	and lbr.TimeStatus != 'A'
	and lbr.PayrollDate < DATEADD(d,-1,getdate())

gives:

you should be able to get the employee number you’re looking for and work backwards, no?

'scuse my self-taught SQL…

Honestly even better after looking at the method definition, just look up Erp.LaborHed using the hed seq passed into the method directly and inner join that to labordtl on their normal keys and look for an activetrans

Query in TSQL would translate to

SELECT
   * 
FROM 
   Erp.LaborHed h 
JOIN 
   Erp.LaborDtl d ON d.Company = h.Company AND d.LaborHedSeq = h.LaborHedSeq 
WHERE 
   h.LaborHedSeq = @LaborHedSeq AND 
   d.ActiveTrans = 1

If you find any rows throw an exception.

I added just an exception pre-processing on start activity to see what it would do. It throws the exception but still let the form open, but you could not input a job.
I would either move to a customization on form load or let them get to entering a job and then block it.

1 Like

I was ok allowing the start activity screen to open because I took it one step further and pop a BPM form asking if they want to end their prior activity if so they can continue or it yells. I personally try to avoid customizations at all costs, one there are a couple ways to clock into jobs so you have to hit them all or risk a squeak through (Office MES, Handheld, MES) and if you ever go to Kinetic you can likely kiss your customization as you know it goodbye and start over again. BO’s won’t change that much for some time.