Added calls to verify indexes and update indexes right after receiving and releasing material. Refactored codebase to adjust work order quantities instead of recalculate quantities.

Removing reliance on transaction queue for receive and releaase

Added unlock call in case write fails
This commit is contained in:
Infineon\StieberD
2025-09-30 13:45:55 -07:00
parent a2f61d11c9
commit beaac0d38a
17 changed files with 1272 additions and 778 deletions

View File

@ -60,6 +60,8 @@ $Insert CUST_EPI_PART_EQUATES
$Insert QUOTE_SPEC_EQU
$Insert WO_STEP_EQUATES
Equ NUM_ATTEMPTS$ to 60
EQU PI$LEFT TO 1
EQU PI$TOP TO 2
EQU PI$RIGHT TO 3
@ -77,7 +79,7 @@ EQU PS$PATTERN TO 11
Declare function PSN_Services, SRP_Rotate_Array, Datetime, Database_Services, Environment_Services, Logging_Services
Declare function obj_Install, SRP_Json
Declare subroutine Database_Services, Set_Status, obj_Wo_Mat_Log, Logging_Services, Extract_Si_Keys, Btree.Extract
Declare subroutine SRP_Json
Declare subroutine SRP_Json, Update_Index, Delay
GoToService else
Error_Services('Set', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
@ -218,19 +220,27 @@ Service VerifyWoStepWMIKeyIndex(WMIKey)
// Add index transaction to update WM_IN_KEYS relational index (target WO_STEP table)
IndexTransactionRow = 'WO_STEP*WM_IN_KEYS*AR':@FM:WMIKey:@FM:"":@FM:WOStepKey:@FM
Open "!WM_IN" to BangTable then
Lock BangTable, 0 then
Read PendingTrans from BangTable, 0 else PendingTrans = '0':@FM
PendingTrans := IndexTransactionRow
Write PendingTrans on BangTable, 0 then
LogData<4> = 'Index transaction successfully added.'
Logging_Services('AppendLog', objVerifyWMIKeyLog, LogData, @RM, @FM)
Done = False$
For AttemptNo = 1 to NUM_ATTEMPTS$
If AttemptNo GT 1 then Delay(1)
Lock BangTable, 0 then
Read PendingTrans from BangTable, 0 else PendingTrans = '0':@FM
PendingTrans := IndexTransactionRow
Write PendingTrans on BangTable, 0 then
LogData<4> = 'Index transaction successfully added.'
Logging_Services('AppendLog', objVerifyWMIKeyLog, LogData, @RM, @FM)
Done = True$
end else
ErrorMsg = 'Unable to write index transaction to !WM_IN. ':WMIKey
end
Unlock BangTable, 0 else ErrorMsg = 'Unable to Open !WM_IN to add index transaction. ':WMIKey
end else
ErrorMsg = 'Unable to write index transaction to !WM_IN. ':WMIKey
If AttemptNo GE NUM_ATTEMPTS$ then
ErrorMsg = 'Unable to Lock !WM_IN to add index transaction. ':WMIKey
end
end
Unlock BangTable, 0 else ErrorMsg = 'Unable to Open !WM_IN to add index transaction. ':WMIKey
end else
ErrorMsg = 'Unable to Lock !WM_IN to add index transaction. ':WMIKey
end
Until Done or ErrorMsg
Next AttemptNo
end else
ErrorMsg = 'Unable to Open !WM_IN to add index transaction. ':WMIKey
end
@ -263,10 +273,9 @@ Service VerifyWOLogWMIKeyIndex(WMIKey)
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' !WM_IN WM_IN{WO_NO} Log.csv'
Headers = 'Logging DTM':@FM:'WMIKey':@FM:'WOStep':@FM:'Result'
objVerifyWMIWoIndexLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, COMMA$, Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
LogData = ''
LogData<1> = LoggingDtm
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<2> = WMIKey
LogData<4> = 'Begin ':Service
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
@ -278,32 +287,44 @@ Service VerifyWOLogWMIKeyIndex(WMIKey)
If WONo NE '' then
WOLogRDSKeys = ''
Extract_Si_Keys('WM_IN', 'WO_NO', WONo, WOLogRDSKeys)
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<3> = WONo
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
Locate WMIKey in WOLogRDSKeys using @VM setting vPos else
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'WMIKey missing from Btree index. Generating index transaction.'
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
// Add index transaction to update WO_NO btree index
IndexTransactionRow = 'WO_NO':@FM:WMIKey:@FM:"":@FM:WONo:@FM
Open "!WM_IN" to BangTable then
Lock BangTable, 0 then
Read PendingTrans from BangTable, 0 else PendingTrans = '0':@FM
PendingTrans := IndexTransactionRow
Write PendingTrans on BangTable, 0 then
LogData<4> = 'Index transaction successfully added.'
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
Done = False$
For AttemptNo = 1 to NUM_ATTEMPTS$
If AttemptNo GT 1 then Delay(1)
Lock BangTable, 0 then
Read PendingTrans from BangTable, 0 else PendingTrans = '0':@FM
PendingTrans := IndexTransactionRow
Write PendingTrans on BangTable, 0 then
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'Index transaction successfully added.'
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
Done = True$
end else
ErrorMsg = 'Error in ':Service:' service. Unable to write index transaction to !WM_IN. ':WMIKey
end
Unlock BangTable, 0 else ErrorMsg = 'Error in ':Service:' service. Unable to Open !WM_IN to add index transaction. ':WMIKey
end else
ErrorMsg = 'Error in ':Service:' service. Unable to write index transaction to !WM_IN. ':WMIKey
If AttemptNo GE NUM_ATTEMPTS$ then
ErrorMsg = 'Error in ':Service:' service. Unable to Lock !WM_IN to add index transaction. ':WMIKey
end
end
Unlock BangTable, 0 else ErrorMsg = 'Error in ':Service:' service. Unable to Open !WM_IN to add index transaction. ':WMIKey
end else
ErrorMsg = 'Error in ':Service:' service. Unable to Lock !WM_IN to add index transaction. ':WMIKey
end
Until Done or ErrorMsg
Next AttemptNo
end else
ErrorMsg = 'Error in ':Service:' service. Unable to Open !WM_IN to add index transaction. ':WMIKey
end
end
end else
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'WONo for WM_IN ':WMIKey:' is null. Nothing to update.'
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
end
@ -313,10 +334,12 @@ Service VerifyWOLogWMIKeyIndex(WMIKey)
end
If ErrorMsg NE '' then
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = ErrorMsg
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
end
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'End ':Service
Logging_Services('AppendLog', objVerifyWMIWoIndexLog, LogData, @RM, @FM)
@ -333,10 +356,9 @@ Service VerifyWOMatWMIKeyIndex(WMIKey)
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' !WM_IN WO_MAT{WMI_KEY} Log.csv'
Headers = 'Logging DTM':@FM:'WMIKey':@FM:'WOMatKey':@FM:'Result'
objVerifyWoMatWmiKeyLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, COMMA$, Headers, '', False$, False$)
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
LogData = ''
LogData<1> = LoggingDtm
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<2> = WMIKey
LogData<4> = 'Begin ':Service
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
@ -347,32 +369,44 @@ Service VerifyWOMatWMIKeyIndex(WMIKey)
WOMatKey = Field(WMIKey, '*', 1, 1):'*':Field(WMIKey, '*', 3, 1)
If WOMatKey NE '' then
WOMatWMIKey = Xlate('WO_MAT', WOMatKey, 'WMI_KEY', 'X')
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<3> = WOMatKey
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
If WOMatWMIKey EQ '' then
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'WMIKey missing from WO_MAT record. Generating index transaction.'
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
// Add index transaction to update WMI_KEY relational index (target WO_MAT table)
IndexTransactionRow = 'WO_MAT*WMI_KEY*TOP':@FM:WMIKey:@FM:"":@FM:WOMatKey:@FM
Open "!WM_IN" to BangTable then
Lock BangTable, 0 then
Read PendingTrans from BangTable, 0 else PendingTrans = '0':@FM
PendingTrans := IndexTransactionRow
Write PendingTrans on BangTable, 0 then
LogData<4> = 'Index transaction successfully added.'
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
Done = False$
For AttemptNo = 1 to NUM_ATTEMPTS$
If AttemptNo GT 1 then Delay(1)
Lock BangTable, 0 then
Read PendingTrans from BangTable, 0 else PendingTrans = '0':@FM
PendingTrans := IndexTransactionRow
Write PendingTrans on BangTable, 0 then
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'Index transaction successfully added.'
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
Done = True$
end else
ErrorMsg = 'Unable to write index transaction to !WM_IN. ':WMIKey
end
Unlock BangTable, 0 else ErrorMsg = 'Unable to Open !WM_IN to add index transaction. ':WMIKey
end else
ErrorMsg = 'Unable to write index transaction to !WM_IN. ':WMIKey
If AttemptNo GE NUM_ATTEMPTS$ then
ErrorMsg = 'Unable to Lock !WM_IN to add index transaction. ':WMIKey
end
end
Unlock BangTable, 0 else ErrorMsg = 'Unable to Open !WM_IN to add index transaction. ':WMIKey
end else
ErrorMsg = 'Unable to Lock !WM_IN to add index transaction. ':WMIKey
end
Until Done or ErrorMsg
Next AttemptNo
end else
ErrorMsg = 'Unable to Open !WM_IN to add index transaction. ':WMIKey
end
end
end else
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'WO_MAT key for WM_IN ':WMIKey:' is null. Nothing to update.'
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
end
@ -380,10 +414,12 @@ Service VerifyWOMatWMIKeyIndex(WMIKey)
end
If ErrorMsg NE '' then
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = ErrorMsg
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)
end
LogData<1> = OConv(Datetime(), 'DT/^S')
LogData<4> = 'End ':Service
Logging_Services('AppendLog', objVerifyWoMatWmiKeyLog, LogData, @RM, @FM)