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

@ -42,14 +42,15 @@ Function WO_LOG_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record,
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$insert APP_INSERTS
$insert FILE.SYSTEM.EQUATES
$insert ACTION_SETUP
$insert WO_MAT_EQUATES
$insert WO_LOG_EQUATES
$insert WO_STEP_EQUATES
$insert RLIST_EQUATES
$insert SCHED_DET_NG_EQUATES
$Insert APP_INSERTS
$Insert FILE.SYSTEM.EQUATES
$Insert ACTION_SETUP
$Insert WO_MAT_EQUATES
$Insert WO_LOG_EQUATES
$Insert WO_STEP_EQUATES
$Insert RLIST_EQUATES
$Insert SCHED_DET_NG_EQUATES
$Insert IFX_EQUATES
Equ Comma$ to ','
@ -57,7 +58,7 @@ Declare function Error_Services, Database_Services, Environment_Services, Logg
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
Declare subroutine Schedule_Services, Service_Services
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\WO_LOG'
LogDate = Oconv(Date(), 'D4/')
@ -205,12 +206,12 @@ WRITE_RECORD_PRE:
OrigQty = OrigRecord<WO_LOG_QTY$>
NewQty = Record<WO_LOG_QTY$>
ModifyQty = NewQty - OrigQty
OrigCassList = OrigRecord<WO_LOG_WO_MAT_KEY$>
NewCassList = Record<WO_LOG_WO_MAT_KEY$>
If ( (OrigQty NE NewQty) or (OrigCassList NE NewCassList) ) then
// Update released, unreleased, and received quantities
RelQty = obj_WO_Log('RelQty', Name:@RM:Record)
Record<WO_LOG_REL_QTY_STATIC$> = RelQty
// Update unreleased, open (i.e., not received) quantities
RelQty = OrigRecord<WO_LOG_REL_QTY_STATIC$>
If RelQty GT NewQty then
UnRelQty = 0
end else
@ -218,9 +219,14 @@ WRITE_RECORD_PRE:
end
Record<WO_LOG_UNREL_QTY_STATIC$> = UnRelQty
RXQty = obj_WO_Log('RxQty', Name:@RM:Record)
Record<WO_LOG_RX_QTY_STATIC$> = RXQty
SaveRecord = Record
RxQty = OrigRecord<WO_LOG_RX_QTY_STATIC$>
If RxQty GT NewQty then
OpenQty = 0
end else
OpenQty = NewQty - RxQty
end
Record<WO_LOG_OPEN_QTY_STATIC$> = OpenQty
SaveRecord = Record
end
// Check if we need to auto-close the work order
@ -278,202 +284,7 @@ WRITE_RECORD:
NewQty = Record<WO_LOG_QTY$>
ModifyQty = NewQty - OrigQty
WONo = Name
SchedDetNGKey = ''
Begin Case
Case ModifyQty GT 0
LogData = ''
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<2> = 'WO_LOG_ACTIONS'
LogData<3> = 'Work order ':WONo:' quantity increased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', '', LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Searching for a scheduled event to increase the quantity.'
Schedule_Services('LogActivity', '', LogData, False$)
// Search schedule for most recent event and increase that event quantity by the difference.
Query = 'SELECT SCHED_DET_NG WITH WO_NO EQ ':WONo:' BY-DSND STOP_DTM'
GoSub ClearCursors
Set_Status(0)
RList(Query, TARGET_ACTIVELIST$, '', '', False$)
errCode = ''
If Get_Status(errCode) then
ErrorMsg = 'Error retrieving event list in WO_LOG_Actions. RList error code ':errCode:'.'
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = ErrorMsg
Schedule_Services('LogActivity', '', LogData, False$)
Error_Services('Add', ErrorMsg)
end else
EOF = False$
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Query successful. Number of keys found: ':@RecCount:'.'
Schedule_Services('LogActivity', '', LogData, False$)
ReadNext SchedDetNGKey else EOF = True$
If SchedDetNGKey NE '' then
EventRec = Database_Services('ReadDataRow', 'SCHED_DET_NG', SchedDetNGKey)
StopDTM = EventRec<SCHED_DET_NG.STOP_DTM$>
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Work order record ':WONo:' quantity increased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Scheduled event ':SchedDetNGKey:' found.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
// Only modify the event if it is still running or is scheduled in the future.
If StopDTM GT Datetime() then
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' less than current DTM, so increasing event quantity.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
ReactNo = EventRec<SCHED_DET_NG.REACT_NO$>
WONo = EventRec<SCHED_DET_NG.WO_NO$>
StartDTM = EventRec<SCHED_DET_NG.START_DTM$>
Desc = EventRec<SCHED_DET_NG.DESC$>
EventQty = EventRec<SCHED_DET_NG.EVENT_TOTAL_WFRS$>
NewEventQty = EventQty + ModifyQty
Schedule_Services('ModifySchedEvent', SchedDetNGKey, ReactNo, WONo, StartDTM, StopDTM, Desc, NewEventQty)
// Adjust reactor events as needed.
Schedule_Services('AdjustScheduleEvents', ReactNo)
end else
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' greater than current DTM.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity not increased.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
end
end
end
GoSub ClearCursors
Case ModifyQty LT 0
LogData = ''
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<2> = 'WO_LOG_ACTIONS'
LogData<3> = 'Work order ':WONo:' quantity decreased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', '', LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Searching for a scheduled event to decrease the quantity.'
Schedule_Services('LogActivity', '', LogData, False$)
// Search schedule for most recent events and decrease/delete those events as needed.
Query = 'SELECT SCHED_DET_NG WITH WO_NO EQ ':WONo:' BY-DSND STOP_DTM'
GoSub ClearCursors
Set_Status(0)
RList(Query, TARGET_ACTIVELIST$, '', '', False$)
errCode = ''
If Get_Status(errCode) then
ErrorMsg = 'Error retrieving event list in WO_LOG_Actions. RList error code ':errCode:'.'
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = ErrorMsg
Schedule_Services('LogActivity', '', LogData, False$)
Error_Services('Add', ErrorMsg)
end else
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Query successful. Number of keys found: ':@RecCount:'.'
Schedule_Services('LogActivity', '', LogData, False$)
EOF = False$
Done = False$
UpdateReq = False$
Loop
ReadNext SchedDetNGKey else EOF = True$
Until EOF EQ True$
If SchedDetNGKey NE '' then
EventRec = Database_Services('ReadDataRow', 'SCHED_DET_NG', SchedDetNGKey)
StopDTM = EventRec<SCHED_DET_NG.STOP_DTM$>
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Work order record ':WONo:' quantity decreased from ':OrigQty:' to ':NewQty:'.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Scheduled event ':SchedDetNGKey:' found.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
// Only modify the event if it is still running or is scheduled in the future.
If StopDTM GT Datetime() then
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' less than current DTM, so decreasing event quantity.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
UpdateReq = True$
ReactNo = EventRec<SCHED_DET_NG.REACT_NO$>
WONo = EventRec<SCHED_DET_NG.WO_NO$>
StartDTM = EventRec<SCHED_DET_NG.START_DTM$>
Desc = EventRec<SCHED_DET_NG.DESC$>
EventQty = EventRec<SCHED_DET_NG.EVENT_TOTAL_WFRS$>
If EventQty GT Abs(ModifyQty) then
// This event has enough wafers, so just reduce the quantity.
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity ':EventQty:' greater than quantity reduction ':ModifyQty:', so decreasing event quantity.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
Done = True$
NewEventQty = EventQty + ModifyQty
Schedule_Services('ModifySchedEvent', SchedDetNGKey, ReactNo, WONo, StartDTM, StopDTM, Desc, NewEventQty)
end else
// This event has fewer wafers than are being removed. Delete this event and continue
// onto the next event.
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity ':EventQty:' less than quantity reduction ':ModifyQty:', so canceling event.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
Schedule_Services('CancelScheduleEvent', SchedDetNGKey, True$)
ModifyQty += EventQty
end
end else
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event stop DTM ':OConv(StopDtm, 'DT2/^H'):' greater than current DTM.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
LogData<1> = OConv(Datetime(), 'DT2/^H')
LogData<3> = 'Event quantity not decreased.'
Schedule_Services('LogActivity', EventRec<SCHED_DET_NG.REACT_NO$>, LogData, False$)
end
end
Until Done EQ True$
Repeat
If UpdateReq then
// Adjust reactor events as needed.
Schedule_Services('AdjustScheduleEvents', ReactNo)
end
end
GoSub ClearCursors
Case Otherwise$
Null
End Case
If ModifyQty NE 0 then Service_Services('PostProcedure', 'SCHEDULE_SERVICES', 'AdjustWorkOrderScheduleQty':SD$:WONo:SD$:ModifyQty)
return