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

@ -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)
#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
@ -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
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$insert APP_INSERTS
$insert FILE.SYSTEM.EQUATES
$insert ACTION_SETUP
@ -56,7 +54,7 @@ $insert SCHED_DET_NG_EQUATES
Equ Comma$ to ','
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 Logging_Services, Set_Status, Schedule_Services, Work_Order_Services, obj_Notes
Declare subroutine Schedule_Services
@ -225,6 +223,17 @@ WRITE_RECORD_PRE:
SaveRecord = Record
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
WRITE_RECORD:
@ -457,28 +466,28 @@ return
DELETE_RECORD_PRE:
// Log which user and computer station attempted to delete the record
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Name
LogData<3> = @User4
Logging_Services('AppendLog', objDeleteLog, LogData, @RM, @FM)
// Send an LSL message to FI admins to alert them
Recipients = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
SentFrom = 'SYSTEM'
Subject = 'WO_LOG Delete Attempt'
Message = 'An attempt to delete WO_LOG record ':Name:' was made by ':@User4:'.'
AttachWindow = 'NDW_WO_LOG'
AttachKey = Name
SendToGroup = ''
// Log which user and computer station attempted to delete the record
LogData = ''
LogData<1> = LoggingDTM
LogData<2> = Name
LogData<3> = @User4
Logging_Services('AppendLog', objDeleteLog, LogData, @RM, @FM)
// Send an LSL message to FI admins to alert them
Recipients = Xlate('SEC_GROUPS', 'OI_ADMIN', 'USER', 'X')
SentFrom = 'SYSTEM'
Subject = 'WO_LOG Delete Attempt'
Message = 'An attempt to delete WO_LOG record ':Name:' was made by ':@User4:'.'
AttachWindow = 'NDW_WO_LOG'
AttachKey = Name
SendToGroup = ''
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
obj_Notes('Create',Parms)
// Stop the system from deleting the record
ActionFlow = ACTION_STOP$
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
obj_Notes('Create',Parms)
// Stop the system from deleting the record
ActionFlow = ACTION_STOP$
return
DELETE_RECORD: