BPM needed for when a job is fully complete

In the end we went with a standard data directive Asynchronously execute ABL define buffer bittJobMtl for ttJobMtl. ... record nothing with rule

ABL: define buffer bittJobMtl for ttJobMtl. define buffer bJobMtl for JobMtl. define buffer bJobHead for JobHead. define var cRecipients As char no-undo. define var cSubject as char no-undo. define var cMessage as char no-undo. assign cRecipients = "[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected];[email protected]". /may contain multiple rows, so add a check to only send the email once per job in the set. multiple rows could be sent if job is issued complete from mass issue to manufacturing/ for each ttJobMtl where ttJobMtl.RowMod = "U" break by ttJobMtl.JobNum: if first-of(ttJobMtl.JobNum) then do: if(ttJobMtl.IssuedComplete) then do: find first bittJobMtl where bittJobMtl.SysRowId = ttJobMtl.SysRowID and bittJobMtl.RowMod = "":u no-error.

/check if material has just been set to issued complete/ if avail bittJobMtl and not bittJobMtl.IssuedComplete then do:

/*see if any incomplete materials remain on the job (all assemblies)*/
/*change to the jobmtl will be in the db so we can just use the index to look for completed materials on the job*/
if not can-find(first bJobMtl where bJobMtl.Company = cur-comp
         and bJobMtl.Plant = cur-plant
         and bJobMtl.JobNum = ttJobMtl.JobNum
         and bJobMtl.JobComplete = No
         and bJobMtl.IssuedComplete = No) then do:

 find first Company where Company.Company = cur-comp no-lock no-error.

 find first bJobHead where bJobHead.Company = ttJobMtl.Company
            and bJobHead.JobNum = ttJobMtl.JobNum no-lock no-error.

 assign cSubject = "Kitting Complete for Job " + ttJobMtl.JobNum.
 assign cMessage = "Kitting Complete for Job " + ttJobMtl.JobNum + (if avail bJobHead then ", Part number " + bJobHead.PartNum else "").

 /*send the email notification*/
 def var vh as handle.

 run Bpm/BpmEmail.p persistent set vh.

 RUN SendEmail in vh(no, /*async*/
                            ttJobMtl.Company, /*company*/
                            Company.EmailFromAddr, /*from*/
                            cRecipients, /*to - ';' delimited list of addresses*/
                            "", /*cc*/
                            cSubject, /*subject*/
                            cMessage, /*message*/
                            ""). /*mime type - left as plain text*/

 DELETE OBJECT vh NO-ERROR.

end.

end. end. end. end.

/r/epicor Thread Parent