Compile function OPERATION_TW_CREATE(LotId, Action, Operator) //Action: IN, OUT, PROCESS Declare function Lot_Services, Error_Services, Datetime, Database_Services Declare subroutine Database_Services, Lot_Services #pragma precomp SRP_PreCompiler $insert LOGICAL $Insert APP_INSERTS $Insert Lot_Operation_Equates $Insert LOT_EQUATES Success = False$ debug If RowExists('LOT', LotId) then If Operator NE '' and RowExists('LSL_USERS', Operator) then Begin Case Case Action = 'IN' GoSub MoveIn Case Action = 'OUT' GoSub MoveOut Case Action = 'PROCESS' GoSub Process Case Otherwise$ null End Case end else Error_Services('Add', 'Operator ID was null') end end else Error_Services('Add', 'Invalid lot passed to Operation routine.') Success = False$ end Return Success MoveIn: debug //Get TW Create Operation ID ThisOperationID = Lot_Services('GetLotCurrOperationId', LotId) If Field(ThisOperationId, '*', 1) EQ 'TW_CREATE' then ThisLotCurrOperationRec = Database_Services('ReadDataRow', 'LOT_OPERATION', ThisOperationID) ThisLotCurrOperationRec = Datetime() ThisLotCurrOperationRec = Xlate('LOT', LotId, LOT_WAFER_QTY$, 'X') ThisLotCurrOperationRec = Operator Database_Services('WriteDataRow', 'LOT_OPERATION', ThisLotCurrOperationID, ThisOperationID) If Error_Services('NoError') then LotType = XLATE('LOT', LotId, LOT_TYPE$, 'X') CurrOperation = XLATE('LOT_OPERATION', ThisLotCurrOperationID, LOT_OPERATION_OPERATION_ID$, 'X') Lot_Services('CreateLotEvent', LotId, LotType, Datetime(), 'MOVE_IN', '', '', 0, 0, CurrOperation, Operator) end end else Error_Services('Add', 'Failed to move in lot. Lot is not currently at TW_CREATE. Detected Operation is ' : Field(ThisOperationId, '*', 1)) end return MoveOut: ThisOperationID = Lot_Services('GetLotCurrOperationID', LotId) If Field(ThisOperationId, '*', 1) EQ 'TW_CREATE' then ThisLotCurrOperationRec = Database_Services('ReadDataRow', 'LOT_OPERATION', ThisLotCurrOperationID) LotMovedIn = ThisLotCurrOperationRec If LotMovedIn then ThisOperationSteps = ThisLotCurrOperationRec AllStepsCompleted = False$ for each OperationStepId in ThisOperationSteps using @VM ThisStepComplete = Xlate('LOT_OPERATION_STEP', OperationStepId, LOT_OPERATION_STEP_STEP_COMPLETED$, 'X') If ThisStepComplete then AllStepsComplete = True$ end else AllStepsComplete = False$ end until AllStepsCompleted = False$ Next OperationStep If AllStepsCompleted then ThisLotCurrOperationRec = Datetime() ThisLotCurrOperationRec = Xlate('LOT', LotId, LOT_WAFER_QTY$, 'X') ThisLotCurrOperationRec = Operator Database_Services('WriteDataRow', 'LOT_OPERATION', ThisLotCurrOperationID, ThisLotCurrOperationRec) If Error_Services('NoError') then LotType = XLATE('LOT', LotId, LOT_TYPE$, 'X') CurrOperation = XLATE('LOT_OPERATION', ThisLotCurrOperationID, LOT_OPERATION_OPERATION_ID$, 'X') Lot_Services('CreateLotEvent', LotId, LotType, Datetime(), 'MOVE_OUT', '', '', ReduceQty, BonusQty, CurrOperation, Operator) end end else Error_Services('Add', 'Failed to move out lot. Not all steps completed.') end end else Error_Services('Add', 'Failed to move out lot. Lot was not moved in.') end end return Process: //Get Current Step and proceed from that step onward return OpenLot: return PrintLabel: return