COMPILE SUBROUTINE Print_Control_Plan_JCH( PSNo, WONo )


DECLARE SUBROUTINE ErrMsg
DECLARE FUNCTION Set_Printer, Get_printer, Msg,obj_Install,Printer_Select, obj_Prod_Spec, obj_Recipe, obj_Popup
DECLARE FUNCTION obj_Met_Prop, obj_PRS_Layer, obj_PRS_Prop

$INSERT OIPRINT_EQUATES
$INSERT PROD_SPEC_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT WO_LOG_EQUATES
$INSERT ORDER_DET_EQU
$INSERT COMPANY_EQU
$INSERT RECIPE_EQU
$INSERT RDS_LAYER_EQUATES
$INSERT PRS_LAYER_EQUATES
$INSERT PRS_PROP_EQUATES
$INSERT RDS_TEST_EQUATES
$INSERT PRS_LAYER_EQU
$INSERT PRS_STAGE_EQUATES
$INSERT RECIPE_PARMS_EQU
$INSERT APPCOLORS
$INSERT EPI_PART_EQUATES
$INSERT CUST_EPI_PART_EQUATES
$INSERT TOOL_CLASS_EQUATES



EQU PI$LEFT		TO 1
EQU PI$TOP		TO 2
EQU PI$RIGHT	TO 3
EQU PI$BOTTOM	TO 4
EQU PI$WIDTH	TO 5
EQU PI$HEIGHT	TO 6
EQU PI$SIZE		TO 7


EQU FONT_NAME$		TO 1
EQU FONT_SIZE$		TO 2
EQU FONT_JUST$		TO 3
EQU FONT_BOLD$		TO 4
EQU FONT_ITALIC$	TO 5
EQU FONT_UNDERLINE$	TO 6

EQU STEP_STEP$			TO 1
EQU STEP_PSN$			TO 2
EQU STEP_PROCESS_NAME$	TO 3
EQU STEP_TOOL_TYPE$		TO 4
EQU STEP_PRODUCT$		TO 5
EQU STEP_EVAL_MEAS$		TO 6
EQU STEP_RECIPE$		TO 7
EQU STEP_SPEC_TOL$		TO 8

EQU STEP_SIZE$			TO 9
EQU STEP_FREQ$			TO 10
EQU STEP_CTRL_METHOD$	TO 11
EQU STEP_REACT_PLAN$	TO 12

IF NOT(ASSIGNED(PSNo)) THEN RETURN
IF NOT(ASSIGNED(WONo)) THEN WONo = ''



* * *   PRINT SETUP   * * *


FileName 	= 'Print Control Plan'
Title		= 'Print Control Plan'

PageInfo	= ''				; * Default is .5 inch margins and 8.5 x 11 paper
PageInfo<PI$LEFT>	= 0.5
PageInfo<PI$TOP>	= 1.5
PageInfo<PI$RIGHT>	= 0.5
PageInfo<PI$BOTTOM>	= 0.5
PageInfo<PI$SIZE>	= LETTER

PageSetup	= 1					;* 1 = Landscape mode

PrintSetup	= ''
PrintSetup<1,1>	= '2'	;* Preview Normal
PrintSetup<1,2> = '5'	;* Show Print and PDF, hide Print Setup
PrintSetup<1,3>	= '0'	;* Show the printing window
PDFParms = 'Printing PDF Document':@FM: '' :@FM:'':@FM: ''
		
stat = Set_Printer( 'INIT', PDFParms, 'Run Data Sheet',PageInfo,PageSetup,PrintSetup)

Margins			= Get_Printer('MARGIN')
LMargin = Margins<1>
TMargin	= Margins<2>
RMargin = Margins<3>
BMargin	= Margins<4>

PageSize	= Get_Printer('PAGESIZE')
PageWidth	= PageSize<1>
PageHeight	= PageSize<2>

MaxPrintWidth = PageWidth - LMargin - RMargin
MaxPrintHeight = PageHeight - TMargin - BMargin

font = 'Arial'		;* Font basics
font<2> = 10
font<4> = 0

stat = Set_Printer('FONTHEADFOOT', font)

stat = Set_Printer('LINESTYLE', PS_SOLID:@FM:2)
stat = Set_Printer('LINE', -0.1:@FM:-1.2:@FM:10.0:@FM:-1.2, 1)
stat = Set_Printer('LINE', -0.1:@FM:-0.1:@FM:10.0:@FM:-0.1, 1)
 
location = -0.15:@FM:-1.150:@FM:1.57:@FM:1
stat = Set_Printer('BMP',obj_Install('Get_Prop','ColorBMP'),location, 0,1)

RSideGraphicX = (1.57 - .15)
RSideTextX = (MaxPrintWidth - 1.75)

HeaderMidX = ((RSideTextX - RSideGraphicX)/2) + RSideGraphicX

font<2> = 12
font<4> = 1
stat = Set_Printer('TEXTXY',obj_Install('Get_Prop','Company'),RSideTextX:@FM:-1.15,font,1)

font<2> = 10	;* 12 point font
font<4> = 0		;* Bold off
font<5> = 0		;* Italics Off

stat = Set_Printer('TEXTXY',obj_Install('Get_Prop','Address'),RSideTextX:@FM:-0.925,font,1)
stat = Set_Printer('TEXTXY',obj_Install('Get_Prop','CSZC'),RSideTextX:@FM:-0.775,font,1)
stat = Set_Printer('TEXTXY','Phone:  ':obj_Install('Get_Prop','Phone'),RSideTextX:@FM:-0.625,font,1)
stat = Set_Printer('TEXTXY','FAX:    ':obj_Install('Get_Prop','FAX'),RSideTextX:@FM:-0.475,font,1)
*stat = Set_Printer('TEXTXY','Web:    ':obj_Install('Get_Prop','WebSite'),RSideTextX:@FM:-0.325,font,1)

font	= 'Arial'
font<2>	= '18'		;* Big type
font<4>	= 1			;* Bold on
font<5> = 1			;* Italics

stat = Set_Printer('FONT',font)

stat		= Set_Printer("CALCTEXT", 'Control Plan')
titleSize	= Get_Printer("CALCTEXT")
titleWidth 	= titleSize<1>
titleHeight = titleSize<2>

titleStartX = HeaderMidX - (titleWidth/2)

stat = Set_Printer('TEXTXY','Control Plan',titleStartX:@FM:-1.0,font,1)

font<2> = '16'
font<4> = 0

stat = Set_Printer('FONT',font)

IF WONo NE '' THEN	
	WORec		= XLATE('WO_LOG',WONo,'','X')
	
	ProdOrdNo	= WORec<WO_LOG_PROD_ORD_NO$>
	EpiPartNo	= WORec<WO_LOG_EPI_PART_NO$>
	ProdVerNo	= WORec<WO_LOG_PROD_VER_NO$>
	SubPartNo 	= WORec<WO_LOG_ORD_SUB_PART_NO$>
	
	CustNo		= WORec<WO_LOG_CUST_NO$>
	CustName 	= XLATE('COMPANY',CustNo,COMPANY_CO_NAME$,'X')
	
	CustEpiPartRec = XLATE('CUST_EPI_PART',CustNo:'*':EpiPartNo,'','X')
	
	CustPartNos		= CustEpiPartRec<CUST_EPI_PART_CUST_PART_NO$>
	CustPartDescs	= CustEpiPartRec<CUST_EPI_PART_CUST_PART_DESC$>
	
	EpiPartRec = XLATE('EPI_PART',EpiPartNo,'','X')
	
	Orientation = EpiPartRec<EPI_PART_SUB_ORIENTATION$>
	ProdType	= EpiPartRec<EPI_PART_SUB_DOPE_TYPE$>
END ELSE
	CustPartNos = ''
	CustPartDescs = ''
	CustName	= ''
	ProdOrdNo	= ''
	EpiPartNo	= ''
	EpiPartRec	= ''
	ProdVerNo	= ''
	SubPartNo 	= ''
	Orientation = ''
	ProdType	= ''
END

stat		= Set_Printer("CALCTEXT", 'PSN: ':PSNo:' - ':CustName)
psnSize		= Get_Printer("CALCTEXT")
psnWidth 	= psnSize<1>
psnHeight 	= psnSize<2>

psnStartX = HeaderMidX - (psnWidth/2)

stat		= Set_Printer("CALCTEXT", 'Work Order No: ':WONo)
woSize		= Get_Printer("CALCTEXT")
woWidth 	= woSize<1>
woHeight 	= woSize<2>

woStartX = HeaderMidX - (woWidth/2)

IF WONo NE '' THEN
	stat = Set_Printer('TEXTXY','PSN: ':PSNo:' - ':CustName,psnStartX:@FM:-0.68,font,1)
	stat = Set_Printer('TEXTXY','Work Order No: ':WONo,woStartX:@FM:-0.40,font,1)
END ELSE
	stat = Set_Printer('TEXTXY','PSN: ':PSNo:' - ':CustName,psnStartX:@FM:-0.60,font,1)
END

font<2> = 12	;* Drop the font size
font<5> = 0		;* Italics off

stat = Set_Printer('FOOTER',"Page 'P'":@VM:@VM:"'T' 'D'")

* Extract Prod Spec data

WORec = XLATE('WO_LOG',WONo,'','X')
PSNRec = XLATE('PROD_SPEC',PSNo,'','X')

SpecType = XLATE('PROD_SPEC',PSNo,'SPEC_TYPE','X')				;* Aded 8/22/2012 HC

SpecSubInfo = PSNRec<prod_spec_spec_substrate$>

ReactorType = OCONV(PSNRec<PROD_SPEC_REACTOR_TYPE$> ,'[REACT_TYPE_CONV,OPSREF]' )
SpecialInst = PSNRec<PROD_SPEC_SPEC_INST$>				;* 3/25/2013 JCH
ProveinInst = PSNRec<PROD_SPEC_PROVE_IN_INST$>			;* 3/25/2013 JCH

EntryDt		= OCONV(PSNRec<PROD_SPEC_ENTRY_DATE$>,'D4/')
RevDt		= OCONV(PSNRec<PROD_SPEC_MOD_DATE$>,'D4/')

KeyContact	= "Onsite Quality Representative (480) 668-4000"
CoreTeam	= 'Executive Director, Process Engineering Manager, Maintenance Engineering Manager, Manufacturing Manager (480) 668-4000'


BEGIN CASE
	CASE SpecType = 'U'
		Sig		= PSNRec<PROD_SPEC_MODE_SIG$,1>								;* Added 8/22/2012 JCH
		SigDt	= PSNRec<PROD_SPEC_MODE_SIG_DTM$,1>[1,'.']					;* Added 8/22/2012 JCH
		
	CASE SpecType = 'Q'
		Sig		= PSNRec<PROD_SPEC_MODE_SIG$,2>								;* Added 8/22/2012 JCH
		SigDt	= PSNRec<PROD_SPEC_MODE_SIG_DTM$,2>[1,'.']					;* Added 8/22/2012 JCH
		
	CASE SpecType = 'E'
		Sig		= PSNRec<PROD_SPEC_MODE_SIG$,3>								;* Added 8/22/2012 JCH
		SigDt	= PSNRec<PROD_SPEC_MODE_SIG_DTM$,3>[1,'.']					;* Added 8/22/2012 JCH
		
	CASE SpecType = 'P'
		Sig		= PSNRec<PROD_SPEC_MODE_SIG$,4>								;* Added 8/22/2012 JCH
		SigDt	= PSNRec<PROD_SPEC_MODE_SIG_DTM$,4>[1,'.']					;* Added 8/22/2012 JCH
		
END CASE

Font = 'Arial'
Font<FONT_JUST$>		= 'L'
Font<FONT_SIZE$>		= 8
Font<FONT_UNDERLINE$>	= 0
Font<FONT_BOLD$>		= 0
Void = Set_Printer( 'FONT', Font )

* First line of Specification

colHeader 	   = 'Description'				; colFormat      = '^1440'
colHeader<1,2> = 'Type'						; colFormat<1,2> = '^1440'
colHeader<1,3> = 'Signed'					; colFormat<1,3> = '^1080'
colHeader<1,4> = 'Key Contact'				; colFormat<1,4> = '^2520'
colHeader<1,5> = 'Core Team'				; colFormat<1,5> = '^5760'
colHeader<1,6> = 'PSN':CRLF$:'Original Dt'	; colFormat<1,6> = '^1080'
colHeader<1,7> = 'PSN':CRLF$:'Last Rev'		; colFormat<1,7> = '^1080'

colData      = PSNRec<PROD_SPEC_LAYER_TYPE$>
colData<1,2> = OCONV(SpecType,'[SPEC_TYPE_CONV]')
colData<1,3> = OCONV(SigDt,'D4/')
colData<1,4> = KeyContact
colData<1,5> = CoreTeam
colData<1,6> = EntryDt
colData<1,7> = RevDt

stat = Set_Printer('ADDTABLE', colFormat,colHeader,'',LTGREY$,'',0,TB_ALL)
stat = Set_Printer('ADDTABLE',colFormat,'',colData,LTGREY$,'',1,TB_ALL)

stat = Set_Printer('TEXT')

* Second line of Specification

PSNLayerProps = obj_Prod_Spec('GetLayerProp',PSNo)			;* this goes away when done developing

PRSLayerKeys = PSNRec<PROD_SPEC_PRS_LAYER_KEY$>

lCnt = COUNT(PRSLayerKeys,@VM) + (PRSLayerKeys NE '')

LSIDs = ''
Dopants = ''

colData = ''
lsData = ''			;* Layer Set - Property data
recData = ''		;* Layer Set - Recipe data
stepData = ''		;* Layer Data for production Step section of report

lsHeader = 'LS':CRLF$:'Id':@VM				; lsFormat = '^540':@VM
lsHeader<1,2> = 'Dopant':@VM				; lsFormat<1,2> = '^1380':@VM
lsHeader<1,3> = 'Measure':@VM				; lsFormat<1,3> = '<1560':@VM
lsHeader<1,4> = 'Minimum':@VM				; lsFormat<1,4> = '^1440':@VM
lsHeader<1,5> = 'Target':@VM				; lsFormat<1,5> = '^1440':@VM
lsHeader<1,6> = 'Maximum':@VM				; lsFormat<1,6> = '^1440':@VM
lsHeader<1,7> = 'Tool':@VM					; lsFormat<1,7> = '<1020':@VM
lsHeader<1,8> = 'Monitor Type':@VM			; lsFormat<1,8> = '<1260':@VM
lsHeader<1,9> = 'Recipe':@VM				; lsFormat<1,9> = '<1260':@VM
lsHeader<1,10> = 'Pattern':@VM				; lsFormat<1,10> = '^1260':@VM
lsHeader<1,11> = 'Frq':@VM					; lsFormat<1,11> = '^540':@VM
lsHeader<1,12> = 'ProveIn Type'				; lsFormat<1,12> = '<1260'

recHeader = 'LS':CRLF$:'Id':@VM				; recFormat = '^540':@VM
recHeader<1,2> = 'Deposit':@VM				; recFormat<1,2> = '^1155':@VM
recHeader<1,3> = 'Diluent':@VM				; recFormat<1,3> = '^1155':@VM
recHeader<1,4> = 'Dopant Flow':@VM			; recFormat<1,4> = '^1155':@VM
recHeader<1,5> = 'Bake Time':@VM			; recFormat<1,5> = '^1155':@VM
recHeader<1,6> = 'H2 Flow':@VM				; recFormat<1,6> = '^1155':@VM
recHeader<1,7> = 'Silane Flow':@VM			; recFormat<1,7> = '^1155':@VM
recHeader<1,8> = 'Aux1 Flow':@VM			; recFormat<1,8> = '^1155':@VM
recHeader<1,9> = 'Aux2 Flow':@VM			; recFormat<1,9> = '^1155':@VM
recHeader<1,10> = 'F Offset':@VM			; recFormat<1,10> = '^1155':@VM
recHeader<1,11> = 'S Offset':@VM			; recFormat<1,11> = '^1155':@VM
recHeader<1,12> = 'R Offset':@VM			; recFormat<1,12> = '^1155':@VM
recHeader<1,13> = 'Susc Etch'				; recFormat<1,13> = '^1155'


FOR I = 1 TO lCnt

	PRSLayerKey = PRSLayerKeys<1,I>
	PRSLayerRec = XLATE('PRS_LAYER',PRSLayerKey,'','X')			;* 1st layer record
	
	LayerNo		= FIELD(PRSLayerKey,'*',2)
	LSID		= PRSLayerRec<PRS_LAYER_LS_ID$>
	RecipeNo	= PRSLayerRec<PRS_LAYER_RECIPE_ID$>
		
	PropKeys	= obj_PRS_Layer('SortPropKeys',PRSLayerKey:@RM:PRSLayerRec)

	RecipeRec = XLATE('RECIPE',RecipeNo,'','X')					;* 1st layer receipe 

	Dopant 			= RecipeRec<RECIPE_EPI_DOPANT$>
	
	IF I = 1 THEN
	
		RecipeEntryDt	= OCONV(RecipeRec<RECIPE_ENTRY_DATE$>,'D4/')
		RecipeLastModDt	= OCONV(RecipeRec<RECIPE_MOD_DATE$,1>,'D4/')
		RecipeName		= RecipeRec<RECIPE_RECIPE_NAME$>
		EpiGas			= RecipeRec<RECIPE_EPI_GASES$>

		BEGIN CASE
			CASE EpiGas _EQC 'SiH4'		; EpiGasName = 'Silane'
			CASE EpiGas _EQC 'SiH2CL2'	; EpiGasName = 'DiChloroSilane (DCS)'
			CASE EpiGas _EQC 'SiHCL3'	; EpiGasName = 'TriChloroSilane (TCS)'
			CASE 1						; EpiGasName = ''
		END CASE

		SWAP @VM WITH CRLF$ IN CustPartNos
		SWAP @VM WITH CRLF$ IN CustPartDescs

		colData<1,1> = 'Silcon Epitaxy'
		colData<1,2> = PSNo
		colData<1,3> = CustPartNos
		colData<1,4> = CustPartDescs
		colData<1,5> = RecipeNo
		colData<1,6> = Recipename
		colData<1,7> = RecipeEntryDt
		colData<1,8> = RecipeLastModDt
		colData<1,9> = EpiGas
		colData<1,10> = SubPartNo
		colData<1,11> = Orientation
		colData<1,12> = ProdType

		colHeader      = 'Product'				; colFormat      = '<2160'
		colHeader<1,2> = 'PSN'					; colFormat<1,2> = '^720'
		colHeader<1,3> = 'Cust Part No'			; colFormat<1,3> = '^1440'
		colHeader<1,4> = 'Part Desc'			; colFormat<1,4> = '<2160'
		colHeader<1,5> = 'Rec No'				; colFormat<1,5> = '^720'
		colHeader<1,6> = 'Recipe'				; colFormat<1,6> = '^1080'
		colHeader<1,7> = 'Org Dt'				; colFormat<1,7> = '^1080'
		colHeader<1,8> = 'Last Rev'				; colFormat<1,8> = '^1080'
		colHeader<1,9> = 'Epi Gas'				; colFormat<1,9> = '^1080'
		colHeader<1,10> = 'Prod Sub No'			; colFormat<1,10> = '^1440'
		colHeader<1,11> = 'Orient'				; colFormat<1,11> = '^720'
		colHeader<1,12> = 'Type'				; colFormat<1,12> = '^720'


		stat = Set_Printer('ADDTABLE', colFormat,colHeader,'',LTGREY$,'',0,TB_ALL)
		stat = Set_Printer('ADDTABLE',colFormat,'',colData,LTGREY$,'',1,TB_ALL)
		
		colData = ''
		
		stat = Set_Printer('TEXT')
	END	;* End of check for 1st layaer
	
	IF I = 1 THEN lsDopant = Dopant ELSE lsDopant = ''
	
	propCnt = COUNT(PropKeys,@VM) + (PropKeys NE '')
	
	FOR P = 1 TO propCnt
		
		PropKey = PropKeys<1,P>
		PropCd = FIELD(PropKey,'*',3)
		
		PropRec = XLATE('PRS_PROP',PropKey,'','X')
		
		MinTarMax = obj_PRS_Prop('GetMinTarMax',PropKey:@RM:PropRec)
		
		Units		= obj_Popup('CodeDesc','MET_PROPERTY':@RM:PropCd:@RM:5)
		DescUnits	= obj_Popup('CodeDesc','MET_PROPERTY':@RM:PropCd:@RM:6)
		IF P = 1 THEN 
			lsData<I,1> = LSID
			lsData<I,2> = lsDopant
			lsData<I,3> = OCONV(PropCd,'[CONV_CODE_DESC,MET_PROPERTY]')
			lsData<I,4> = MinTarMax<1>:' ':Units
			lsData<I,5> = MinTarMax<2>:' ':Units
			lsData<I,6> = MinTarMax<3>:' ':Units
			lsData<I,7> = PropRec<PRS_PROP_TOOL$>
			lsData<I,8> = PropRec<PRS_PROP_MET_WFR_TYPE$>
			lsData<I,9> = PropRec<PRS_PROP_MET_RECIPE$>
			lsData<I,10> = PropRec<PRS_PROP_MET_RECIPE_PATTERN$>
			lsData<I,11> = PropRec<PRS_PROP_MET_INTERVAL$>
			lsData<I,12> = PropRec<PRS_PROP_PROVEIN_WFR_TYPE$>

		END ELSE
			lsData<I,1> = lsData<I,1>:CRLF$
			lsData<I,2> = lsData<I,2>:CRLF$
			lsData<I,3> = lsData<I,3>:CRLF$:OCONV(PropCd,'[CONV_CODE_DESC,MET_PROPERTY]')
			lsData<I,4> = lsData<I,4>:CRLF$:MinTarMax<1>:' ':Units
			lsData<I,5> = lsData<I,5>:CRLF$:MinTarMax<2>:' ':Units
			lsData<I,6> = lsData<I,6>:CRLF$:MinTarMax<3>:' ':Units
			lsData<I,7> = lsData<I,7>:CRLF$:PropRec<PRS_PROP_TOOL$>
			lsData<I,8> = lsData<I,8>:CRLF$:PropRec<PRS_PROP_MET_WFR_TYPE$>
			lsData<I,9> = lsData<I,9>:CRLF$:PropRec<PRS_PROP_MET_RECIPE$>
			lsData<I,10> = lsData<I,10>:CRLF$:PropRec<PRS_PROP_MET_RECIPE_PATTERN$>
			lsData<I,11> = lsData<I,11>:CRLF$:PropRec<PRS_PROP_MET_INTERVAL$>
			lsData<I,12> = lsData<I,12>:CRLF$:PropRec<PRS_PROP_PROVEIN_WFR_TYPE$>
			
		END
		
		sdPointer = I + ( P - 1 )
		StepData<sdPointer,1> = ''		;* Step number filled in later
		StepData<sdPointer,2> = PSNo
		StepData<sdPointer,3> = 'Epitaxy Layer ':LayerNo
		StepData<sdPointer,4> = ReactorType
		StepData<sdPointer,5> = CHAR(185):OCONV(PropCd,'[CONV_CODE_DESC,MET_PROPERTY]')
		StepData<sdPointer,6> = PropRec<PRS_PROP_TOOL$>
		StepData<sdPointer,7> = 'Epi Growth'
		StepData<sdPointer,8> = MinTarMax<1>:'- ':MinTarMax<3>:' ':DescUnits
		StepData<sdPointer,9> = PropRec<PRS_PROP_MET_WFR_TYPE$>
		StepData<sdPointer,10> = PropRec<PRS_PROP_MET_INTERVAL$>
		StepData<sdPointer,11> = 'SPC'
		StepData<sdPointer,12> = 'OCAP'
		
		
		
	NEXT P
	
	FOR C = 1 TO 12
		lsData<I,C> = lsData<I,C>:CRLF$
	NEXT C

	RecLimits = obj_Recipe('GetLimits',RecipeNo:@RM:PSNo:@RM:LSID)
	
	IF RecLimits<RP_DEPOSIT_TIME_MIN$> NE '' THEN
	
		RecDepTime	= OCONV(RecLimits<RP_DEPOSIT_TIME_MIN$>:@SVM:RecLimits<RP_DEPOSIT_TIME_MAX$>,'MD1')
		
		
		IF RecLimits<RP_DILUENT_FLOW_MIN$> = '' THEN
			DiluentFlowMin	= RecLimits<RP_EPI_DILUENT$>
		END ELSE
			DiluentFlowMin = RecLimits<RP_DILUENT_FLOW_MIN$>
		END
		
		IF RecLimits<RP_DILUENT_FLOW_MAX$> = '' THEN
			DiluentFlowMax	= RecLimits<RP_EPI_DILUENT$>
		END ELSE
			DiluentFlowMax = RecLimits<RP_DILUENT_FLOW_MAX$>
		END
		
		
		RecDiluent		= OCONV(DiluentFlowMin:@SVM:DiluentFlowMax,'MD2')
		
		RecDopantFlow	= OCONV(RecLimits<RP_DOPANT_FLOW_MIN$>:@SVM:RecLimits<RP_DOPANT_FLOW_MAX$>,'MD2')
		RecBakeTime		= OCONV(RecLimits<RP_BAKE_TIME_MIN$>:@SVM:RecLimits<RP_BAKE_TIME_MAX$>,'[SECONDS_CONV]')
		RecH2Flow		= OCONV(RecLimits<RP_H2_FLOW_MIN$>:@SVM:RecLimits<RP_H2_FLOW_MAX$>,'MD0')
		RecTCSFlow		= OCONV(RecLimits<RP_TCS_FLOW_MIN$>:@SVM:RecLimits<RP_TCS_FLOW_MAX$>,'MD1')
		RecDCSFlow		= OCONV(RecLimits<RP_DCS_FLOW_MIN$>:@SVM:RecLimits<RP_DCS_FLOW_MAX$>,'MD0')
		RecAux1Flow		= OCONV(RecLimits<RP_AUX1_FLOW_MIN$>:@SVM:RecLimits<RP_AUX1_FLOW_MAX$>,'MD2')
		RecAux2Flow		= OCONV(RecLimits<RP_AUX2_FLOW_MIN$>:@SVM:RecLimits<RP_AUX2_FLOW_MAX$>,'MD2')
		RecFOffset		= OCONV(RecLimits<RP_FOFFSET_MIN$>:@SVM:RecLimits<RP_FOFFSET_MAX$>,'MD0')
		RecSOffset		= OCONV(RecLimits<RP_SOFFSET_MIN$>:@SVM:RecLimits<RP_SOFFSET_MAX$>,'MD0')
		RecROffset		= OCONV(RecLimits<RP_ROFFSET_MIN$>:@SVM:RecLimits<RP_ROFFSET_MAX$>,'MD0')
		RecSuscEtch		= OCONV(RecLimits<RP_SUSC_ETCH_MIN$>:@SVM:RecLimits<RP_SUSC_ETCH_MAX$>,'MD1')
		
		IF RecDiluent = @SVM	THEN RecDiluent = ''
		IF RecDopantFlow = @SVM THEN RecDopantFlow = ''
		IF RecBakeTime  = @SVM	THEN RecBakeTime = ''
		IF RecH2Flow = @SVM		THEN RecH2Flow = ''
		IF RecTCSFlow = @SVM	THEN RecTCSFlow = ''
		IF RecDCSFlow = @SVM	THEN RecDCSFlow = ''
		IF RecAux1Flow = @SVM	THEN RecAux1Flow = ''
		IF RecAux2Flow = @SVM	THEN RecAux2Flow= ''
		IF RecFOffset = @SVM	THEN RecFOffset = ''
		IF RecSOffset = @SVM	THEN RecSOffset = ''
		IF RecROffset = @SVM	THEN RecROffset = ''
		IF RecSuscEtch = @SVM	THEN RecSuscEtch = ''

		recData<I,1> 	= LSID
		recData<I,2>	= RecDepTime		
		recData<I,3>	= RecDiluent
		recData<I,4>	= RecDopantFlow
		recData<I,5>	= RecBakeTime
		recData<I,6>	= RecH2Flow
		
		IF I = 1 THEN
			IF RecTCSFlow = '' THEN
				recHeader<1,7>	= 'DCS Flow'
				recData<I,7>	= RecDCSFlow
			END ELSE
				recHeader<1,7>	= 'TCS Flow'
				recData<I,7>	= RecTCSFlow
			END
		END
		
		recData<I,8>	= RecAux1Flow
		recData<I,9>	= RecAux2Flow
		recData<I,10>	= RecFOffset
		recData<I,11>	= RecSOffset
		recData<I,12>	= RecROffset
		recData<I,13>	= RecSuscEtch
		
		FOR C = 1 TO 13
			recData<I,C> = recData<I,C>:CRLF$
		NEXT C
		
		SWAP @SVM WITH ' ~ ' IN RecData
	END	;* End of check for a deposit time
	
	
	
NEXT I



font<FONT_NAME$> = 'MS LineDraw'
font<FONT_SIZE$> = 8		;* 10 point
font<FONT_BOLD$> = 0		;* Bold
stat = Set_Printer('FONT',font)


stat = Set_Printer('ADDTABLE', lsFormat,lsHeader,'',LTGREY$,'',0,TB_ALL)
stat = Set_Printer('ADDTABLE',lsFormat,'',lsData,LTGREY$,'',1,TB_ALL)


stat = Set_Printer('TEXT')

stat = Set_Printer('ADDTABLE', recFormat,recHeader,'',LTGREY$,'',0,TB_ALL)
stat = Set_Printer('ADDTABLE',recFormat,'',recData,LTGREY$,'',1,TB_ALL)


stat = Set_Printer('TEXT')

Sigs = ''

* Process Steps

colHeader = ''	; colFormat = ''

colHeader<1,STEP_STEP$>			= 'Step':@VM				; colFormat<1,STEP_STEP$>			= '^540':@VM
colHeader<1,STEP_PSN$> 			= 'PSN':@VM					; colFormat<1,STEP_PSN$>			= '^540':@VM
colHeader<1,STEP_PROCESS_NAME$> = 'Process Name':@VM		; colFormat<1,STEP_PROCESS_NAME$>	= '<1440':@VM
colHeader<1,STEP_TOOL_TYPE$> 	= 'Tool Group':@VM			; colFormat<1,STEP_TOOL_TYPE$>		= '^1080':@VM
colHeader<1,STEP_PRODUCT$> 		= 'Measurement':@VM			; colFormat<1,STEP_PRODUCT$> 		= '^1440':@VM
colHeader<1,STEP_EVAL_MEAS$> 	= 'Tool Class':@VM			; colFormat<1,STEP_EVAL_MEAS$> 		= '^1440':@VM
colHeader<1,STEP_RECIPE$> 		= 'Recipe':@VM				; colFormat<1,STEP_RECIPE$> 		= '^1800':@VM
colHeader<1,STEP_SPEC_TOL$> 	= 'Spec Tolerance':@VM		; colFormat<1,STEP_SPEC_TOL$> 		= '^2160':@VM
colHeader<1,STEP_SIZE$> 		= 'Size':@VM				; colFormat<1,STEP_SIZE$> 			= '^1080':@VM
colHeader<1,STEP_FREQ$> 		= 'Freq':@VM				; colFormat<1,STEP_FREQ$> 			= '^1080':@VM
colHeader<1,STEP_CTRL_METHOD$> 	= 'Control':CRLF$:'Method'	; colFormat<1,STEP_CTRL_METHOD$>	= '^720':@VM
colHeader<1,STEP_REACT_PLAN$> 	= 'React Plan'				; colFormat<1,STEP_REACT_PLAN$>		= '^1080'

StepNo = 1

* Receiving Step

colData = ''
colData<StepNo,STEP_STEP$>			= StepNo
colData<StepNo,STEP_PROCESS_NAME$>	= 'Receiving'
colData<StepNo,STEP_TOOL_TYPE$>		= 'Paperwork'
colData<StepNo,STEP_PSN$>			= PSNo
colData<StepNo,STEP_PRODUCT$>		= 'Documentation'
colData<StepNo,STEP_RECIPE$>		= 'Manual'
colData<StepNo,STEP_SPEC_TOL$>		= 'Consistent Data'
colData<StepNo,STEP_EVAL_MEAS$>		= 'Visual'
colData<StepNo,STEP_SIZE$>			= 'Shipment'
colData<StepNo,STEP_FREQ$>			= 'Per Cass'
colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
colData<StepNo,STEP_REACT_PLAN$>	= 'Pass/Fail'



Stages = obj_Popup('AllCodes','STAGE')

CONVERT @VM TO @FM IN Stages

CIStages = Stages

StageCnt = COUNT(CIStages,@FM) + (CIStages NE '')

FOR I = 1 TO StageCnt

	Stage		= CIStages<I>
	StageRec	= XLATE('PRS_STAGE',PSNo:'*':Stage,'','X')
	StageDesc	= obj_Popup('CodeDesc','STAGE':@RM:Stage)
	
	IF Stage = 'PRE' THEN
		IF EpiPartRec<EPI_PART_SUB_OXIDE$> = 1 THEN
			StepNo += 1
			colData<StepNo,STEP_STEP$>			= StepNo
			colData<StepNo,STEP_PSN$>			= PSNo
			colData<StepNo,STEP_PROCESS_NAME$>	= 'HF Strip'
			colData<StepNo,STEP_TOOL_TYPE$>		= 'HF'
			colData<StepNo,STEP_PRODUCT$>		= 'SC-1'
			colData<StepNo,STEP_RECIPE$>		= '20min or Dewet'
			colData<StepNo,STEP_SPEC_TOL$>		= '-'
			colData<StepNo,STEP_EVAL_MEAS$>		= 'HF'
			colData<StepNo,STEP_SIZE$>			= '1 Cass'
			colData<StepNo,STEP_FREQ$>			= 'All'
			colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
			colData<StepNo,STEP_REACT_PLAN$>	= 'OCAP'
		END	;* End of Check for SubOxide Flag
		
	END	;* End of check for PRE stage
	
	IF StageRec NE '' THEN
	
		IF StageRec<PRS_STAGE_CLEAN_TOOL$> NE '' THEN
			StepNo += 1
			colData<StepNo,STEP_STEP$>			= StepNo
			colData<StepNo,STEP_PSN$>			= PSNo
			colData<StepNo,STEP_PROCESS_NAME$>	= StageDesc
			
			CleanTools = StageRec<PRS_STAGE_CLEAN_TOOL$>
			
			SWAP @VM WITH ', ' IN CleanTools
			
			colData<StepNo,STEP_TOOL_TYPE$>		= 'Cleans'
			colData<StepNo,STEP_EVAL_MEAS$>		= CleanTools
			colData<StepNo,STEP_PRODUCT$>		= '-'								;*StageRec<PRS_STAGE_CLEAN_TOOL$>
			colData<StepNo,STEP_RECIPE$>		= StageRec<PRS_STAGE_CLEAN_RECIPE$>
			colData<StepNo,STEP_SPEC_TOL$>		= '-'
			
			colData<StepNo,STEP_SIZE$>			= '1 Cass'
			colData<StepNo,STEP_FREQ$>			= ''
			colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
			colData<StepNo,STEP_REACT_PLAN$>	= 'OCAP'
		END	;* End of check for Clean Tool
		
		
		IF StageRec<PRS_STAGE_BRIGHTLIGHT$> = 1 THEN
			StepNo += 1
			colData<StepNo,STEP_STEP$>			= StepNo
			colData<StepNo,STEP_PSN$>			= PSNo
			colData<StepNo,STEP_PROCESS_NAME$>	= StageDesc
			colData<StepNo,STEP_TOOL_TYPE$>		= XLATE('TOOL_CLASS','BRIGHTLIGHT',TOOL_CLASS_TOOL_TYPE$,'X')
			colData<StepNo,STEP_EVAL_MEAS$>		= 'BRIGHTLIGHT'
			colData<StepNo,STEP_PRODUCT$>		= CHAR(185):"LPD's"
			colData<StepNo,STEP_RECIPE$>		= 'Visual'
			colData<StepNo,STEP_SPEC_TOL$>		= '<':StageRec<PRS_STAGE_LPD$>
			
			colData<StepNo,STEP_SIZE$>			= '1'
			colData<StepNo,STEP_FREQ$>			= 'Per Cass'
			colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
			colData<StepNo,STEP_REACT_PLAN$>	= 'OCAP'
		END	;* End of check for Brightlight flag
		
		
		IF StageRec<PRS_STAGE_MICROSCOPE$> = 1 THEN
			StepNo += 1
			colData<StepNo,STEP_STEP$>			= StepNo
			colData<StepNo,STEP_PSN$>			= PSNo
			colData<StepNo,STEP_PROCESS_NAME$>	= StageDesc
			colData<StepNo,STEP_TOOL_TYPE$>		= XLATE('TOOL_CLASS','MICROSCOPE',TOOL_CLASS_TOOL_TYPE$,'X')
			colData<StepNo,STEP_EVAL_MEAS$>		= 'MICROSCOPE'
			colData<StepNo,STEP_PRODUCT$>		= 'Surface Quality'
			colData<StepNo,STEP_RECIPE$>		= 'Visual'
			colData<StepNo,STEP_SPEC_TOL$>		= 'PSN:':PSNo:' - Surface Spec'
			
			colData<StepNo,STEP_SIZE$>			= '1'
			colData<StepNo,STEP_FREQ$>			= 'Per Cass'
			colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
			colData<StepNo,STEP_REACT_PLAN$>	= 'OCAP'
		END	;* End of check for Microscope flag
	
	
		IF StageRec<PRS_STAGE_SURFSCAN_RECIPE$> NE '' THEN
			StepNo += 1
			colData<StepNo,STEP_STEP$>			= StepNo
			colData<StepNo,STEP_PSN$>			= PSNo
			colData<StepNo,STEP_PROCESS_NAME$>	= StageDesc
			colData<StepNo,STEP_TOOL_TYPE$>		= XLATE('TOOL_CLASS','TENCOR',TOOL_CLASS_TOOL_TYPE$,'X')
			colData<StepNo,STEP_EVAL_MEAS$>		= 'TENCOR'
			colData<StepNo,STEP_PRODUCT$>		= CHAR(185):"LPD's"
			colData<StepNo,STEP_RECIPE$>		= StageRec<PRS_STAGE_SURFSCAN_RECIPE$>
			colData<StepNo,STEP_SPEC_TOL$>		= 'See Hard Copy Spec'
			
			colData<StepNo,STEP_SIZE$>			= StageRec<PRS_STAGE_SS_SAMP_QTY$>
			colData<StepNo,STEP_FREQ$>			= 'Per Cass'
			colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
			colData<StepNo,STEP_REACT_PLAN$>	= 'OCAP'
		END	;* End of check for Surfscan Recipe
		
		
		IF StageRec<PRS_STAGE_MET_TEST$> NE '' THEN
			metCnt = COUNT(StageRec<PRS_STAGE_MET_TEST$>,@VM) + (StageRec<PRS_STAGE_MET_TEST$> NE '')
			FOR M = 1 TO metCnt
				MetTest = StageRec<PRS_STAGE_MET_TEST$,M>
				
				*IF StageRec<PRS_STAGE_MET_WFR_QTY$,M> NE '' THEN
				*	Size = StageRec<PRS_STAGE_MET_WFR_QTY$,M>
				*END ELSE
				*	Size = StageRec<PRS_STAGE_MET_SLOT$,M>
				*END
				
				
				IF MetTest NE '' THEN
					StepNo += 1
					colData<StepNo,STEP_STEP$>			= StepNo
					colData<StepNo,STEP_PSN$>			= PSNo
					colData<StepNo,STEP_PROCESS_NAME$>	= obj_Popup('CodeDesc','STAGE':@RM:Stage)
					
					ToolClassType = XLATE('TOOL_CLASS',StageRec<PRS_STAGE_MET_TOOL_CLASS$,M>,TOOL_CLASS_TOOL_TYPE$,'X')
					IF ToolClassType = 'Metrology' THEN
						ToolClassType = 'Met'
					END
					
					colData<StepNo,STEP_TOOL_TYPE$>		= 'QA-':ToolClassType
					colData<StepNo,STEP_EVAL_MEAS$>		= StageRec<PRS_STAGE_MET_TOOL_CLASS$,M>
					colData<StepNo,STEP_PRODUCT$>		= CHAR(185):obj_Met_Prop('GetPropDesc',StageRec<PRS_STAGE_MET_PROP$,M>)
					colData<StepNo,STEP_RECIPE$>		= StageRec<PRS_STAGE_MET_RECIPE$,M>
					colData<StepNo,STEP_SPEC_TOL$>		= StageRec<PRS_STAGE_MET_MIN$,M>:' - ':StageRec<PRS_STAGE_MET_MAX$,M>:' ':obj_Met_Prop('GetUnitsDesc',StageRec<PRS_STAGE_MET_PROP$,M>)
					
					colData<StepNo,STEP_SIZE$>			= StageRec<PRS_STAGE_MET_WFR_QTY$,M>
					colData<StepNo,STEP_FREQ$>			= StageRec<PRS_STAGE_MET_INTERVAL$,M>
					colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
					colData<StepNo,STEP_REACT_PLAN$>	= 'OCAP'
				END
			NEXT M
		END
		
	
	END	;* End of check for null stage record
	
	
	* Insert LayerSet step data after the LOAD stage
	
	IF Stage = 'LOAD' THEN

		FOR SDLine = 1 TO sdPointer
			StepNo += 1
			colData<StepNo,STEP_STEP$>		= StepNo
			
			FOR Col = STEP_PSN$ TO STEP_REACT_PLAN$
				colData<StepNo,Col> = StepData<SDLine,Col>
			NEXT Col
		
		NEXT SDLine
	
	END
	
	
NEXT I
	



StepNo += 1
colData<StepNo,STEP_STEP$>			= StepNo
colData<StepNo,STEP_PROCESS_NAME$>	= 'Shipping'
colData<StepNo,STEP_TOOL_TYPE$>		= 'Paperwork'
colData<StepNo,STEP_PSN$>			= PSNo
colData<StepNo,STEP_PRODUCT$>		= 'Documentation'
colData<StepNo,STEP_RECIPE$>		= 'Manual'
colData<StepNo,STEP_SPEC_TOL$>		= 'Consistent Data'
colData<StepNo,STEP_EVAL_MEAS$>		= 'Visual'
colData<StepNo,STEP_SIZE$>			= 'Shipment'
colData<StepNo,STEP_FREQ$>			= 'Per Cass'
colData<StepNo,STEP_CTRL_METHOD$>	= 'WI'
colData<StepNo,STEP_REACT_PLAN$>	= 'Pass/Fail'



Font = 'Arial'
Font<FONT_JUST$>		= 'L'
Font<FONT_SIZE$>		= 8

Font<FONT_UNDERLINE$>	= 0
Font<FONT_BOLD$>		= 0
Void = Set_Printer( 'FONT', Font )

stat = Set_Printer('ADDTABLE', colFormat,colHeader,'',LTGREY$,'',0,TB_ALL)
stat = Set_Printer('ADDTABLE',colFormat,'',colData,LTGREY$,'',1,TB_ALL)


***************************************************

stat		= Set_Printer("CALCTEXT",CHAR(185):'Note: Special Characteristics')
noteSize	= Get_Printer("CALCTEXT")
noteWidth 	= noteSize<1>
noteHeight 	= noteSize<2>


stat = Set_Printer('TEXT')
stat = Set_Printer('TEXT',CHAR(185):'Note: Special Characteristics')

stat = Set_Printer('TEXT')

SpecialInst = PSNRec<PROD_SPEC_SPEC_INST$>			;* 3/25/2013 JCH
ProveinInst = PSNRec<PROD_SPEC_PROVE_IN_INST$>		;* 3/25/2013 JCH

SWAP @TM WITH CRLF$ IN SpecialInst
SWAP @TM WITH CRLF$ IN ProveInInst

colHeader	= 'Special Instructions'
colFmt		= '^14400'
colData		= SpecialInst

stat = Set_Printer('CALCTABLE',colFmt:@FM:colData)

TableSize	= Get_Printer('CALCTABLE')
TableHeight = TableSize<2>
CurrY = Get_Printer('POS')<2>

IF CurrY + noteHeight + TableHeight > MaxPrintHeight  THEN
	stat = Set_Printer('PAGEBREAK')
END

Font<2> = 10   
Font<4> = 0
Void = Set_Printer( 'FONT', Font )   

stat = Set_Printer('ADDTABLE', colFmt,colHeader,'',LTGREY$,'',0,TB_ALL)

colFmt = '<14400'
stat = Set_Printer('ADDTABLE',colFmt,'',colData,LTGREY$,'',1,TB_ALL)

stat = Set_Printer('TEXT')

colHeader	= 'Prove-In Instructions'
colFmt		= '^14400'
colData		= ProveinInst

stat = Set_Printer('CALCTABLE',colFmt:@FM:colData)

TableSize	= Get_Printer('CALCTABLE')
TableHeight = TableSize<2>
CurrY = Get_Printer('POS')<2>

IF CurrY + noteHeight + TableHeight > MaxPrintHeight  THEN
	stat = Set_Printer('PAGEBREAK')
END


Font<2> = 10   
Font<4> = 0
Void = Set_Printer( 'FONT', Font )   

stat = Set_Printer('ADDTABLE', colFmt,colHeader,'',LTGREY$,colData,0,TB_ALL)

colFmt = '<14400'
stat = Set_Printer('ADDTABLE',colFmt,'',colData,LTGREY$,'',1,TB_ALL)


stat = set_printer( 'TERM' )

RETURN




