added triggers to calculate and store the scrapped quantity of a work order and auto close the work order when the scrap quantity and ship quantity equal the total work order quantity
added performance improvements to reduce unnecessary writes to the WO_LOG table
This commit is contained in:
@ -77,7 +77,7 @@ Declare function Database_Services, obj_NCR, obj_SAP, Environment_Services, L
|
||||
Declare function obj_WO_Mat, obj_RDS, Error_Services, MemberOf, SRP_Array
|
||||
Declare subroutine Error_Services, Database_Services, obj_NCR, obj_SAP, Material_Services, Work_Order_Services
|
||||
Declare subroutine Logging_Services, Set_Status, obj_WO_Mat, obj_WO_Mat_Log, Schedule_Services, obj_Tables
|
||||
Declare subroutine obj_RDS, SAP_Services, Pass_To_SQL, NCR_Services
|
||||
Declare subroutine obj_RDS, SAP_Services, Pass_To_SQL, NCR_Services, Service_Services
|
||||
|
||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NCR'
|
||||
LogDate = Oconv(Date(), 'D4/')
|
||||
@ -255,21 +255,28 @@ WRITE_RECORD_PRE:
|
||||
Status = 0
|
||||
ActionFlow = ACTION_STOP$
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
|
||||
WRITE_RECORD:
|
||||
|
||||
// NCR quantity may have changed, so update RDS data in SCRAPE.
|
||||
NCRNo = @ID
|
||||
NewQty = Sum(obj_NCR('RejQty',NCRNo:@RM:Record))
|
||||
OrgQty = Sum(obj_NCR('RejQty',NCRNo:@RM:OrigRecord))
|
||||
WorkOrderNo = {WO_NO}
|
||||
// NCR quantity may have changed, so update RDS data in SCRAPE DB as well as the total scrap qty in the work order.
|
||||
RDSNos = {RDS_ID}
|
||||
For each RDSNo in RDSNos using @VM setting vPos
|
||||
Pass_To_SQL('WRITE', 'RDS', RDSNo)
|
||||
Next RDSNo
|
||||
|
||||
If (OrgQty NE NewQty) then
|
||||
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES', 'UpdateScrappedQty':@VM:WorkOrderNo)
|
||||
end
|
||||
|
||||
// On the write of the record, read then write associated WM_IN and WM_OUT records to trigger the WM_MFS.
|
||||
// This will update their current status within the associated WO_MAT record.
|
||||
WorkOrderNo = {WO_NO}
|
||||
ReactorType = XLATE('WO_LOG', WorkOrderNo, 'REACT_TYPE', 'X')
|
||||
ReactorType = Field(ReactorType, @VM, 1)
|
||||
CassNo = {WO_MAT_CASS_NO}
|
||||
@ -302,14 +309,10 @@ WRITE_RECORD:
|
||||
CassStatus = Xlate('RDS', RDSNo, 'CURR_STATUS', 'X')
|
||||
END
|
||||
|
||||
// add SAP transaction
|
||||
NCRNo = @ID
|
||||
NewQty = Sum(obj_NCR('RejQty',NCRNo:@RM:Record))
|
||||
|
||||
// Add SAP transaction
|
||||
IF OrigRecord = '' THEN
|
||||
TransQty = NewQty
|
||||
END ELSE
|
||||
OrgQty = Sum(obj_NCR('RejQty',NCRNo:@RM:OrigRecord))
|
||||
TransQty = NewQty - OrgQty
|
||||
END
|
||||
IF TransQty NE 0 THEN
|
||||
@ -662,7 +665,6 @@ WRITE_RECORD:
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
|
||||
DELETE_RECORD_PRE:
|
||||
@ -743,6 +745,8 @@ DELETE_RECORD:
|
||||
Pass_To_SQL('WRITE', 'RDS', RDSNo)
|
||||
Next RDSNo
|
||||
|
||||
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES', 'UpdateScrappedQty':@VM:WorkOrderNo)
|
||||
|
||||
return
|
||||
|
||||
|
||||
@ -808,3 +812,4 @@ LogRecord:
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user