From 9d86fd5fba6bb48bab29da1ede74c4a59361006c Mon Sep 17 00:00:00 2001 From: "Infineon\\StieberD" Date: Wed, 22 Jan 2025 15:42:27 -0700 Subject: [PATCH] refactored auto hold service and toggle hold service --- LSL2/STPROC/HOLD_SERVICES.txt | 19 ++- LSL2/STPROC/MATERIAL_SERVICES.txt | 270 +++++++++++++++++++++--------- 2 files changed, 199 insertions(+), 90 deletions(-) diff --git a/LSL2/STPROC/HOLD_SERVICES.txt b/LSL2/STPROC/HOLD_SERVICES.txt index 638cb16..e545b41 100644 --- a/LSL2/STPROC/HOLD_SERVICES.txt +++ b/LSL2/STPROC/HOLD_SERVICES.txt @@ -78,7 +78,7 @@ Return Response or "" // WOMatKey - [Required] // HoldEntity - [Required] // HoldEntityID - [Required] -// CtrlEntID - [Required] +// CtrlEntID - [Optional] *Required for ship hold checks // OriginFlag - [Optional] // HoldData - [Optional] // OperatorID - [Optional] @@ -87,15 +87,15 @@ Return Response or "" //---------------------------------------------------------------------------------------------------------------------- Service ToggleHold(WOMatKey, HoldEntity, HoldEntityID, CtrlEntID, OriginFlag, HoldData, OperatorID) - IF WOMatKey = '' or HoldEntity = '' or HoldEntityID = '' or CtrlEntID = '' THEN - Error_Services('Add', 'Null parameter WOMatKey, HoldEntity, HoldEntityID, CtrlEntID passed to service.') + If ( (WOMatKey EQ '') or (HoldEntity EQ '') or (HoldEntityID EQ '') ) then + Error_Services('Add', 'Null parameter WOMatKey, HoldEntity, or HoldEntityID passed to service.') end else HoldCheck = Hold_Services("CheckForHold", WOMatKey, CtrlEntID) If Unassigned(OperatorID) then OperatorID = '' - BEGIN CASE - CASE INDEX(CtrlEntID,'SHIP_HOLD',1) ; HoldType = 'SHOLD' ; * Ship Hold - CASE 1 ; HoldType = 'HOLD' ; * Production or Engineering Hold - END CASE + Begin Case + Case Index(CtrlEntID,'SHIP_HOLD',1) ; HoldType = 'SHOLD' ; * Ship Hold + Case Otherwise$ ; HoldType = 'HOLD' ; * Production or Engineering Hold + End Case If Error_Services("NoError") then If HoldCheck = False$ then Hold_Services("OnHold", WOMatKey, HoldEntity, HoldEntityID, HoldType, HoldData, OperatorID, OriginFlag) @@ -502,8 +502,8 @@ Service CheckForHold(WOMatKey, CtrlEntID) WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey, '', '', '') BEGIN CASE - CASE INDEX(CtrlEntID,'SHIP_HOLD',1) ; HoldType = 'SHOLD' ; * Ship Hold - CASE 1 ; HoldType = 'HOLD' ; * Production or Engineering Hold + CASE Index(CtrlEntID,'SHIP_HOLD',1) ; HoldType = 'SHOLD' ; * Ship Hold + CASE Otherwise$ ; HoldType = 'HOLD' ; * Production or Engineering Hold END CASE IF HoldType = 'SHOLD' THEN @@ -765,3 +765,4 @@ Service CreateComment(HoldEntity, HoldEntityID, Reason, Transition, HoldType, Op end service + diff --git a/LSL2/STPROC/MATERIAL_SERVICES.txt b/LSL2/STPROC/MATERIAL_SERVICES.txt index 8209090..469c8d8 100644 --- a/LSL2/STPROC/MATERIAL_SERVICES.txt +++ b/LSL2/STPROC/MATERIAL_SERVICES.txt @@ -49,6 +49,7 @@ $insert CLEAN_INSP_EQUATES $insert RDS_LAYER_EQUATES $insert RDS_TEST_EQUATES $insert TW_USE_EQUATES +$insert MAKEUP_WAFERS_EQUATES Equ Tab$ to Char(9) Equ Esc$ to \1B\ @@ -264,105 +265,211 @@ End Service // looks for MakeUp wafers older than 3 years old and then puts them on hold and sends notification. //---------------------------------------------------------------------------------------------------------------------- Service ProcessAutoHold() - + // Service should run once a day or less // First find subset of Makeup lots that are over 3 years old (age based on date out) // From above list, // 1) Put affected lots on hold and // 2) Send notification to notification group - LogData = '' - LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'Begin ':Service - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + hSysLists = Database_Services('GetTableHandle', 'SYSLISTS') + Lock hSysLists, ServiceKeyID then - HoldList = '' - CutoffDate = SRP_Date('AddYears', Date(), -3) - Query = 'SELECT MAKEUP_WAFERS WITH UNLOAD_DTM LT ':Quote(OConv(CutoffDate, 'DT2/^H')) - Flag = '' - RList(Query, TARGET_ACTIVELIST$, '', '', Flag) - - LogData = '' - LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'RList Flag = ':Flag:'. @RecCount = ':@RecCount - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - - EOF = False$ - Loop - Readnext WOMatKey else EOF = True$ - Until EOF + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'Begin ':Service + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + + HoldList = '' + FailedHoldList = '' + CutoffDate = SRP_Date('AddYears', Date(), -3) + Query = 'SELECT MAKEUP_WAFERS WITH UNLOAD_DTM LT ':Quote(OConv(CutoffDate, 'DT2/^H')) + Flag = '' + RList(Query, TARGET_ACTIVELIST$, '', '', Flag) LogData = '' LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'Placing lot "':WOMatKey:'" on hold.' + LogData<2> = 'RList Flag = ':Flag:'. @RecCount = ':@RecCount Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - WONo = Field(WOMatKey, '*', 1) - ReactType = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X') - If ReactType EQ 'EPP' then - CassNo = Field(WOMatKey, '*', 2) - HoldEntity = 'WM_OUT' - HoldEntityID = WONo:'*1*':CassNo - end else - HoldEntity = 'RDS' - HoldEntityID = Xlate('WO_MAT', WOMatKey, 'RDS_NO', 'X') - end - HoldList<-1> = ReactType:TAB$:HoldEntityID - OnHold = Xlate(HoldEntity, HoldEntityID, 'HOLD', 'X') - If OnHold NE True$ then - //obj_WO_Mat('ToggleHold',WOMatKey:@RM:HoldEntity:@RM:HoldEntityID:@RM:'':@RM:'H':@RM:'SYSTEM') - Hold_Services('ToggleHold', WOMatKey, HoldEntity, HoldEntityID, '', 'H', '', 'SYSTEM') - end - - LogData = '' - LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'Lot "':WOMatKey:'" hold flag = ':Xlate(HoldEntity, HoldEntityID, 'HOLD', 'X'):'.' - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - - LogData = '' - LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'Marking lot "':WOMatKey:'" as expired.' - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - - Material_Services('MarkMUCassExpired', WOMatKey) - ExpiredFlag = Xlate('MAKEUP_WAFERS', WOMatKey, 'EXPIRED', 'X') - If Error_Services('NoError') then - LogData = '' - LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'Successfully marked lot "':WOMatKey:'" as expired. Expired flag = ':ExpiredFlag:'.' - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - end else - LogData = '' + EOF = False$ + Loop + Readnext WOMatKey else EOF = True$ + Until EOF + + ErrorMsg = '' ; // Local loop error message tracking + ExpiredFlag = '' + HoldFlag = '' + + LogData = '' LogData<1> = OConv(Datetime(), 'DT2/^H') - ErrorMsg = 'Failed to mark lot "':WOMatKey:'" as expired. Expired flag = ':ExpiredFlag:'. ' - ErrorMsg := 'Error message: ':Error_Services('GetMessage') - LogData<2> = ErrorMsg + LogData<2> = 'Identified lot "':WOMatKey:'" as older than three years. Checking hold state...' Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + + WONo = Field(WOMatKey, '*', 1) + ReactType = Xlate('WO_LOG', WONo, 'REACT_TYPE', 'X') + If ReactType EQ 'EPP' then + CassNo = Field(WOMatKey, '*', 2) + HoldEntity = 'WM_OUT' + HoldEntityID = WONo:'*1*':CassNo + end else + HoldEntity = 'RDS' + HoldEntityID = Xlate('WO_MAT', WOMatKey, 'RDS_NO', 'X') + end + + WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey) + If Error_Services('NoError') then + HoldFlag = WOMatRec + If HoldFlag EQ True$ then + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'Lot "':WOMatKey:'" already on hold. Hold flag = ':HoldFlag:'.' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end else + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'Lot "':WOMatKey:'" not on hold. Hold flag = ':HoldFlag:'. Attempting to place lot on hold...' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + + // Toggle hold state + Hold_Services('ToggleHold', WOMatKey, HoldEntity, HoldEntityID, '', 'H', '', 'SYSTEM') + If Error_Services('NoError') then + // Verify hold state + // Re-read record to verify hold state + WOMatRec = Database_Services('ReadDataRow', 'WO_MAT', WOMatKey) + If Error_Services('NoError') then + NewHoldFlag = WOMatRec + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'Lot "':WOMatKey:'" new hold flag = ':NewHoldFlag:'.' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + If NewHoldFlag EQ HoldFlag then + // Something went wrong somewhere + ErrorMsg = 'New hold state, ':NewHoldFlag:', of lot "':WOMatKey:'" equals previous hold state, ':HoldFlag:'.' + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = ErrorMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + end else + ErrorMsg = Error_Services('GetMessage') + LogMsg = 'Failed to verify lot "':WOMatKey:'" was placed on hold.' + LogMsg := 'Error message: ':ErrorMsg + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = LogMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + end else + ErrorMsg = Error_Services('GetMessage') + LogMsg = 'Failed to toggle hold state of lot "':WOMatKey:'".' + LogMsg := 'Error message: ':ErrorMsg + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = LogMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + end + If ErrorMsg EQ '' then + // Now mark cassette as expired + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'Attempting to mark lot "':WOMatKey:'" as expired.' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + + Material_Services('MarkMUCassExpired', WOMatKey) + If Error_Services('NoError') then + MWRec = Database_Services('ReadDataRow', 'MAKEUP_WAFERS', WOMatKey) + If Error_Services('NoError') then + ExpiredFlag = MWRec + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'Successfully marked lot "':WOMatKey:'" as expired. Expired flag = ':ExpiredFlag:'.' + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end else + ErrorMsg = Error_Services('GetMessage') + LogMsg = 'Failed to verify lot "':WOMatKey:'" was marked as expired.' + LogMsg := 'Error message: ':ErrorMsg + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = LogMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + end else + ErrorMsg = Error_Services('GetMessage') + LogMsg = 'Failed to mark lot "':WOMatKey:'" as expired.' + LogMsg := 'Error message: ':ErrorMsg + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = LogMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + end else + ErrorMsg = Error_Services('GetMessage') + LogMsg = 'Failed to toggle hold state of lot "':WOMatKey:'".' + LogMsg := 'Error message: ':ErrorMsg + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = LogMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + end else + ErrorMsg = Error_Services('GetMessage') + LogMsg = 'Failed to place lot "':WOMatKey:'" on hold. Error reading WO_MAT record to get hold state.' + LogMsg := 'Error message: ':ErrorMsg + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = LogMsg + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + end + + If (ErrorMsg EQ '') then + HoldList<-1> = ReactType:TAB$:HoldEntityID + end else + FailedHoldList<-1> = ReactType:TAB$:HoldEntityID + end + + Repeat + + // Send notification of successful lots and failed lots + If (HoldList NE '') then + Recipients = '' + SentFrom = 'SYSTEM' + Subject = 'Makeup Wafer Auto-Hold Report' + AttachWindow = '' + AttachKey = '' + SendToGroup = 'AUTO_HOLD' + Message = 'The following makeup cassettes are older than three years and have been automatically ' + Message := 'placed on hold.':CRLF$:'Reminder: EpiPro lots can contain multiple RDS lots.':CRLF$:CRLF$ + Swap @FM with CRLF$ in HoldList + Message := HoldList + Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup + obj_Notes('Create',Parms) end - Repeat - - // Send notification if list is not null - If HoldList NE '' then - Recipients = '' - SentFrom = 'SYSTEM' - Subject = 'Makeup Wafer Auto-Hold Report' - AttachWindow = '' - AttachKey = '' - SendToGroup = 'AUTO_HOLD' - Message = 'The following makeup cassettes are older than three years and have been automatically ' - Message := 'placed on hold.':CRLF$:'Reminder: EpiPro lots can contain multiple RDS lots.':CRLF$:CRLF$ - Swap @FM with CRLF$ in HoldList - Message := HoldList - Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup - obj_Notes('Create',Parms) + If (FailedHoldList NE '') then + Recipients = '' + SentFrom = 'SYSTEM' + Subject = 'Makeup Wafer Auto-Hold Report' + AttachWindow = '' + AttachKey = '' + SendToGroup = 'AUTO_HOLD' + Message = 'The following makeup cassettes are older than three years and failed to be placed on hold by ' + Message := 'the system.':CRLF$:'Reminder: EpiPro lots can contain multiple RDS lots.':CRLF$:CRLF$ + Swap @FM with CRLF$ in FailedHoldList + Message := FailedHoldList + Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup + obj_Notes('Create',Parms) + end + + LogData = '' + LogData<1> = OConv(Datetime(), 'DT2/^H') + LogData<2> = 'End ':Service + Logging_Services('AppendLog', objLog, LogData, @RM, @FM) + + Unlock hSysLists, ServiceKeyID else Null end - LogData = '' - LogData<1> = OConv(Datetime(), 'DT2/^H') - LogData<2> = 'End ':Service - Logging_Services('AppendLog', objLog, LogData, @RM, @FM) - end service @@ -1353,3 +1460,4 @@ ClearCursors: return +