COMPILE FUNCTION Comm_Dialog_Unload_Epi_Pro(Method, Parm1, Parm2)

/*
	Commuter module for Dialog_Unload_Epi_Pro window.
	
	05/01/2006 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, End_Dialog, Set_Status, ErrMsg, obj_RDS2, Send_Event, RDS_React_Run
DECLARE SUBROUTINE obj_Appwindow, Start_Window, Msg, End_Dialog, Send_Message, obj_WM_Out, obj_WM_Wfrs, obj_React_Status
DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, Popup, obj_WM_Out, Send_Message, obj_NCR, ETMethod, obj_WM_Wfrs

EQU CRLF$	TO \0D0A\

$INSERT POPUP_EQUATES
$INSERT LOGICAL
$INSERT MSG_EQUATES
$INSERT RDS_EQU
$INSERT RDS_TEST_EQUATES
$INSERT REACTOR_EQUATES
$INSERT RDS_EPILOAD
$INSERT NCR_EQU
$INSERT EPI_SUSCEPTOR_EQUATES
$INSERT PROD_SPEC_EQU
$INSERT QUOTE_SPEC_EQU
$INSERT WO_LOG_EQU
$INSERT WM_OUT_EQUATES
$INSERT APPCOLORS

EQU COL$WM_OUT_CASS		TO 1
EQU COL$WM_OUT_SLOT		TO 2

EQU COL$POCKET		TO 1
EQU COL$USAGE		TO 2
EQU COL$ZONE		TO 3
EQU COL$IN_CASS		TO 4
EQU COL$IN_SLOT		TO 5
EQU COL$WAFER_TYPE	TO 6
EQU COL$OUT_CASS	TO 7
EQU COL$OUT_SLOT	TO 8
EQU COL$OUT_NCR		TO 9

EQU COL$NCR_NO		TO 1
EQU COL$NCR_POCKET	TO 2


ErrTitle = 'Error in Comm_Dialog_Load_Epi_Pro'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE Method = 'Create'				; GOSUB Create
	CASE Method = 'Close'				; GOSUB Close
	CASE Method = 'Done'				; GOSUB Done
	CASE Method = 'Refresh'				; GOSUB Refresh
	CASE Method = 'UpdateWMOut'			; GOSUB UpdateWMOut
	CASE Method = 'ReloadProduct'		; GOSUB ReloadProduct
	CASE Method = 'UnloadProduct'		; GOSUB UnloadProduct
	CASE Method = 'ReactIR'				; GOSUB ReactIR
	CASE Method = 'ReactDR'				; GOSUB ReactDR
	
	CASE 1
		ErrMsg(ErrTitle:@SVM:'Unknown method ':QUOTE(Method):' passed to routine.')
		
END CASE


RETURN Result


* * * * * * *
Create:
* * * * * * *

obj_AppWindow('Create')

* get the current style

EQU MULTILINE_STYLE$	TO 512 			;* MultiLine Select
EQU DROPDOWN_STYLE$		TO 131072

Style = Get_Property(@WINDOW:'.REACTOR_TABLE', 'STYLE')									

IF Style [1,2] _EQC "0x" THEN
  CONVERT @LOWER.CASE TO @UPPER.CASE IN STYLE
  Style = ICONV(Style [3,99], "MX")
END

Style = BitOr(Style, MULTILINE_STYLE$)
Set_Property(@WINDOW:'.REACTOR_TABLE', "STYLE", Style)

RDSNo		= FIELD(Parm1,@FM,1)
CurrentLoad = FIELD(Parm1,@FM,2,99)

IF RDSNo = '' THEN 
	ErrMsg('Null RDS No passed to Dialog Box...')
	End_Dialog(@WINDOW,'')
END

RDSRec = XLATE('RDS',RDSNo,'','X')

ReactorNo	= RDSRec<RDS_REACTOR$>
WONo		= RDSRec<RDS_WO$>
WOStepKey	= RDSRec<RDS_WO_STEP_KEY$>
WOStep	 	= FIELD(WOStepKey,'*',2)

PSNo			= XLATE('WO_STEP',WOStepKey,1,'X')
SubstrateSpec	= XLATE('PROD_SPEC',PSNo,PROD_SPEC_SPEC_SUBSTRATE$,'X')
ReactorType 	= XLATE('PROD_SPEC',PSNo,PROD_SPEC_REACTOR_TYPE$,'X')

SubPostClean = SubstrateSpec<1,QSSubPostClean$>
PSType		 = SubstrateSpec<1,QSSubSpecType$>

WaferSize = SubstrateSpec<1,QSSubWaferSize$>

BEGIN CASE
	CASE WaferSize = '125 mm 5 in' ; EpiSusceptorKey = '5'
	CASE WaferSize = '150 mm 6 in' ; EpiSusceptorKey = '6'
	CASE WaferSize = '200 mm 8 in' ; EpiSusceptorKey = '8'
	CASE 1
		ErrMsg('Unknown Wafer Size ':QUOTE(WaferSize):' in PSN ':PSNo)
		End_Dialog(@WINDOW,'')
		
END CASE

EpiSusceptorRec = XLATE('EPI_SUSCEPTOR',EpiSusceptorKey,'','X')

Pockets = EpiSusceptorRec<EPI_SUSCEPTOR_POCKET_NO$>
Zones	= EpiSusceptorRec<EPI_SUSCEPTOR_POCKET_ZONE$>	
PTypes	= EpiSusceptorRec<EPI_SUSCEPTOR_POCKET_TYPE$>


Ctrls = @WINDOW:'.RDS_NO':@RM:@WINDOW:'.WO_NO':@RM:@WINDOW:'.WO_STEP':@RM:@WINDOW:'.REACTOR_NO'
Props = 'DEFPROP':@RM: 'DEFPROP':@RM: 'DEFPROP':@RM: 'DEFPROP'
Vals  = RDSNo:@RM:WONo:@RM:WOStep:@RM:ReactorNo

Set_Property(Ctrls,Props,Vals)

RCtrl = @WINDOW:'.REACTOR_TABLE'
IF CurrentLoad<1,1> = '' THEN

	FOR I = 1 TO COUNT(Pockets,@VM) + (Pockets NE '')
		Set_Property(RCtrl,'CELLPOS',Pockets<1,I>,COL$POCKET:@FM:I)
		Set_Property(RCtrl,'CELLPOS',PTypes<1,I>,COL$USAGE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',Zones<1,I>,COL$ZONE:@FM:I)
	NEXT I

	Set_Property(@WINDOW,'@LAST_POCKET',I-1)
	
END ELSE
	* Use load data previously saved on the RDS
	FOR I = 1 TO COUNT(CurrentLoad<1>,@VM) + (CurrentLoad<1> NE '')
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$POCKET,I>,COL$POCKET:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$USAGE,I>,COL$USAGE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$ZONE,I>,COL$ZONE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$IN_CASS,I>,COL$IN_CASS:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$IN_SLOT,I>,COL$IN_SLOT:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$WAFER_TYPE,I>,COL$WAFER_TYPE:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$OUT_CASS,I>,COL$OUT_CASS:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$OUT_SLOT,I>,COL$OUT_SLOT:@FM:I)
		Set_Property(RCtrl,'CELLPOS',CurrentLoad<COL$OUT_NCR,I>,COL$OUT_NCR:@FM:I)
	NEXT I
END

GOSUB UpdateWMOut


** Now Lock the available outbound slots  **

LoadedMaterial	= ''
ReactorList		= Get_Property(RCtrl,'LIST')

FOR I = COUNT(ReactorList,@FM) + (ReactorList NE '') TO 1 STEP -1
	IF ReactorList<I,COL$WAFER_TYPE> = 'PROD' AND ReactorList<I,COL$USAGE> NE 'DUMMY' THEN
		IF ReactorList<I,COL$USAGE> NE 'TEST' THEN
			LoadedMaterial = INSERT(LoadedMaterial,1,0,0,I)
		END
	END
NEXT I

LoadCnt	= COUNT(LoadedMaterial,@FM) + (LoadedMaterial NE '')

AvailSlots	= ''
WMOutList	= Get_Property(@WINDOW:'.WM_OUT_TABLE','LIST')

FOR I = 1 TO COUNT(WMOutList,@FM) + (WMOutList NE '')
	IF WMOutList<I,COL$WM_OUT_CASS> NE '' THEN
		AvailSlots<I,1> = WMOutList<I,COL$WM_OUT_CASS>
		AvailSlots<I,2> = WMOutList<I,COL$WM_OUT_SLOT>
	END
NEXT I

AvailSlotCnt	= COUNT(AvailSlots,@FM) + (AvailSlots NE '')


IF AvailSlotCnt > 0 THEN
	WONo	= Get_Property(@WINDOW:'.WO_NO','TEXT')
	WOStep	= Get_Property(@WINDOW:'.WO_STEP','TEXT')

	WMOWaferKeys = ''
	LoadSlotsLocked = 0

	FOR LC = 1 TO LoadCnt
		OutCassNo = AvailSlots<LC,1>
		OutSlotNo = AvailSlots<LC,2>
		
		WMOWaferKey = WONo:'*':WOStep:'*':OutCassNo:'*':OutSlotNo
		WMOWaferKeys<1,-1> = WMOWaferKey
	NEXT LC

	Set_Status(0)
	LockedWMOKeys = obj_WM_Wfrs('LockSet','WMO_WFRS':@RM:WMOWaferKeys)

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)

		Send_Event(@WINDOW,'CLOSE')
	END ELSE
		Set_Property(@WINDOW,'@LOCKED_WFRS',LockedWMOKeys)
	END
END ELSE
	Set_Property(@WINDOW,'@LOCKED_WFRS','')
END



RETURN


* * * * * * *
Close:
* * * * * * *



* * * * * * *
Done:
* * * * * * *

RCtrl = @WINDOW:'.REACTOR_TABLE'
ReactorList = Get_Property(RCtrl,'LIST')
WONo		= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
Reactor		= Get_Property(@WINDOW:'.REACTOR_NO','DEFPROP')


Pockets			= ''
PocketChars		= ''
Zones			= ''
InCassettes 	= ''
InSlots			= ''
WaferChars		= ''
OutCassettes	= ''
OutSlots		= ''
OutNCRs			= ''

LoadCnt	= 1	


FOR I = 1 TO COUNT(ReactorList,@FM) + (ReactorList NE '')
	IF ReactorList<I,COL$POCKET> NE '' THEN
		Pockets<1,LoadCnt>		= ReactorList<I,COL$POCKET>
		PocketChars<1,LoadCnt>	= ReactorList<I,COL$USAGE>
		Zones<1,LoadCnt>		= ReactorList<I,COL$ZONE>
		InCassettes<1,LoadCnt>	= ReactorList<I,COL$IN_CASS>
		InSlots<1,LoadCnt>		= ReactorList<I,COL$IN_SLOT>
		WaferChars<1,LoadCnt>	= ReactorList<I,COL$WAFER_TYPE>
		OutCassettes<1,LoadCnt>	= ReactorList<I,COL$OUT_CASS>
		OutSlots<1,LoadCnt>		= ReactorList<I,COL$OUT_SLOT>
		OutNCRs<1,LoadCnt>		= ReactorList<I,COL$OUT_NCR>
		LoadCnt += 1
	END
NEXT I

RDSNo = Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

orParms = RDSNo:@RM:Pockets:@RM:PocketChars:@RM:Zones:@RM:InCassettes:@RM:InSlots:@RM:WaferChars:@RM:OutCassettes:@RM:OutSlots:@RM:OutNCRs

obj_RDS2('LoadEpi',orParms)

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	
	WMOLocks = Get_Property(@WINDOW,'@LOCKED_WFRS')
	
	obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:WMOLocks)	; * Remove locks on the wafer slots
	
	RETURN
	
END ELSE
	* Update Reactor Status with load data * * * * * *			;* Added 11/14/2008 JCH

	LoadDTM = OCONV( Date(), 'D2/' ):' ':OCONV( Time(), 'MTH' )

	WfrCnt = COUNT(OutCassettes,@VM) + (OutCassettes NE '')
	CassIDs = ''
	FOR I = 1 TO WfrCnt
		OutCass = OutCassettes<1,I>
		LOCATE OutCass IN CassIDs USING @VM SETTING Pos ELSE
			CassIDs = INSERT(CassIDs,1,Pos,0,OutCass)
		END
	NEXT I

	
	*obj_React_Status('ReactorLoad',Reactor:@RM:WONo:@RM:CassIDs:@RM:LoadDTM)
	
	IF Get_Status(errCode) THEN ErrMsg(errCode)

END

WMOLocks = Get_Property(@WINDOW,'@LOCKED_WFRS')

IF WMOLocks NE '' THEN
	obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:WMOLocks)		; * Remove locks on the wafer slots
END

End_Dialog(@WINDOW,'')

RDS_React_Run(RDSNo)		;* Conversion to REACT_RUN code 9/25/2008 JCH **********************************************

Set_Property('RDS_UNLOAD.RDS_NO','DEFPROP',RDSNo)
Send_Event('RDS_UNLOAD','READ')


RETURN



* * * * * * *
Refresh:
* * * * * * *

RCtrl = @WINDOW:'.REACTOR_TABLE'
ReactorList = Get_Property(RCtrl,'LIST')

LastPocket = Get_Property(@WINDOW,'@LAST_POCKET')
OpenTestCnt = 0
OpenProdCnt = 0

FOR I = 1 TO COUNT(ReactorList,@FM) + (ReactorList NE '')

	IF ReactorList<I,COL$POCKET> NE '' THEN
		IF ReactorList<I,COL$USAGE> = 'PROD' THEN
			Set_Property(RCtrl,'CELLPOS','',COL$USAGE:@FM:I)
		END
		
		BEGIN CASE
			CASE ReactorList<I,COL$OUT_NCR> NE ''
				Send_Message(RCtrl,'COLOR_BY_POS',0,I,RED$)
	
			CASE ReactorList<I,COL$USAGE> = 'TEST'
				Send_Message(RCtrl,'COLOR_BY_POS',0,I,YELLOW$)
		
			CASE ReactorList<I,COL$USAGE> = 'DUMMY'
				Send_Message(RCtrl,'COLOR_BY_POS',0,I,WHITE$)
		
			CASE ReactorList<I,COL$USAGE> = 'PROD' OR ReactorList<I,COL$USAGE> = '' 
				Zone = ReactorList<I,COL$ZONE> 
				IF Zone = 1 THEN LineColor = RCV_BLUE$
				IF Zone = 2 THEN LineColor = PRE_BLUE$
				IF Zone = 3 THEN LineColor = INP_BLUE$
				IF Zone = 4 THEN LineColor = POS_BLUE$
				Send_Message(RCtrl,'COLOR_BY_POS',0,I,LineColor)
				
		END CASE
	END
	SelectedRows = Get_Property(RCtrl,'SELPOS')
	Set_Property(RCtrl,'SELPOS',SelectedRows)		;* This is a toggle - turns OFF any turned ON ************************
NEXT I


RETURN



* * * * * * *
ReloadProduct:
* * * * * * *

LoadList	= Get_Property(@WINDOW:'.REACTOR_TABLE','LIST')
WMOutArray	= Get_Property(@WINDOW:'.WM_OUT_TABLE','ARRAY')
		
WONo	= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep	= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
RDSNo	= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')


WafersPulled	= 0
NCRPresent		= 0

FOR RP = 1 TO COUNT(LoadList,@FM) + (LoadList NE '')
	IF LoadList<RP,COL$OUT_CASS> NE '' AND LoadList<RP,COL$WAFER_TYPE> = 'PROD' THEN
		IF LoadList<RP,COL$USAGE> = '' THEN
		
			CassNo = LoadList<RP,COL$OUT_CASS>
			SlotNo = LoadList<RP,COL$OUT_SLOT>
			Pocket = LoadList<RP,COL$POCKET>
			
			WMOutRec = XLATE('WM_OUT',WONo:'*':WOStep:'*':CassNo,'','X')

			LOCATE SlotNo IN WMOutRec<WM_OUT_SLOT_NO$> USING @VM SETTING Pos THEN
				IF WMOutRec<WM_OUT_RDS$,Pos> = '' THEN WafersPulled = 1
				IF WMOutRec<WM_OUT_SLOT_NCR$,Pos> NE '' THEN NCRPresent = 1
			END
			IF WafersPulled THEN ErrorMsg = 'Wafers pulled from WM_OUT ':SlotNo:' cannot reload reactor.'
			IF NCRPresent THEN ErrorMsg = 'NCR issued for Slot No ':SlotNo:' in WM_OUT.  Cannot reload reactor.'
			IF ErrorMsg NE '' THEN
				ErrMsg(ErrorMsg)
				RETURN
			END
		END
	END
NEXT RP

LoadSlotsLocked = Get_Property(@WINDOW,'@LOCKED_WFRS')

IF LoadSlotsLocked NE '' THEN

	Set_Status(0)
	LockedWMOKeys = obj_WM_Wfrs('UnlockSet','WMO_WFRS':@RM:LoadSlotsLocked)

	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
		LoadSlotsUnlocked = 0
	END ELSE
		Set_Property(@WINDOW,'@LOCKED_WFRS','')
		LoadSlotsUnlocked = 1
	END
END ELSE
	LoadSlotsUnlocked = 1
END

IF LoadSlotsUnlocked THEN


	FOR RP = 1 TO COUNT(LoadList,@FM) + (LoadList NE '')
		IF LoadList<RP,COL$OUT_CASS> NE '' AND LoadList<RP,COL$WAFER_TYPE> = 'PROD' THEN
			IF LoadList<RP,COL$USAGE> = '' THEN
			
				CassNo = LoadList<RP,COL$OUT_CASS>
				SlotNo = LoadList<RP,COL$OUT_SLOT>
				
				obj_WM_Out('RemoveWafer',WONo:@RM:WOStep:@RM:CassNo:@RM:SlotNo)

				IF Get_Status(errCode) THEN
					ErrMsg(errCode)
				END ELSE
					Set_Property(@WINDOW:'.REACTOR_TABLE','CELLPOS','',COL$OUT_CASS:@FM:RP)
					Set_Property(@WINDOW:'.REACTOR_TABLE','CELLPOS','',COL$OUT_SLOT:@FM:RP)
				END
			END
		END
	NEXT RP
END

GOSUB UpdateWMOut

RETURN



* * * * * * *
UnloadProduct:
* * * * * * *

ReactCtrl = @WINDOW:'.REACTOR_TABLE'
WMOutCtrl = @WINDOW:'.WM_OUT_TABLE'

* Get PROD wafers in the reactor

WONo	= Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep	= Get_Property(@WINDOW:'.WO_STEP','DEFPROP')
RDSNo	= Get_Property(@WINDOW:'.RDS_NO','DEFPROP')

LoadedMaterial	= ''
ReactorList		= Get_Property(ReactCtrl,'LIST')

FOR I = COUNT(ReactorList,@FM) + (ReactorList NE '') TO 1 STEP -1
	IF ReactorList<I,COL$WAFER_TYPE> = 'PROD' AND ReactorList<I,COL$USAGE> NE 'DUMMY' THEN
		IF ReactorList<I,COL$USAGE> NE 'TEST' THEN
			LoadedMaterial = INSERT(LoadedMaterial,1,0,0,I)
		END
	END
NEXT I

LoadCnt	= COUNT(LoadedMaterial,@FM) + (LoadedMaterial NE '')

AvailSlots	= ''
WMOutList	= Get_Property(@WINDOW:'.WM_OUT_TABLE','LIST')

FOR I = 1 TO COUNT(WMOutList,@FM) + (WMOutList NE '')
	IF WMOutList<I,COL$WM_OUT_CASS> NE '' THEN
		AvailSlots<I,1> = WMOutList<I,COL$WM_OUT_CASS>
		AvailSlots<I,2> = WMOutList<I,COL$WM_OUT_SLOT>
	END
NEXT I

AvailSlotCnt	= COUNT(AvailSlots,@FM) + (AvailSlots NE '')

LockedSlots = Get_Property(@WINDOW,'@LOCKED_WFRS')
	
FOR LC = 1 TO LoadCnt

	OutCassNo = AvailSlots<LC,1>
	OutSlotNo = AvailSlots<LC,2>
	
	ReactorLineNo = LoadedMaterial<LC>
	ReactorLine = ReactorList<ReactorLineNo>
	
	PocketNo	= ReactorLine<1,COL$POCKET>
	Zone		= ReactorLine<1,COL$ZONE>
	InCass		= ReactorLine<1,COL$IN_CASS>
	InSlot		= ReactorLine<1,COL$IN_SLOT>
	
	owParms  = WONo:@RM
	owParms := WOStep:@RM
	owParms := OutCassNo:@RM
	owParms := OutSlotNo:@RM
	owParms := RDSNo:@RM
	owParms := PocketNo:@RM
	owParms := Zone:@RM
	owParms := InCass:@RM
	owParms := InSlot
	
	obj_WM_Out('AddWafer',owParms)
	
	IF Get_Status(errCode) THEN
		ErrMsg(errCode)
	END ELSE
		Set_Property(@WINDOW:'.REACTOR_TABLE','CELLPOS',OutCassNo,COL$OUT_CASS:@FM:ReactorLineNo)
		Set_Property(@WINDOW:'.REACTOR_TABLE','CELLPOS',OutSlotNo,COL$OUT_SLOT:@FM:ReactorLineNo)
	END
	
NEXT LC


GOSUB UpdateWMOut

RETURN





* * * * * * *
ReactIR:
* * * * * * *

RowIndex = Parm1

IF RowIndex = '' THEN RETURN

CtrlID = @WINDOW:'.REACTOR_TABLE'

Dummy = Send_Message(CtrlID,'DELETE',RowIndex)

GOSUB Refresh

RETURN



* * * * * * *
ReactDR:
* * * * * * *

RowIndex = Parm1
RowData = Parm2

IF RowIndex = '' THEN RETURN

CtrlID = @WINDOW:'.REACTOR_TABLE'

Dummy = Send_Message(CtrlID, "INSERT", RowIndex, RowData)

GOSUB Refresh

RETURN






* * * * * * *
UpdateWMOut:
* * * * * * *

GOSUB Refresh


WONo = Get_Property(@WINDOW:'.WO_NO','DEFPROP')
WOStep = Get_Property(@WINDOW:'.WO_STEP','DEFPROP')

WMOut = Get_Property(@WINDOW:'.WM_OUT_TABLE','LIST')

ReactorLoad = Get_Property(@WINDOW:'.REACTOR_TABLE','LIST')

ReqWMLineCnt = 0
WMLineCnt = 0
FOR RL = 1 TO COUNT(ReactorLoad,@FM) + (ReactorLoad NE '')
	IF ReactorLoad<RL,COL$POCKET> NE '' AND ReactorLoad<RL,COL$USAGE> = '' THEN
		InCass		= ReactorLoad<RL,COL$IN_CASS>
		InSlot		= ReactorLoad<RL,COL$IN_SLOT>
		WaferType	= ReactorLoad<RL,COL$WAFER_TYPE>
		OutCass		= ReactorLoad<RL,COL$OUT_CASS>
		OutSlot		= ReactorLoad<RL,COL$OUT_SLOT>
		Pocket		= ReactorLoad<RL,COL$POCKET>
		IF WaferType = 'PROD' AND OutCass = '' THEN
			ReqWMLineCnt += 1
		END
	END
NEXT RL

IF ReqWMLineCnt > 0 THEN

	WMOut = Get_Property(@WINDOW:'.WM_OUT_TABLE','LIST')

	AllOpenSlots = obj_WM_Out('NextOpenSlots',WONo:@RM:WoStep)
	
	OpenSlots = FIELD(AllOpenSlots,@FM,1,ReqWMLineCnt)
		
	IF OpenSlots = '' THEN RETURN
	
	OpenBoxSlotCnt = ReqWMLineCnt
	
	FOR M = WMLineCnt+1 TO ReqWMLineCnt
		NextOpenSlot = OpenSlots[1,@FM]
		OpenSlots[1,COL2()] = ''
		Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS',NextOpenSlot<1,1>,1:@FM:M)
		Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS',NextOpenSlot<1,2>,2:@FM:M)
	NEXT M


	FOR M = ReqWMLineCnt + 1 TO 25
		Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS','',1:@FM:M)
		Set_Property(@WINDOW:'.WM_OUT_TABLE','CELLPOS','',2:@FM:M)
	NEXT M
END ELSE
	Set_Property(@WINDOW:'.WM_OUT_TABLE','LIST',STR(@VM:@FM,25))
END

RETURN



