COMPILE FUNCTION obj_WO_Mat_GAN(Method,Parms)

/*
	Methods for WO_MAT and related tables used for GaN processes material
    
	07/13/2016 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    GetManifestWfrs()  		;* nothing historical just Returns all shippable wafers on GaN wfrs not yet placed into a shipping cassette
	
	
*/

DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, 
DECLARE SUBROUTINE obj_WO_Wfr, ErrMsg, Btree.Extract

DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, NextKey,  obj_Prod_Spec, Send_Dyn, obj_Clean_Insp


$INSERT WO_LOG_EQUATES
$INSERT WO_MAT_EQUATES
$INSERT WO_WFR_EQUATES
$INSERT REACT_RUN_EQUATES
$INSERT RUN_STAGE_WFR_EQUATES
$INSERT RLIST_EQUATES


EQU COL$IN_WFR_ID		TO 1	;* Equates used in return data structure for Manifest Wafers
EQU COL$CARR_SLOT_ID	TO 2
EQU COL$GAN_WFR_ID		TO 3
EQU COL$SCRIBE			TO 4
EQU COL$WFR_GRADE		TO 5
EQU COL$WFR_SHIP		TO 6
EQU COL$OUT_SLOT_ID		TO 7


ErrTitle = 'Error in Stored Procedure "obj_WO_Mat_GAN"'
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 = 'GetManifestWfrs'
	    GOSUB GetManifestWfrs
	
	CASE 1
		ErrorMsg = 'Unknown Method ':QUOTE(Method):' passed to routine'
		
END CASE

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

RETURN Result


* * * * * * *
GetManifestWfrs:
* * * * * * *

    WONo = Parms[1,@RM]

    WORec		= XLATE('WO_LOG',WONo,'','X')
    WOMatKeys	= WORec<WO_LOG_WO_MAT_KEY$>
    ReactType	= WORec<WO_LOG_REACT_TYPE$>

    IF ReactType NE 'GAN' THEN RETURN

    Open 'REACT_RUN' To RRunTable Else
        ErrMsg(ErrorMsg)
        Return 
    End 

    SelectSent = 'SELECT REACT_RUN WITH WO_NO = ':QUOTE(WONo):' BY RDS_NO'

    Set_Status(0)
    RList(SelectSent,TARGET_ACTIVELIST$,'','','')
    IF Get_Status(errCode) THEN
        ErrMsg(errCode)
        Return
    END

    Line = 0
    Done = 0

    LOOP
        READNEXT RRunKey ELSE Done = 1
    UNTIL Done
        READ RRunRec FROM RRunTable,RRunKey THEN
        
            sCnt = COUNT(RRunRec<REACT_RUN_CARR_WFR_ID$>,@VM) + (RRunRec<REACT_RUN_CARR_WFR_ID$> NE '')
            
            FOR I = 1 TO sCnt
            
                OutSlotID	= RRunRec<REACT_RUN_OUT_SLOT_ID$,I>
                ShipWfr		= RRunRec<REACT_RUN_CARR_WFR_SHIP$,I>
                
                IF RRunRec<REACT_RUN_OUT_SLOT_ID$,I> = '' AND RRunRec<REACT_RUN_CARR_WFR_SHIP$,I> = 1 THEN
                    Line += 1
                    WfrID                           = RRunRec<REACT_RUN_CARR_WFR_ID$,I>
                    Result<Line,COL$IN_WFR_ID>		= WfrID
                    Result<Line,COL$CARR_SLOT_ID>	= RRunRec<REACT_RUN_CARR_SLOT_ID$,I>
                    Pocket = Xlate('WO_WFR', WfrID, 'POCKET', 'X')
                    Result<Line,COL$GAN_WFR_ID> 	= RRunRec<REACT_RUN_GAN_RUN_ID$>:Pocket
*                    Result<Line,COL$GAN_WFR_ID> 	= RRunRec<REACT_RUN_GAN_RUN_ID$>:FMT(RRunRec<REACT_RUN_RUN_PKT$,I>,'R(0)#2')
                    Result<Line,COL$SCRIBE>			= XLATE('WO_WFR',RRunRec<REACT_RUN_IN_WFR_ID$,I>,WO_WFR_SCRIBE$,'X')
                    Result<Line,COL$WFR_GRADE>		= RRunRec<REACT_RUN_CARR_WFR_GRADE$,I>
                    Result<Line,COL$WFR_SHIP>		= RRunRec<REACT_RUN_CARR_WFR_SHIP$,I>
                    Result<Line,COL$OUT_SLOT_ID>	= RRunRec<REACT_RUN_OUT_SLOT_ID$,I>
                
                END
            
            NEXT I
            
        END	;* End of RRunRec read
        
    REPEAT
    
RETURN
