COMPILE ROUTINE LOAD_CLEAN_INSP_WMO(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, ErrMsg
DECLARE FUNCTION Get_Status, Set_Printer, NextKey

$INSERT OIPRINT_EQUATES

$INSERT WM_OUT_EQUATES
$INSERT CLEAN_INSP_EQUATES
$INSERT SURFACE_SCAN_EQUATES
$INSERT PROD_SPEC_EQU

OPEN 'WM_OUT'		TO WMOutTable		ELSE GOTO Bail
OPEN 'CLEAN_INSP' 	TO CITable			ELSE GOTO Bail

SELECT WMOutTable

Done = 0
RecCnt = 0
LOOP
	READNEXT WMOutKey ELSE Done = 1
UNTIL Done
	RecCnt += 1
	Send_Info(RecCnt)
	
	READ WMOutRec FROM WMOutTable,WMOutKey THEN
		
		WONo	= WMOutKey[1,'*']
		WOStep	= WMOutKey[COL2()+1,'*']
		CassNo	= WMOutKey[COL2()+1,'*']
		
		IF WONo ='' OR WOStep = '' OR CassNo = '' THEN GOTO Skip
		
		Stage	= 'PC'
		
		PSNo = XLATE('WO_STEP',WONo:'*':WOStep,1,'X')
		PSrec = XLATE('PROD_SPEC',PSNo,'','X')
		
		CINo = WMOutRec<WM_OUT_CI_NO$>

		IF CINo = '' THEN
		
			* Build the basic CleanInspRecord
		
			CINo = NextKey('CLEAN_INSP')
			
			WMOutRec<WM_OUT_CI_NO$> = CINo
			
			WRITE WMOutRec ON WMOutTable,WMOutKey ELSE
				DEBUG
			END
		END ELSE
			READ CIRec FROM CITable,CINo ELSE
				ErrMsg('Unable to read CIRec ':QUOTE(CINo)) 
			END
		END
			
		PSNo = XLATE('WO_STEP',WONo:'*':WOStep,1,'X')
		PSrec = XLATE('PROD_SPEC',PSNo,'','X')

		ReactorType = PSRec<PROD_SPEC_REACTOR_TYPE$>

		CIRec = ''
		
		CIRec<CLEAN_INSP_WO_NO$>		= WONo
		CIRec<CLEAN_INSP_WO_STEP$>		= WOStep
		CIRec<CLEAN_INSP_CASS_NO$>		= CassNo
		CIRec<CLEAN_INSP_STAGE$>		= 'POST'
		CIRec<CLEAN_INSP_RDS_NO$>		= ''
		
		CIRec<CLEAN_INSP_SPEC_BRIGHTLIGHT$>				= PSRec<PROD_SPEC_POST_CLEAN_BRIGHTLIGHT$>
		CIRec<CLEAN_INSP_SPEC_SURFSCAN$>				= PSRec<PROD_SPEC_POST_CLEAN_SURFSCAN$>
		CIRec<CLEAN_INSP_SPEC_SURFSCAN_RECIPE$>			= PSRec<PROD_SPEC_POST_CLEAN_SURFSCAN_RECIPE$>

		IF CIRec<CLEAN_INSP_SPEC_BRIGHTLIGHT$> = 1 THEN
			CIRec<CLEAN_INSP_SPEC_PITS$>				= PSRec<PROD_SPEC_POST_PITS$>
			CIRec<CLEAN_INSP_SPEC_MOUNDS$>				= PSRec<PROD_SPEC_POST_MOUNDS$>
			CIRec<CLEAN_INSP_SPEC_BL_DEFECTS$>			= PSRec<PROD_SPEC_POST_BL_DEFECTS$>
			CIRec<CLEAN_INSP_SPEC_SPOTS$>				= PSRec<PROD_SPEC_POST_SPOTS$>
			CIRec<CLEAN_INSP_SPEC_FOV$>					= PSRec<PROD_SPEC_POST_FOV$>
			CIRec<CLEAN_INSP_SPEC_SCRATCHES$>			= PSRec<PROD_SPEC_POST_SCRATCHES$>
			CIRec<CLEAN_INSP_SPEC_SCRATCH_LEN$>			= PSRec<PROD_SPEC_POST_SCRATCH_LEN$>
			CIRec<CLEAN_INSP_SPEC_LPD$>					= PSRec<PROD_SPEC_POST_LPD$>
			CIRec<CLEAN_INSP_SPEC_STACK_FAULTS$>		= PSRec<PROD_SPEC_POST_STACK_FAULTS$>
			CIRec<CLEAN_INSP_SPEC_SPIKES$>				= PSRec<PROD_SPEC_POST_SPIKES$>
		END
		
		CIRec<CLEAN_INSP_SPEC_SURF_HAZE$>				= PSRec<PROD_SPEC_POST_CLEAN_SURF_HAZE$>
		CIRec<CLEAN_INSP_SPEC_SURF_DEFECTS$>			= PSRec<PROD_SPEC_POST_CLEAN_SURF_DEFECTS$>
		CIRec<CLEAN_INSP_SPEC_SS_SAMP_QTY$>				= PSRec<PROD_SPEC_POST_CLEAN_SS_SAMP_QTY$>
		
		CIRec<CLEAN_INSP_SPEC_CLEAN_SUBOXIDE$>			= XLATE('PROD_SPEC',PSNo,'SUB_OXIDE_STRIP','X')
		CIRec<CLEAN_INSP_SPEC_CLEAN_OXIDE_ANGSTROMS$>	= XLATE('PROD_SPEC',PSNo,'SUB_OXIDE_ANGSTROMS','X')
		CIRec<CLEAN_INSP_SPEC_CLEAN_TOOL$>				= XLATE('PROD_SPEC',PSNo,'SUB_POST_CLEAN','X')
		CIRec<CLEAN_INSP_SPEC_CLEAN_AKRION_RECIPE$>		= XLATE('PROD_SPEC',PSNo,'POST_AKRION_RECIPE','X')
			
			
	
		CIRec<CLEAN_INSP_CLEAN_CODE$>			= WMOutRec<WM_OUT_POST_CODE$>
		CIRec<CLEAN_INSP_CLEAN_BOAT_ID$>		= WMOutRec<WM_OUT_POST_BOAT_ID$>
		CIRec<CLEAN_INSP_CLEAN_SRD_NO$>			= WMOutRec<WM_OUT_POST_SRD_NO$>
		CIRec<CLEAN_INSP_CLEAN_SIG$>			= WMOutRec<WM_OUT_POST_EPI_SIG$>
		CIRec<CLEAN_INSP_CLEAN_SIG_DTM$>		= WMOutRec<WM_OUT_POST_EPI_SIG_DTM$>
		
		CIRec<CLEAN_INSP_PITS$>					= WMOutRec<WM_OUT_POST_PITS$>
		CIRec<CLEAN_INSP_MOUNDS$>				= WMOutRec<WM_OUT_POST_MOUNDS$>
		CIRec<CLEAN_INSP_LPD_IN$>				= WMOutRec<WM_OUT_LPD_FIRSTWAFER$>
		CIRec<CLEAN_INSP_LPD_OUT$>				= WMOutRec<WM_OUT_LPD_POSTCLEAN$>
		
		CIRec<CLEAN_INSP_INSP_SIG$>				= WMOutRec<WM_OUT_SUP_VER_SIG$>
		CIRec<CLEAN_INSP_INSP_SIG_DTM$>			= WMOutRec<WM_OUT_SUP_VER_SIG_DTM$>
		
		CIRec<CLEAN_INSP_BL_DEFECTS$>			= WMOutRec<WM_OUT_POST_BL_DEFECTS$>
		CIRec<CLEAN_INSP_STACK_FAULTS$>			= WMOutRec<WM_OUT_POST_STACK_FAULTS$>
		CIRec<CLEAN_INSP_SPIKES$>				= WMOutRec<WM_OUT_POST_SPIKES$>
		CIRec<CLEAN_INSP_SPOTS$>				= WMOutRec<WM_OUT_POST_SPOTS$>
		CIRec<CLEAN_INSP_FOV$>					= WMOutRec<WM_OUT_POST_FOV$>
		CIRec<CLEAN_INSP_SCRATCHES$>			= WMOutRec<WM_OUT_POST_SCRATCHES$>
		CIRec<CLEAN_INSP_SCRATCH_LEN$>			= WMOutRec<WM_OUT_POST_SCRATCH_LEN$>
	
		
		SurfScanKey = WONO:'*':WOStep:'*':CassNo:'*':'PC'
		SurfScanRec = XLATE('SURFACE_SCAN',SurfScanKey,'','X')
		
		IF SurfScanRec NE '' THEN

			CIRec<CLEAN_INSP_SCAN_TOOL$>			= SurfScanRec<SURFACE_SCAN_SCAN_TOOL$> 
			CIRec<CLEAN_INSP_SCAN_DTM$>			= SurfScanRec<SURFACE_SCAN_SCAN_DTM$> 
			CIRec<CLEAN_INSP_SCAN_SUM_OF_DEF_MIN$>	= SurfScanRec<SURFACE_SCAN_SUM_OF_DEF_MIN$>
			CIRec<CLEAN_INSP_SCAN_SUM_OF_DEF_MAX$>	= SurfScanRec<SURFACE_SCAN_SUM_OF_DEF_MAX$>
			CIRec<CLEAN_INSP_SCAN_SUM_OF_DEF_AVG$>	= SurfScanRec<SURFACE_SCAN_SUM_OF_DEF_AVG$>
			CIRec<CLEAN_INSP_SCAN_HAZE_AVG_MIN$>		= SurfScanRec<SURFACE_SCAN_HAZE_AVG_MIN$>
			CIRec<CLEAN_INSP_SCAN_HAZE_AVG_MAX$>		= SurfScanRec<SURFACE_SCAN_HAZE_AVG_MAX$>
			CIRec<CLEAN_INSP_SCAN_HAZE_AVG_AVG$>		= SurfScanRec<SURFACE_SCAN_HAZE_AVG_AVG$>
		END
				
		WRITE CIRec ON CITable,CINo THEN
			*Send_Dyn(CINo:' ':RecCnt)	
			
		END		
	END
	
* * * * * *
Skip:	
* * * * * * 
	
REPEAT









* * * * * * *
Bail:
* * * * * * *


