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:
Infineon\StieberD
2025-07-07 17:40:32 -07:00
parent 563871008e
commit 28d5b81b30
6 changed files with 179 additions and 72 deletions

View File

@ -14,7 +14,7 @@ Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = "" Ans = ""
// Parse record into a dimensioned array for speed // Parse record into a dimensioned array for speed
Dim Rec(85) Dim Rec(86)
MatParse Record into Rec MatParse Record into Rec
// List of key names and their values // List of key names and their values
@ -58,6 +58,8 @@ DataFields := "ORIGIN" :@VM:SQL_Format(Rec(WO_LOG_ORIGIN$),
DataFields := "INCO_CODE" :@VM:SQL_Format(Rec(WO_LOG_INCO_CODE$), "STR"):@FM DataFields := "INCO_CODE" :@VM:SQL_Format(Rec(WO_LOG_INCO_CODE$), "STR"):@FM
DataFields := "HOT_FLAG" :@VM:SQL_Format(Rec(WO_LOG_HOT_FLAG$), "BIT"):@FM DataFields := "HOT_FLAG" :@VM:SQL_Format(Rec(WO_LOG_HOT_FLAG$), "BIT"):@FM
DataFields := "CURR_STATUS_STATIC" :@VM:SQL_Format(Rec(WO_LOG_CURR_STATUS_STATIC$), "STR"):@FM DataFields := "CURR_STATUS_STATIC" :@VM:SQL_Format(Rec(WO_LOG_CURR_STATUS_STATIC$), "STR"):@FM
DataFields := "REL_QTY" :@VM:SQL_Format(Rec(WO_LOG_REL_QTY_STATIC$), "INT"):@FM
DataFields := "UNREL_QTY" :@VM:SQL_Format(Rec(WO_LOG_UNREL_QTY_STATIC$), "INT"):@FM
// Symbolics // Symbolics
DataFields := "START_DT" :@VM:SQL_Format({START_DT}, "DATE"):@FM DataFields := "START_DT" :@VM:SQL_Format({START_DT}, "DATE"):@FM
@ -69,9 +71,7 @@ DataFields := "CYCLE_TIME_WIP" :@VM:SQL_Format({CYCLE_TIME_WIP},
DataFields := "CYCLE_TIME_DELTA" :@VM:SQL_Format({CYCLE_TIME_DELTA}, "DEC", 1):@FM DataFields := "CYCLE_TIME_DELTA" :@VM:SQL_Format({CYCLE_TIME_DELTA}, "DEC", 1):@FM
DataFields := "CYCLE_TIME_QA_SHIP" :@VM:SQL_Format({CYCLE_TIME_QA_SHIP}, "DEC", 1):@FM DataFields := "CYCLE_TIME_QA_SHIP" :@VM:SQL_Format({CYCLE_TIME_QA_SHIP}, "DEC", 1):@FM
DataFields := "CYCLE_TIME_REL_FIRST_VER":@VM:SQL_Format({CYCLE_TIME_REL_FIRST_VER}, "DEC", 1):@FM DataFields := "CYCLE_TIME_REL_FIRST_VER":@VM:SQL_Format({CYCLE_TIME_REL_FIRST_VER}, "DEC", 1):@FM
DataFields := "SAP_TOT_WFR_QTY" :@VM:SQL_Format({SAP_TOT_WFR_QTY}, "STR"):@FM DataFields := "SAP_TOT_WFR_QTY" :@VM:SQL_Format({SAP_TOT_WFR_QTY}, "STR")
DataFields := "REL_QTY" :@VM:SQL_Format({REL_QTY}, "INT"):@FM
DataFields := "UNREL_QTY" :@VM:SQL_Format({UNREL_QTY}, "INT")
// Write the data to the SQL database // Write the data to the SQL database
Ans = SQL_Write(Connection, "WO_LOG", Keys, DataFields) Ans = SQL_Write(Connection, "WO_LOG", Keys, DataFields)

View File

@ -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 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 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 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' LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\NCR'
LogDate = Oconv(Date(), 'D4/') LogDate = Oconv(Date(), 'D4/')
@ -255,21 +255,28 @@ WRITE_RECORD_PRE:
Status = 0 Status = 0
ActionFlow = ACTION_STOP$ ActionFlow = ACTION_STOP$
end end
end end
return return
WRITE_RECORD: 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} RDSNos = {RDS_ID}
For each RDSNo in RDSNos using @VM setting vPos For each RDSNo in RDSNos using @VM setting vPos
Pass_To_SQL('WRITE', 'RDS', RDSNo) Pass_To_SQL('WRITE', 'RDS', RDSNo)
Next 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. // 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. // This will update their current status within the associated WO_MAT record.
WorkOrderNo = {WO_NO}
ReactorType = XLATE('WO_LOG', WorkOrderNo, 'REACT_TYPE', 'X') ReactorType = XLATE('WO_LOG', WorkOrderNo, 'REACT_TYPE', 'X')
ReactorType = Field(ReactorType, @VM, 1) ReactorType = Field(ReactorType, @VM, 1)
CassNo = {WO_MAT_CASS_NO} CassNo = {WO_MAT_CASS_NO}
@ -302,14 +309,10 @@ WRITE_RECORD:
CassStatus = Xlate('RDS', RDSNo, 'CURR_STATUS', 'X') CassStatus = Xlate('RDS', RDSNo, 'CURR_STATUS', 'X')
END END
// add SAP transaction // Add SAP transaction
NCRNo = @ID
NewQty = Sum(obj_NCR('RejQty',NCRNo:@RM:Record))
IF OrigRecord = '' THEN IF OrigRecord = '' THEN
TransQty = NewQty TransQty = NewQty
END ELSE END ELSE
OrgQty = Sum(obj_NCR('RejQty',NCRNo:@RM:OrigRecord))
TransQty = NewQty - OrgQty TransQty = NewQty - OrgQty
END END
IF TransQty NE 0 THEN IF TransQty NE 0 THEN
@ -662,7 +665,6 @@ WRITE_RECORD:
end end
end end
end end
return return
DELETE_RECORD_PRE: DELETE_RECORD_PRE:
@ -743,6 +745,8 @@ DELETE_RECORD:
Pass_To_SQL('WRITE', 'RDS', RDSNo) Pass_To_SQL('WRITE', 'RDS', RDSNo)
Next RDSNo Next RDSNo
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES', 'UpdateScrappedQty':@VM:WorkOrderNo)
return return
@ -808,3 +812,4 @@ LogRecord:
return return

View File

@ -870,12 +870,12 @@ WRITE_RECORD:
Service_Services('PostProcedure', 'RDS_SERVICES', 'PushSigProfileToWoMat':@VM:Name) Service_Services('PostProcedure', 'RDS_SERVICES', 'PushSigProfileToWoMat':@VM:Name)
WONo = Record<RDS_WO$>
OrigDateOut = OrigRecord<RDS_DATE_OUT$> OrigDateOut = OrigRecord<RDS_DATE_OUT$>
NewDateOut = Record<RDS_DATE_OUT$> NewDateOut = Record<RDS_DATE_OUT$>
If ( ( (OrigDateOut EQ '') and (NewDateOut NE '') ) ) then If ( ( (OrigDateOut EQ '') and (NewDateOut NE '') ) ) then
// Mark this cassette as processed in the schedule event record // Mark this cassette as processed in the schedule event record
WONo = Record<RDS_WO$>
DatetimeOut = {DATETIME_OUT} DatetimeOut = {DATETIME_OUT}
ReactType = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X') ReactType = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X')
EpiPro = (ReactType EQ 'EPP') EpiPro = (ReactType EQ 'EPP')
@ -891,6 +891,12 @@ WRITE_RECORD:
end end
end end
OrigPocketChar = OrigRecord<RDS_POCKET_CHAR$>
NewPocketChar = Record<RDS_POCKET_CHAR$>
If (OrigPocketChar NE NewPocketChar) then
Service_Services('PostProcedure', 'WORK_ORDER_SERVICES', 'UpdateScrappedQty':@VM:WONo)
end
EndTick = GetTickCount() EndTick = GetTickCount()
Mona_Services('QueueLatencyAndCountMetrics', MonaResource, MetricName, StartTick, EndTick) Mona_Services('QueueLatencyAndCountMetrics', MonaResource, MetricName, StartTick, EndTick)

View File

@ -920,37 +920,42 @@ end service
Service UpdateReleasedQty(WONo) Service UpdateReleasedQty(WONo)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG' LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/') LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS') LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Update Released Qty Log.csv' LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Update Released Qty Log.csv'
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes' Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpRelLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$) objUpRelLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
RelQty = ''
ErrorMsg = '' UnRelQty = ''
OrigRelQty = ''
OrigUnRelQty = ''
ErrorMsg = ''
If WONo NE '' then If WONo NE '' then
If RowExists('WO_LOG', WONo) then If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo) WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then If Error_Services('NoError') then
RelQty = obj_WO_Log('RelQty', WONo:@RM:WORec) RelQty = obj_WO_Log('RelQty', WONo:@RM:WORec)
WOQty = WORec<WO_LOG_QTY$> WOQty = WORec<WO_LOG_QTY$>
If RelQty GT WOQty then If RelQty GT WOQty then
UnRelQty = 0 UnRelQty = 0
end else end else
UnRelQty = WOQty - RelQty UnRelQty = WOQty - RelQty
end end
Open 'WO_LOG' to hTable then Open 'WO_LOG' to hTable then
WriteV RelQty on hTable, WONo, WO_LOG_REL_QTY_STATIC$ then Read WORec from hTable, WONo then
WriteV UnRelQty on hTable, WONo, WO_LOG_UNREL_QTY_STATIC$ else OrigRelQty = WORec<WO_LOG_REL_QTY_STATIC$>
ErrorMsg = 'Error in ':Service:' service. Failed to write unreleased quantity ':UnRelQty OrigUnRelQty = WORec<WO_LOG_UNREL_QTY_STATIC$>
ErrorMsg := ' to the UNREL_QTY_STATIC field of WO_LOG record ':WONo:'.' If ( (OrigRelQty NE RelQty) or (OrigUnRelQty NE UnRelQty) ) then
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR WORec<WO_LOG_REL_QTY_STATIC$> = RelQty
WORec<WO_LOG_UNREL_QTY_STATIC$> = UnRelQty
Write WORec on hTable, WONo else
ErrorMsg = 'Error in ':Service:' service. Failed to write unreleased quantity ':UnRelQty
ErrorMsg := ' and/or UNREL_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to write released quantity ':RelQty
ErrorMsg := ' to the REL_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end end
end else end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.' ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
@ -994,18 +999,25 @@ Service UpdateReceivedQty(WONo)
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes' Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpRecLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$) objUpRecLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
RXQty = ''
ErrorMsg = '' OrigRXQty = ''
ErrorMsg = ''
If WONo NE '' then If WONo NE '' then
If RowExists('WO_LOG', WONo) then If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo) WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then If Error_Services('NoError') then
RXQty = obj_WO_Log('RxQty', WONo:@RM:WORec) RXQty = obj_WO_Log('RxQty', WONo:@RM:WORec)
Open 'WO_LOG' to hTable then Open 'WO_LOG' to hTable then
WriteV RXQty on hTable, WONo, WO_LOG_RX_QTY_STATIC$ else ReadV OrigRXQty from hTable, WONo, WO_LOG_RX_QTY_STATIC$ then
ErrorMsg = 'Error in ':Service:' service. Failed to write received quantity ':RXQty If OrigRXQty NE RXQty then
ErrorMsg := ' to the RX_QTY_STATIC field of WO_LOG record ':WONo:'.' WriteV RXQty on hTable, WONo, WO_LOG_RX_QTY_STATIC$ else
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR ErrorMsg = 'Error in ':Service:' service. Failed to write received quantity ':RXQty
ErrorMsg := ' to the RX_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end
end else
ErrorMsg = 'Error in ':Service:' service. Error reading RX_QTY_STATIC column from WO_LOG ':WONo:'.'
end end
end else end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.' ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
@ -1047,18 +1059,25 @@ Service UpdateShippedQty(WONo)
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes' Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpShipLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$) objUpShipLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
ShipQty = ''
ErrorMsg = '' OrigShipQty = ''
ErrorMsg = ''
If WONo NE '' then If WONo NE '' then
If RowExists('WO_LOG', WONo) then If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo) WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then If Error_Services('NoError') then
ShipQty = obj_WO_Log('ShipQty', WONo:@RM:WORec) ShipQty = obj_WO_Log('ShipQty', WONo:@RM:WORec)
Open 'WO_LOG' to hTable then Open 'WO_LOG' to hTable then
WriteV ShipQty on hTable, WONo, WO_LOG_SHIP_QTY_STATIC$ else ReadV OrigShipQty from hTable, WONo, WO_LOG_SHIP_QTY_STATIC$ then
ErrorMsg = 'Error in ':Service:' service. Failed to write ':ShipQty If OrigShipQty NE ShipQty then
ErrorMsg := ' to the SHIP_QTY_STATIC field of WO_LOG record ':WONo:'.' WriteV ShipQty on hTable, WONo, WO_LOG_SHIP_QTY_STATIC$ else
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR ErrorMsg = 'Error in ':Service:' service. Failed to write ':ShipQty
ErrorMsg := ' to the SHIP_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end
end else
ErrorMsg = 'Error in ':Service:' service. Error reading SHIP_QTY_STATIC column from WO_LOG ':WONo:'.'
end end
end else end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.' ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
@ -1093,6 +1112,73 @@ Service UpdateShippedQty(WONo)
end service end service
Service UpdateScrappedQty(WONo)
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
LogTime = Oconv(Time(), 'MTS')
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' Update Scrapped Qty Log.csv'
Headers = 'Logging DTM' : @FM : 'WONo' : @FM : 'Notes'
objUpScrapLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$,',', Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime
ScrapQty = ''
OrigScrapQty = ''
ErrorMsg = ''
If WONo NE '' then
If RowExists('WO_LOG', WONo) then
WORec = Database_Services('ReadDataRow', 'WO_LOG', WONo)
If Error_Services('NoError') then
EpiProFlag = Xlate('WO_LOG', WONo, 'EPI_PRO_FLAG', 'X')
If EpiProFlag then
ScrapQty = Xlate('WO_STEP', WONo:'*1', 'TOT_REJ_TOTAL', 'X')
end else
ScrapQty = Sum(Xlate('WO_LOG', WONo, 'WO_MAT_SAP_CONFIRM_SCRAP', 'X'))
end
Open 'WO_LOG' to hTable then
ReadV OrigScrapQty from hTable, WONo, WO_LOG_SCRAP_QTY_STATIC$ then
If OrigScrapQty NE ScrapQty then
WriteV ScrapQty on hTable, WONo, WO_LOG_SCRAP_QTY_STATIC$ else
ErrorMsg = 'Error in ':Service:' service. Failed to write ':ScrapQty
ErrorMsg := ' to the SCRAP_QTY_STATIC field of WO_LOG record ':WONo:'.'
ErrorMsg := '@FILE_ERROR: ':@FILE_ERROR
end
end
end else
ErrorMsg = 'Error in ':Service:' service. Error reading SCRAP_QTY_STATIC column from WO_LOG ':WONo:'.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to open the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Failed to read record ':WONo:' from the WO_LOG table. '
ErrorMsg := 'Error message: ':Error_Services('GetMessage')
end
end else
ErrorMsg = 'Error in ':Service:' service. ':WONo:' does not exist in the WO_LOG table.'
end
end else
ErrorMsg = 'Error in ':Service:' service. Null WONo passed into service'
end
LogData = ''
LogData<1> = LoggingDtm
LogData<2> = WONo
If ErrorMsg EQ '' then
LogResult = 'Successfully updated WO_LOG record ':WONo:' field SCRAP_QTY_STATIC '
LogResult := 'with scrapped quantity ':ScrapQty:'.'
LogData<3> = LogResult
Logging_Services('AppendLog', objUpScrapLog, LogData, @RM, @FM)
end else
LogResult = 'Failed to update WO_LOG record ':WONo:' field SCRAP_QTY_STATIC with scrapped quantity '
LogResult := ScrapQty:'. Error message: ':ErrorMsg
LogData<3> = LogResult
Logging_Services('AppendLog', objUpScrapLog, LogData, @RM, @FM)
Error_Services('Add', ErrorMsg)
end
end service
Service ConvertRecordToJSON(WONo, Record, ItemURL) Service ConvertRecordToJSON(WONo, Record, ItemURL)
jsonRecord = '' jsonRecord = ''

View File

@ -1,6 +1,4 @@
Function WO_LOG_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record, Status, OrigRecord, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10) Function WO_LOG_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record, Status, OrigRecord, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10)
#pragma precomp SRP_PreCompiler
/*********************************************************************************************************************** /***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
@ -43,7 +41,7 @@ Function WO_LOG_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record,
03/26/11 dmb Add logic to save and restore @FILE.ERROR 03/26/11 dmb Add logic to save and restore @FILE.ERROR
***********************************************************************************************************************/ ***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$insert APP_INSERTS $insert APP_INSERTS
$insert FILE.SYSTEM.EQUATES $insert FILE.SYSTEM.EQUATES
$insert ACTION_SETUP $insert ACTION_SETUP
@ -56,7 +54,7 @@ $insert SCHED_DET_NG_EQUATES
Equ Comma$ to ',' Equ Comma$ to ','
Declare function Error_Services, Database_Services, Environment_Services, Logging_Services, obj_WO_Mat, Datetime Declare function Error_Services, Database_Services, Environment_Services, Logging_Services, obj_WO_Mat, Datetime
Declare function GaN_Services, obj_WO_Log Declare function GaN_Services, obj_WO_Log, SRP_Date
Declare subroutine Error_Services, Database_Services, Environment_Services, Logging_Services, Obj_SAP Declare subroutine Error_Services, Database_Services, Environment_Services, Logging_Services, Obj_SAP
Declare subroutine Logging_Services, Set_Status, Schedule_Services, Work_Order_Services, obj_Notes Declare subroutine Logging_Services, Set_Status, Schedule_Services, Work_Order_Services, obj_Notes
Declare subroutine Schedule_Services Declare subroutine Schedule_Services
@ -225,6 +223,17 @@ WRITE_RECORD_PRE:
SaveRecord = Record SaveRecord = Record
end end
EntryDate = Record<WO_LOG_ENTRY_DATE$>
Today = Date()
YearsOpen = SRP_Date('YearSpan', EntryDate, Today, True$)
ScrapQty = Record<WO_LOG_SCRAP_QTY_STATIC$>
ShipQty = Record<WO_LOG_SHIP_QTY_STATIC$>
If ( ( (ScrapQty + ShipQty) GE NewQty ) or (YearsOpen GE 3) ) then
// Auto-close the work order
Record<WO_LOG_CURR_STATUS_STATIC$> = 'CL'
SaveRecord = Record
end
return return
WRITE_RECORD: WRITE_RECORD:
@ -457,28 +466,28 @@ return
DELETE_RECORD_PRE: DELETE_RECORD_PRE:
// Log which user and computer station attempted to delete the record // Log which user and computer station attempted to delete the record
LogData = '' LogData = ''
LogData<1> = LoggingDTM LogData<1> = LoggingDTM
LogData<2> = Name LogData<2> = Name
LogData<3> = @User4 LogData<3> = @User4
Logging_Services('AppendLog', objDeleteLog, LogData, @RM, @FM) Logging_Services('AppendLog', objDeleteLog, LogData, @RM, @FM)
// Send an LSL message to FI admins to alert them // Send an LSL message to FI admins to alert them
Recipients = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X') Recipients = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
SentFrom = 'SYSTEM' SentFrom = 'SYSTEM'
Subject = 'WO_LOG Delete Attempt' Subject = 'WO_LOG Delete Attempt'
Message = 'An attempt to delete WO_LOG record ':Name:' was made by ':@User4:'.' Message = 'An attempt to delete WO_LOG record ':Name:' was made by ':@User4:'.'
AttachWindow = 'NDW_WO_LOG' AttachWindow = 'NDW_WO_LOG'
AttachKey = Name AttachKey = Name
SendToGroup = '' SendToGroup = ''
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
obj_Notes('Create',Parms) obj_Notes('Create',Parms)
// Stop the system from deleting the record // Stop the system from deleting the record
ActionFlow = ACTION_STOP$ ActionFlow = ACTION_STOP$
return return
DELETE_RECORD: DELETE_RECORD:

View File

@ -95,4 +95,5 @@ Equ WO_LOG_SHIP_QTY_STATIC$ To 82
Equ WO_LOG_RX_STAMPS$ To 83 Equ WO_LOG_RX_STAMPS$ To 83
Equ WO_LOG_REL_STAMPS$ To 84 Equ WO_LOG_REL_STAMPS$ To 84
Equ WO_LOG_CURR_STATUS_STATIC$ To 85 Equ WO_LOG_CURR_STATUS_STATIC$ To 85
Equ WO_LOG_SCRAP_QTY_STATIC$ To 86