COMPILE FUNCTION obj_RDS_Layer(Method,Parms)
/*
	Methods for RDS Layer (RDS_LAYER) table
    
	03/01/2006 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
    Create()							;* Creates New Records
    
    
    
	
*/
#pragma precomp SRP_PreCompiler


DECLARE SUBROUTINE  Set_Status, Msg, obj_Tables, ErrMsg, Logging_Services, Environment_Services

DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Dialog_Box, obj_WO_Log, NextKey, Logging_Services
DECLARE FUNCTION obj_Prod_Spec, obj_RDS_Test, obj_Recipe, Tool_Parms_Services, Database_Services, Environment_Services



$INSERT MSG_EQUATES
$INSERT RDS_EQU
$INSERT RDS_LAYER_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT PRS_LAYER_EQU
$INSERT PROD_SPEC_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT RECIPE_EQU
$INSERT RECIPE_PARMS_EQU
$INSERT DICT_EQUATES
$INSERT TOOL_PARMS_EQUATES


EQU CRLF$	TO \0D0A\

ErrTitle = 'Error in Stored Procedure "obj_RDS_Layer"'
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 Method = 'Delete'			; GOSUB Delete
	CASE Method = 'OutOfSpec'		; GOSUB OutOfSpec
	CASE Method = 'Complete'		; GOSUB Complete
	CASE Method = 'UpdateLimits'	; GOSUB UpdateLimits
	CASE 1
		ErrorMsg = 'Unknown Method ':QUOTE(Method):' passed to routine.'

END CASE

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

RETURN Result


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

RDSNo					= Parms[1,@RM]
LayerSet				= Parms[COL2()+1,@RM]
PSNId					= Parms[COL2()+1,@RM]
NoCombinedLayerSetFlag	= Parms[COL2()+1,@RM]

IF RDSNo = ''		THEN ErrorMsg = 'Null parameter "RDSNo" passed to routine (':Method:').'
IF LayerSet = ''	THEN ErrorMsg = 'Null parameter "LayerSet" passed to routine (':Method:').'
IF PSNId = ''		THEN ErrorMsg = 'Null parameter "PSNId" passed to routine (':Method:').'

IF ErrorMsg NE '' THEN RETURN

PSNRec = XLATE('PROD_SPEC',PSNId,'','X')

IF PSNRec = '' THEN
	ErrorMsg = 'Invalid PSNId ':QUOTE(PSNId):' passed to routine (':Method:').'
	RETURN
END

BEGIN CASE
	CASE LayerSet = 'L1'	; LayerNo = 1				;* This is needed to deal with the incorrect data layouts in the old system
	CASE LayerSet = 'L2'	; LayerNo = 2
	CASE LayerSet = '2'		; LayerNo = 3
	CASE LayerSet = 'L3'	; LayerNo = 4
	CASE LayerSet = '3'		; LayerNo = 5
	CASE LayerSet = 'L4'	; LayerNo = 6
	CASE LayerSet = '4'		; LayerNo = 7
END CASE

IF NoCombinedLayerSetFlag THEN LayerNo = LayerSet

EpiLayers = PSNRec<PROD_SPEC_SPEC_EPI$>

CONVERT CHAR(248) TO @RM IN EpiLayers
CONVERT @VM TO @FM IN EpiLayers
CONVERT @SVM TO @VM IN EpiLayers
CONVERT '~' TO @VM IN EpiLayers

FirstLayer = FIELD(EpiLayers,@RM,1,1)
RecipeNo = FirstLayer<QSEpiRecipe$>

EpiLayer = FIELD(EpiLayers,@RM,LayerNo,1)

RDSLayerRec = ''

*RDSLayerRec<RDS_LAYER_DEP_TIME_RATIO$> = PSNRec<PROD_SPEC_DEP_TIME_RATIO$>		;* Added 4/19/2010 JCH for HTR IGBT runs

IF INDEX(LayerSet,'L',1) OR NoCombinedLayerSetFlag THEN
    
	IF NoCombinedLayerSetFlag THEN
		LayerLimits = obj_Recipe('GetLimits',RecipeNo:@RM:PSNId:@RM:'L':LayerNo)
	END ELSE
		LayerLimits = obj_Recipe('GetLimits',RecipeNo:@RM:PSNId:@RM:LayerSet)
	END

	RDSLayerRec<RDS_LAYER_RECIPE_NO$>			= RecipeNo
	RDSLayerRec<RDS_LAYER_DOPANT$>				= LayerLimits<RP_DOPANT$>

	RDSLayerRec<RDS_LAYER_EPI_DILUENT$>			= LayerLimits<RP_EPI_DILUENT$>
	
	RDSLayerRec<RDS_LAYER_EPI_TIME_MIN$>		= LayerLimits<RP_DEPOSIT_TIME_MIN$>
	RDSLayerRec<RDS_LAYER_EPI_TIME_MAX$>		= LayerLimits<RP_DEPOSIT_TIME_MAX$>
	
	RDSLayerRec<RDS_LAYER_DILUENT_MIN$>			= LayerLimits<RP_DILUENT_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_DILUENT_MAX$>			= LayerLimits<RP_DILUENT_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MIN$>		= LayerLimits<RP_DOPANT_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MAX$>		= LayerLimits<RP_DOPANT_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_HCL_FLOW_MIN$>		= LayerLimits<RP_HCL_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_HCL_FLOW_MAX$>		= LayerLimits<RP_HCL_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_BAKE_TIME_MIN$>		= LayerLimits<RP_BAKE_TIME_MIN$>
	RDSLayerRec<RDS_LAYER_BAKE_TIME_MAX$>		= LayerLimits<RP_BAKE_TIME_MAX$>
	
	RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MIN$>		= LayerLimits<RP_H2_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MAX$>		= LayerLimits<RP_H2_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_TCS_FLOW_MIN$>		= LayerLimits<RP_TCS_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_TCS_FLOW_MAX$>		= LayerLimits<RP_TCS_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_DCS_FLOW_MIN$>		= LayerLimits<RP_DCS_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_DCS_FLOW_MAX$>		= LayerLimits<RP_DCS_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_AUX1_MIN$>			= LayerLimits<RP_AUX1_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_AUX1_MAX$>			= LayerLimits<RP_AUX1_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_AUX2_MIN$>			= LayerLimits<RP_AUX2_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_AUX2_MAX$>			= LayerLimits<RP_AUX2_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_F_OFFSET_MIN$>		= LayerLimits<RP_FOFFSET_MIN$>
	RDSLayerRec<RDS_LAYER_F_OFFSET_MAX$>		= LayerLimits<RP_FOFFSET_MAX$>
	
	RDSLayerRec<RDS_LAYER_S_OFFSET_MIN$>		= LayerLimits<RP_SOFFSET_MIN$>
	RDSLayerRec<RDS_LAYER_S_OFFSET_MAX$>		= LayerLimits<RP_SOFFSET_MAX$>
	
	RDSLayerRec<RDS_LAYER_R_OFFSET_MIN$>		= LayerLimits<RP_ROFFSET_MIN$>
	RDSLayerRec<RDS_LAYER_R_OFFSET_MAX$>		= LayerLimits<RP_ROFFSET_MAX$>
	
	RDSLayerRec<RDS_LAYER_SUSC_ETCH_MIN$> = LayerLimits<RP_SUSC_ETCH_MIN$>
	RDSLayerRec<RDS_LAYER_SUSC_ETCH_MAX$> = LayerLimits<RP_SUSC_ETCH_MAX$>
	
	RDSLayerRec<RDS_LAYER_ETCH1_MIN$> = LayerLimits<RP_ETCH1_MIN$>
	RDSLayerRec<RDS_LAYER_ETCH1_MAX$> = LayerLimits<RP_ETCH1_MAX$>
	
	RDSLayerRec<RDS_LAYER_ETCH2_MIN$> = LayerLimits<RP_ETCH2_MIN$>
	RDSLayerRec<RDS_LAYER_ETCH2_MAX$> = LayerLimits<RP_ETCH2_MAX$>
	
	RDSLayerRec<RDS_LAYER_ETCH3_MIN$> = LayerLimits<RP_ETCH3_MIN$>
	RDSLayerRec<RDS_LAYER_ETCH3_MAX$> = LayerLimits<RP_ETCH3_MAX$>

 	RDSLayerRec<RDS_LAYER_UL_TEMP_MIN$> = LayerLimits<RP_UL_TEMP_MIN$>
 	RDSLayerRec<RDS_LAYER_UL_TEMP_MAX$> = LayerLimits<RP_UL_TEMP_MAX$>
	
END

obj_Tables('WriteRec','RDS_LAYER':@RM:RDSNo:'*':LayerSet:@RM:@RM:RDSLayerRec)

RETURN




* * * * * * *
Delete:
* * * * * * *

LayerKeys = Parms[1,@RM]

IF LayerKeys = '' THEN RETURN

CONVERT @VM:@SVM TO @FM:@FM IN LayerKeys

OPEN 'RDS_LAYER' TO RDSLayerFile THEN
	KeyCnt = COUNT(LayerKeys,@FM) + (LayerKeys NE '')
	FOR I = 1 TO KeyCnt
		DELETE RDSLayerFile,LayerKeys<I> ELSE NULL
	NEXT I
END

RETURN


* * * * * * *
OutOfSpec:
* * * * * * *

RDSLayerKey	= Parms[1,@RM]
RDSLayerRec = Parms[COL2()+1,@RM]

IF RDSLayerKey = ''	THEN ErrorMsg = 'Null parameter "RDSLayerKey" passed to routine (':Method:').'

IF ErrorMsg NE '' THEN RETURN


IF RDSLayerRec = ''	THEN
	RDSLayerRec = XLATE('RDS_LAYER',RDSLayerKey,'','X')
	IF RDSLayerRec = '' THEN RETURN
END

EpiTime    = RDSLayerRec<RDS_LAYER_EPI_TIME$>
Diluent    = RDSLayerRec<RDS_LAYER_DILUENT_ADJ_PARAM$>
DopantFlow = RDSLayerRec<RDS_LAYER_DOPANT_FLOW$>
HCLFlow    = RDSLayerRec<RDS_LAYER_HCL_FLOW$>
BakeTime   = RDSLayerRec<RDS_LAYER_BAKE_TIME$>
EpiH2Flow  = RDSLayerRec<RDS_LAYER_EPI_H2_FLOW$>
TCSFlow    = RDSLayerRec<RDS_LAYER_TCS_FLOW$>
DCSFLow    = RDSLayerRec<RDS_LAYER_DCS_FLOW$>
Aux1       = RDSLayerRec<RDS_LAYER_AUX1$>
Aux2       = RDSLayerRec<RDS_LAYER_AUX2$>
FOffset    = RDSLayerRec<RDS_LAYER_F_OFFSET$>
SOffset    = RDSLayerRec<RDS_LAYER_S_OFFSET$>
ROffset    = RDSLayerRec<RDS_LAYER_R_OFFSET$>
SuscEtch   = RDSLayerRec<RDS_LAYER_SUSC_ETCH$>
Etch1      = RDSLayerRec<RDS_LAYER_ETCH1$>
Etch2      = RDSLayerRec<RDS_LAYER_ETCH2$>
Etch3      = RDSLayerRec<RDS_LAYER_ETCH3$>
ULTemp     = RDSLayerRec<RDS_LAYER_UL_TEMP$>


IF EpiTime NE '' THEN
	IF EpiTime < RDSLayerRec<RDS_LAYER_EPI_TIME_MIN$> OR EpiTime > RDSLayerRec<RDS_LAYER_EPI_TIME_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF Diluent NE '' THEN
	IF Diluent < RDSLayerRec<RDS_LAYER_DILUENT_MIN$> OR Diluent > RDSLayerRec<RDS_LAYER_DILUENT_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF DopantFlow NE '' THEN
	IF DopantFlow < RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MIN$> OR DopantFlow > RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF HCLFlow NE '' THEN
	IF HCLFlow < RDSLayerRec<RDS_LAYER_HCL_FLOW_MIN$> OR HCLFlow > RDSLayerRec<RDS_LAYER_HCL_FLOW_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF BakeTime NE '' THEN
	IF BakeTime < RDSLayerRec<RDS_LAYER_BAKE_TIME_MIN$> OR BakeTime > RDSLayerRec<RDS_LAYER_BAKE_TIME_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF EpiH2Flow NE '' THEN
	IF EpiH2Flow < RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MIN$> OR EpiH2Flow > RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF TCSFlow NE '' THEN
	IF TCSFlow < RDSLayerRec<RDS_LAYER_TCS_FLOW_MIN$> OR TCSFlow > RDSLayerRec<RDS_LAYER_TCS_FLOW_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF DCSFlow NE '' THEN
	IF DCSFlow < RDSLayerRec<RDS_LAYER_DCS_FLOW_MIN$> OR DCSFlow > RDSLayerRec<RDS_LAYER_DCS_FLOW_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF Aux1 NE '' THEN
	IF Aux1 < RDSLayerRec<RDS_LAYER_AUX1_MIN$> OR Aux1 > RDSLayerRec<RDS_LAYER_AUX1_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF Aux2 NE '' THEN
	IF Aux2 < RDSLayerRec<RDS_LAYER_AUX2_MIN$> OR Aux2 > RDSLayerRec<RDS_LAYER_AUX2_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF FOffset NE '' THEN
	IF FOffset < RDSLayerRec<RDS_LAYER_F_OFFSET_MIN$> OR FOffset > RDSLayerRec<RDS_LAYER_F_OFFSET_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF SOffset NE '' THEN
	IF SOffset < RDSLayerRec<RDS_LAYER_S_OFFSET_MIN$> OR SOffset > RDSLayerRec<RDS_LAYER_S_OFFSET_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF ROffset NE '' THEN
	IF ROffset < RDSLayerRec<RDS_LAYER_R_OFFSET_MIN$> OR ROffset > RDSLayerRec<RDS_LAYER_R_OFFSET_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF SuscEtch NE '' THEN
	IF SuscEtch <RDSLayerRec<RDS_LAYER_SUSC_ETCH_MIN$> OR SuscEtch > RDSLayerRec<RDS_LAYER_SUSC_ETCH_MAX$> THEN
		Result = 1
		RETURN
	END
END 

IF Etch1 NE '' THEN
	IF Etch1 < RDSLayerRec<RDS_LAYER_ETCH1_MIN$> OR Etch1 > RDSLayerRec<RDS_LAYER_ETCH1_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF Etch2 NE '' THEN
	IF Etch2 < RDSLayerRec<RDS_LAYER_ETCH2_MIN$> OR Etch2 > RDSLayerRec<RDS_LAYER_ETCH2_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF Etch3 NE '' THEN
	IF Etch3 < RDSLayerRec<RDS_LAYER_ETCH3_MIN$> OR Etch3 > RDSLayerRec<RDS_LAYER_ETCH3_MAX$> THEN
		Result = 1
		RETURN
	END
END

IF ULTemp NE '' THEN
	IF ULTemp < RDSLayerRec<RDS_LAYER_UL_TEMP_MIN$> OR ULTemp > RDSLayerRec<RDS_LAYER_UL_TEMP_MAX$> THEN
		Result = 1
		RETURN
	END
END

RETURN


* * * * * * *
Complete:
* * * * * * *

RDSLayerKey	= Parms[1,@RM]
RDSLayerRec = Parms[COL2()+1,@RM]

IF RDSLayerKey = ''	THEN ErrorMsg = 'Null parameter "RDSLayerKey" passed to routine (':Method:').'

IF ErrorMsg NE '' THEN RETURN

IF RDSLayerRec = ''	THEN
	RDSLayerRec = XLATE('RDS_LAYER',RDSLayerKey,'','X')
	IF RDSLayerRec = '' THEN RETURN
END

EpiTime    = RDSLayerRec<RDS_LAYER_EPI_TIME$>
Diluent    = RDSLayerRec<RDS_LAYER_DILUENT_ADJ_PARAM$>
DopantFlow = RDSLayerRec<RDS_LAYER_DOPANT_FLOW$>
HCLFlow    = RDSLayerRec<RDS_LAYER_HCL_FLOW$>
BakeTime   = RDSLayerRec<RDS_LAYER_BAKE_TIME$>
EpiH2Flow  = RDSLayerRec<RDS_LAYER_EPI_H2_FLOW$>
TCSFlow    = RDSLayerRec<RDS_LAYER_TCS_FLOW$>
DCSFLow    = RDSLayerRec<RDS_LAYER_DCS_FLOW$>
Aux1       = RDSLayerRec<RDS_LAYER_AUX1$>
Aux2       = RDSLayerRec<RDS_LAYER_AUX2$>
FOffset    = RDSLayerRec<RDS_LAYER_F_OFFSET$>
SOffset    = RDSLayerRec<RDS_LAYER_S_OFFSET$>
ROffset    = RDSLayerRec<RDS_LAYER_R_OFFSET$>
Etch1      = RDSLayerRec<RDS_LAYER_ETCH1$>
Etch2      = RDSLayerRec<RDS_LAYER_ETCH2$>
Etch3      = RDSLayerRec<RDS_LAYER_ETCH3$>
SuscEtch   = RDSLayerRec<RDS_LAYER_SUSC_ETCH$>
ULTemp     = RDSLayerRec<RDS_LAYER_UL_TEMP$>

Result = 1

IF EpiTime = '' AND (RDSLayerRec<RDS_LAYER_EPI_TIME_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_EPI_TIME_MAX$>  NE '' ) THEN
	Result = 0
	RETURN
END

IF Diluent = '' AND (RDSLayerRec<RDS_LAYER_DILUENT_MIN$> NE '' OR  RDSLayerRec<RDS_LAYER_DILUENT_MAX$> NE '') THEN
	Result = 0
	RETURN
END

IF DopantFlow = '' AND ( RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MIN$> NE '' OR  RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MAX$> NE '') THEN
	Result = 0
	RETURN
END

IF HCLFlow = '' AND ( RDSLayerRec<RDS_LAYER_HCL_FLOW_MIN$> NE '' OR  RDSLayerRec<RDS_LAYER_HCL_FLOW_MAX$> NE '') THEN
	Result = 0
	RETURN
END

IF BakeTime = '' AND ( RDSLayerRec<RDS_LAYER_BAKE_TIME_MIN$> NE '' OR  RDSLayerRec<RDS_LAYER_BAKE_TIME_MAX$> NE '') THEN
	Result = 0
	RETURN
END

IF EpiH2Flow = '' AND ( RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF TCSFlow = '' AND ( RDSLayerRec<RDS_LAYER_TCS_FLOW_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_TCS_FLOW_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF DCSFlow = '' AND ( RDSLayerRec<RDS_LAYER_DCS_FLOW_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_DCS_FLOW_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF Aux1 = '' AND ( RDSLayerRec<RDS_LAYER_AUX1_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_AUX1_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF Aux2 = '' AND ( RDSLayerRec<RDS_LAYER_AUX2_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_AUX2_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF FOffset = '' AND ( RDSLayerRec<RDS_LAYER_F_OFFSET_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_F_OFFSET_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF SOffset = '' AND ( RDSLayerRec<RDS_LAYER_S_OFFSET_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_S_OFFSET_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF ROffset = '' AND ( RDSLayerRec<RDS_LAYER_R_OFFSET_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_R_OFFSET_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF SuscEtch = '' AND ( RDSLayerRec<RDS_LAYER_SUSC_ETCH_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_SUSC_ETCH_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF Etch1 = '' AND ( RDSLayerRec<RDS_LAYER_ETCH1_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_ETCH1_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF Etch2 = '' AND ( RDSLayerRec<RDS_LAYER_ETCH2_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_ETCH2_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF Etch3 = '' AND ( RDSLayerRec<RDS_LAYER_ETCH3_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_ETCH3_MAX$> NE '' ) THEN
	Result = 0
	RETURN
END

IF ULTemp = '' AND (RDSLayerRec<RDS_LAYER_UL_TEMP_MIN$> NE '' OR RDSLayerRec<RDS_LAYER_UL_TEMP_MAX$> NE '') then
    Result = 0
    RETURN
end

RETURN


* * * * * * *
UpdateLimits:
* * * * * * *

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

IF RDSNo = ''		THEN ErrorMsg = 'Null parameter "RDSNo" passed to routine (':Method:').'
IF LayerSet = ''	THEN ErrorMsg = 'Null parameter "LayerSet" passed to routine (':Method:').'

IF ErrorMsg NE '' THEN RETURN


RLKey = RDSNo:'*':LayerSet

Set_Status(0)
RLParms = 'RDS_LAYER':@RM:RLKey
RDSLayerRec = obj_Tables('ReadOnlyRec',RLParms)

IF Get_Status(errCode) THEN
	ErrorMsg = 'Unable to read RDS_LAYER record ':QUOTE(RLKey):' for Limits Update.'
	RETURN
END

IF RDSLayerRec<RDS_LAYER_RECIPE_NO$> = '' AND RecipeNo NE '' THEN
	RDSLayerRec<RDS_LAYER_RECIPE_NO$> = RecipeNo						;* Added 8/24/2012 JCH
END
	

RecipeNo	= RDSLayerRec<RDS_LAYER_RECIPE_NO$>
WOStepKey	= XLATE('RDS',RDSNo,RDS_WO_STEP_KEY$,'X')
PSNId		= XLATE('WO_STEP',WOStepKey,1,'X')

IF INDEX(LayerSet,'L',1) THEN
	LayerLimits = obj_Recipe('GetLimits',RecipeNo:@RM:PSNId:@RM:LayerSet)

	RDSLayerRec<RDS_LAYER_RECIPE_NO$>			= RecipeNo
	RDSLayerRec<RDS_LAYER_DOPANT$>				= LayerLimits<RP_DOPANT$>

	RDSLayerRec<RDS_LAYER_EPI_DILUENT$>			= LayerLimits<RP_EPI_DILUENT$>
	
	RDSLayerRec<RDS_LAYER_EPI_TIME_MIN$>		= LayerLimits<RP_DEPOSIT_TIME_MIN$>
	RDSLayerRec<RDS_LAYER_EPI_TIME_MAX$>		= LayerLimits<RP_DEPOSIT_TIME_MAX$>
	
	RDSLayerRec<RDS_LAYER_DILUENT_MIN$>			= LayerLimits<RP_DILUENT_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_DILUENT_MAX$>			= LayerLimits<RP_DILUENT_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MIN$>		= LayerLimits<RP_DOPANT_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_DOPANT_FLOW_MAX$>		= LayerLimits<RP_DOPANT_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_HCL_FLOW_MIN$>		= LayerLimits<RP_HCL_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_HCL_FLOW_MAX$>		= LayerLimits<RP_HCL_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_BAKE_TIME_MIN$>		= LayerLimits<RP_BAKE_TIME_MIN$>
	RDSLayerRec<RDS_LAYER_BAKE_TIME_MAX$>		= LayerLimits<RP_BAKE_TIME_MAX$>
	
	RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MIN$>		= LayerLimits<RP_H2_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_EPI_H2_FLOW_MAX$>		= LayerLimits<RP_H2_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_TCS_FLOW_MIN$>		= LayerLimits<RP_TCS_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_TCS_FLOW_MAX$>		= LayerLimits<RP_TCS_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_DCS_FLOW_MIN$>		= LayerLimits<RP_DCS_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_DCS_FLOW_MAX$>		= LayerLimits<RP_DCS_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_AUX1_MIN$>			= LayerLimits<RP_AUX1_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_AUX1_MAX$>			= LayerLimits<RP_AUX1_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_AUX2_MIN$>			= LayerLimits<RP_AUX2_FLOW_MIN$>
	RDSLayerRec<RDS_LAYER_AUX2_MAX$>			= LayerLimits<RP_AUX2_FLOW_MAX$>
	
	RDSLayerRec<RDS_LAYER_F_OFFSET_MIN$>		= LayerLimits<RP_FOFFSET_MIN$>
	RDSLayerRec<RDS_LAYER_F_OFFSET_MAX$>		= LayerLimits<RP_FOFFSET_MAX$>
	
	RDSLayerRec<RDS_LAYER_S_OFFSET_MIN$>		= LayerLimits<RP_SOFFSET_MIN$>
	RDSLayerRec<RDS_LAYER_S_OFFSET_MAX$>		= LayerLimits<RP_SOFFSET_MAX$>
	
	RDSLayerRec<RDS_LAYER_R_OFFSET_MIN$>		= LayerLimits<RP_ROFFSET_MIN$>
	RDSLayerRec<RDS_LAYER_R_OFFSET_MAX$>		= LayerLimits<RP_ROFFSET_MAX$>
	
	RDSLayerRec<RDS_LAYER_SUSC_ETCH_MIN$>		= LayerLimits<RP_SUSC_ETCH_MIN$>
	RDSLayerRec<RDS_LAYER_SUSC_ETCH_MAX$>		= LayerLimits<RP_SUSC_ETCH_MAX$>
	
	RDSLayerRec<RDS_LAYER_ETCH1_MIN$>			= LayerLimits<RP_ETCH1_MIN$>
	RDSLayerRec<RDS_LAYER_ETCH1_MAX$>			= LayerLimits<RP_ETCH1_MAX$>
	
	RDSLayerRec<RDS_LAYER_ETCH2_MIN$>			= LayerLimits<RP_ETCH2_MIN$>
	RDSLayerRec<RDS_LAYER_ETCH2_MAX$>			= LayerLimits<RP_ETCH2_MAX$>
	
	RDSLayerRec<RDS_LAYER_ETCH3_MIN$> = LayerLimits<RP_ETCH3_MIN$>
	RDSLayerRec<RDS_LAYER_ETCH3_MAX$> = LayerLimits<RP_ETCH3_MAX$>
	
	RDSLayerRec<RDS_LAYER_UL_TEMP_MIN$> = LayerLimits<RP_UL_TEMP_MIN$>
	RDSLayerRec<RDS_LAYER_UL_TEMP_MAX$> = LayerLimits<RP_UL_TEMP_MAX$>
	
END

RLParms = FieldStore(RLParms, @RM, 4, 1, RDSLayerRec)
obj_Tables('WriteOnlyRec',RLParms)		


RETURN






















