COMPILE FUNCTION obj_Test_Wafer(Method,Parms)

/*
	Methods for TEST_WAFER table
    
	06/28/2016 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    Create()	; New Record from parms passed in.
	
	
*/


DECLARE FUNCTION	Get_Status, Msg, Utility, obj_Tables, NextKey, obj_WO_Wfr
DECLARE SUBROUTINE 	Set_Status, Msg, obj_Tables, obj_Notes, ErrMsg, RList, Send_Dyn, Send_Info
DECLARE SUBROUTINE	Btree.Extract, obj_WO_Wfr



$INSERT RDS_TEST_EQUATES
$INSERT TEST_WAFER_EQUATES
$INSERT RLIST_EQUATES


EQU CRLF$	TO \0D0A\

ErrTitle = 'Error in Stored Procedure "obj_Test_Wafer"'
ErrorMsg = ''

IF NOT(ASSIGNED(Method))	THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine'
IF NOT(ASSIGNED(Parms))		THEN Parms = ''

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

Result = ''

BEGIN CASE
	CASE Method = 'Create'			; GOSUB Create
	
	CASE 1

END CASE

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

RETURN Result


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

RDSNo		= Parms[1,@RM]
CharWfrIDs	= Parms[COL2()+1,@RM]

TWNo = NextKey('TEST_WAFER')

TWRec = ''
TWRec<TEST_WAFER_RDS_NO$> = RDSNo
TWRec<TEST_WAFER_WFR_ID$> = CharWfrIDs

otParms = 'TEST_WAFER':@RM:TWNo:@RM:@RM:TWRec
obj_Tables('WriteRec',otParms)

WfrCnt = COUNT(CharWfrIDs,@VM) + (CharWfrIDs NE '')

FOR S = 1 TO WfrCnt

	WfrID = CharWfrIDs<1,S>
	
	CurrLocs = obj_WO_Wfr('CurrLoc',WfrID:@RM:'')	;* Added 10/3/2016 JCH
				
	CurrSlotID	= CurrLocs<1,2>						;* Added 10/3/2016 JCH
	CurrTool	= CurrLocs<1,3>						;* Added 10/3/2016 JCH
	CurrInvLoc	= CurrLocs<1,4>						;* Added 10/3/2016 JCH
	
	/*
	Recipients		= 'BRYCE_BARB'
	SentFrom		= @USER4
	Subject			= 'TW_USE non EpiPRO':TWNo
	Message			= 'WfrID = ':QUOTE(WfrID):CRLF$:'CurrSlotID = ':QUOTE(CurrSlotID):CRLF$:'CurrInvLoc = ':QUOTE(CurrInvLoc):CRLF$
	AttachWindow	= 'TEST_WAFER'
	AttachKey		= TWNo
	SendToGroup		= ''   

	Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
	obj_Notes('Create',Parms)
	*/
	
	CurrDTM =  OCONV(Date(),'D4/'):' ':OCONV(Time(),'MTS')
	
	
	Parms  = WfrID:@RM				;* WfrID
	Parms := CurrDTM:@RM								;* EventDtm
	Parms := @USER4:@RM									;* EventBy
	Parms := 'TEST':@RM									;* Event
	Parms := '':@RM										;* NewSlotID
	Parms := '':@RM										;* RunLoc
	Parms := '':@RM										;* NCRNo
	Parms := TWNo:@RM									;* TWfrNo
	Parms := CurrSlotID:@RM								;* CurrSlotID
	Parms := '':@RM										;* NewToolID
	Parms := CurrTool:@RM								;* CurrToolID
	Parms := '':@RM										;* NewInvLoc
	Parms := CurrInvLoc:@RM								;* CurrInvLoc
	Parms := 'O'										;* Inbound or Outbound Wafers										;* CurrSlotID

	obj_WO_Wfr('AddEvent',Parms)
	
NEXT S


Result = TWNo

RETURN





















