Michael,
This code is not specific to Sales Order, but you should be able to pick
out some relevant ideas depending on the specifics of what you are
trying to do.
This is actually specific to the Labor.Update method relating to ending
activity in MES but it might help. If you give a little more specific
example of what you are looking for I might be able to be more helpful.
Best of luck,
Aaron Hoyt
Vantage Plastics
/* Define the Variables */
DEFINE VARIABLE stackid AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE job AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE date AS DATE INITIAL Today NO-UNDO.
DEFINE VARIABLE wcs AS CHARACTER INITIAL
"MACH1,MACH2,MACH3,MACH4,MACH5,MACH6,MACH7,MACH8,MACH9,MACHJ,ASM,INSP"
NO-UNDO.
DEFINE VARIABLE sup AS CHARACTER INITIAL "2,218,135,133,4,138" NO-UNDO.
DEFINE VARIABLE grnd AS CHARACTER INITIAL "SHRD1,SHRD2,CMPT" NO-UNDO.
DEFINE VARIABLE shift AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE cust AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE stackcount AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE material AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE issued AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE scrap AS INTEGER NO-UNDO.
DEFINE VARIABLE goodparts AS INTEGER NO-UNDO.
DEFINE VARIABLE rcvparts AS INTEGER NO-UNDO.
DEFINE VARIABLE wipmtl AS INTEGER NO-UNDO.
DEFINE VARIABLE remsheet AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE operator AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE remparts AS CHARACTER INITIAL "" NO-UNDO.
DEFINE VARIABLE n AS INTEGER NO-UNDO.
DEFINE BUFFER LaborDtl2 FOR labordtl.
DEFINE VARIABLE earned AS DECIMAL NO-UNDO.
DEFINE VARIABLE worked AS DECIMAL NO-UNDO.
DEFINE VARIABLE qty AS DECIMAL NO-UNDO.
/* Initialize Integers */
qty = 0.
scrap = 0.
goodparts = 0.
n = 0.
rcvparts = 0.
earned = 0.
worked = 0.
/* If workcenter is right Procede */
Find First LaborDtl WHERE (LaborDtl.Company = "VPC") and
(LaborDtl.EmployeeNum =
ttLaborDtl.EmployeeNum) and
(LaborDtl.ActiveTrans = True) and
(LaborDtl.JobNum =
ttLaborDtl.JobNum) and
(LaborDtl.AssemblySeq =
ttLaborDtl.AssemblySeq) and
(LaborDtl.OprSeq =
ttLaborDtl.OprSeq) No-LOCK No-ERROR.
IF LOOKUP (ttLaborDtl.ResourceGrpID, wcs) > 0 AND
(LaborDtl.LaborType) <> "I"
THEN DO:
/*Add up the scrap values from this and other labor detail records and
add receipts up*/
/* Look up Information from Job, EmpBasic, Order */
FIND JobHead WHERE (JobHead.Company = LaborDtl.Company) AND
(JobHead.JobNum = LaborDtl.JobNum)
NO-LOCK No-ERROR.
FIND JobOper WHERE (JobOper.Company = LaborDtl.Company) AND
(JobOper.JobNum = LaborDtl.JobNum) AND
(JobOper.AssemblySeq = LaborDtl.AssemblySeq) AND
(JobOper.OprSeq = LaborDtl.OprSeq)
NO-LOCK No-ERROR.
FIND JobAsmbl WHERE (JobAsmbl.Company = LaborDtl.Company) AND
(JobAsmbl.JobNum = LaborDtl.JobNum) AND
(JobAsmbl.AssemblySeq = LaborDtl.AssemblySeq)
NO-LOCK No-ERROR.
FOR EACH PartWip WHERE (PartWip.Company = LaborDtl.Company) AND
(PartWip.JobNum = LaborDtl.JobNum) AND
(PartWip.WareHouseCode = "FG"):
rcvparts = rcvparts + PartWip.Quantity.
END.
/*Add up the scrap values from this and other labor detail records*/
FOR EACH LaborDtl2 WHERE (LaborDtl2.Company = LaborDtl.Company) AND
(LaborDtl2.JobNum = LaborDtl.JobNum) AND
(LaborDtl2.LaborType <> "I") AND
(LaborDtl2.AssemblySeq = LaborDtl.AssemblySeq) AND
(LaborDtl2.OprSeq = LaborDtl.OprSeq):
scrap = scrap + LaborDtl2.ScrapQty.
earned = earned + LaborDtl2.EarnedHrs.
worked = worked + LaborDtl2.LaborHrs.
goodparts = goodparts + LaborDtl2.LaborQty.
END.
FIND FIRST JobProd WHERE (JobProd.Company = JobHead.Company) AND
(JobProd.JobNum = JobHead.JobNum)
NO-LOCK No-ERROR.
FIND LaborHed WHERE (LaborHed.Company = LaborDtl.Company) AND
(LaborHed.LaborHedSeq = LaborDtl.LaborHedSeq)
NO-LOCK No-ERROR.
IF JobProd.OrderNum > 0
THEN DO:
FIND OrderHed WHERE (OrderHed.Company = JobProd.Company) AND
(OrderHed.OrderNum = JobProd.OrderNum)
NO-LOCK No-ERROR.
FIND Customer WHERE (Customer.Company = OrderHed.Company) AND
(Customer.CustNum = OrderHed.CustNum)
NO-LOCK No-ERROR.
FIND FIRST OrderRel Where (OrderRel.Company = JobProd.Company) AND
(OrderRel.OrderNum = JobProd.OrderNum) and
(OrderRel.OrderLine = JobProd.OrderLine) No-LOCK
NO-ERROR.
/* Set the Variables */
IF Customer.CustNum = 219
THEN DO:
cust= "".
END.
ELSE DO:
cust = string(Customer.Name).
END.
END.
ELSE DO:
cust = "WIP".
END.
qty = ttLaborDtl.Number01.
stackcount = "____".
stackid = string(LaborDtl.LaborDtlSeq) + FILL("0", (5 -
LENGTH(string(Time)))) + string(Time).
job = CAPS(string(ttLaborDtl.JobNum)).
date = TODAY.
shift = string(LaborHed.Shift).
goodparts = (JobOper.QtyCompleted + ttLaborDtl.LaborQty).
operator = ttLaborDtl.EmployeeNum.
remparts = string(JobOper.RunQty - goodparts).
/* Now create the acutal export file */
/* Start the output to data file */
output to "\\Vpserver3\epicor\mfgsysdata\Label\EndAct.CSV".
/* Set up Data Identifiers */
export delimiter ","
"StackID"
"Part"
"Job"
"Qty"
"Date"
"Customer"
"Shift"
"StackCount"
"Material"
"MatIssued"
"Scrap"
"GoodParts"
"RemainingSheet"
"Operator"
"Assm"
"OperSeq"
"RemainingParts"
"N"
"RecQty"
"QtyComplete"
"WipMaterial"
"Shipped".
/* Begin Export of data to CSV format */
FOR EACH JobMtl WHERE (JobMtl.Company = LaborDtl.Company) AND
(JobMtl.JobNum = LaborDtl.JobNum) AND
(JobMtl.AssemblySeq = LaborDtl.AssemblySeq) AND
(JobMtl.RelatedOperation = LaborDtl.OprSeq) AND
(JobMtl.WarehouseCode = "RAW"):
issued = string(JobMtl.IssuedQty).
material = string(JobMtl.PartNum).
remsheet = string(JobMtl.IssuedQty - (((JobOper.QtyCompleted +
scrap) * JobMtl.QtyPer) / JobOper.QtyPer)).
n = n + 1.
wipmtl = 0.
FOR EACH PartWip WHERE (PartWip.Company = JobMtl.Company) AND
(PartWip.PartNum = JobMtl.PartNum) AND
(PartWip.JobNum = JobMtl.JobNum) AND
(PartWip.AssemblySeq = JobMtl.AssemblySeq) AND
(PartWip.OprSeq = JobMtl.RelatedOperation):
wipmtl = wipmtl + PartWip.Quantity.
END.
export delimiter ","
stackid
string(JobHead.PartNum)
job
qty
date
cust
shift
stackcount
material
issued
scrap
goodparts
remsheet
operator
string(ttLaborDtl.AssemblySeq)
string(ttLaborDtl.OprSeq)
remparts
n
rcvparts
JobHead.QtyCompleted
wipmtl
string(JobProd.ShippedQty).
END.
IF n = 0 THEN DO:
export delimiter ","
stackid
string(JobHead.PartNum)
job
qty
date
cust
shift
stackcount
string("No Material")
string(0)
scrap
goodparts
string(0)
operator
string(ttLaborDtl.AssemblySeq)
string(ttLaborDtl.OprSeq)
string(0)
1
rcvparts
JobHead.QtyCompleted
wipmtl
string(JobProd.ShippedQty).
END.
ELSE DO:
END.
END.
/* Finsh Export and close output */
output close.
/* end of export program *//* end of export program */
Michael McWilliams wrote:
>
> Posted before I was done.
> I want to perform a set of actions for the current set of data. For
> example if the BPM triggers on a specific method in the sales order I
> want to perform an action for every line of that sales order.
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>,
> "Michael McWilliams"
> <mmcwilliams22@...> wrote:
> >
> > Does anyone have any examples of 4gl code they are using with BPM.
> >
>
>
[Non-text portions of this message have been removed]