COMPILE ROUTINE FIX_PRS_STAGE(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, RList, ErrMsg, obj_Prod_Spec, Btree.Extract, obj_PRS_Stage
DECLARE FUNCTION Get_Status, Set_Printer, obj_Prod_Spec, NextKEy

$INSERT PROD_SPEC_EQUATES
$INSERT QUOTE_SPEC_EQU
$INSERT PART_EQUATES
$INSERT RLIST_EQUATES

$INSERT CUST_EPI_PART_EQUATES
$INSERT PRS_STAGE_EQUATES
$INSERT CLEAN_INSP_EQUATES

EQU TAB$ TO \09\:'/'

EQU CRLF$ TO \0D0A\

EQU PDISPLAY$ TO 8

OPEN 'PROD_SPEC' TO PSNTable ELSE
	DEBUG
	GOTO Bail
END


OPEN 'PRS_STAGE' TO StageTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'PRS_SIG' TO SigTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'CLEAN_INSP' TO CITable ELSE
	DEBUG
	GOTO Bail
END



SelectSent = 'SELECT PRS_SIG '

RList(SelectSent,TARGET_ACTIVELIST$,'','','')

DEBUG


Done = 0
RecCnt = 0
FixCnt = 0

LOOP
	READNEXT StageKey ELSE Done = 1
UNTIL Done 
	
	

	READ SigRec FROM SigTable,StageKey  THEN
	
		RecCnt += 1
		
		READ StageRec FROM StageTable,StageKey ELSE StageRec = ''
		
		StageRec<PRS_STAGE_PROC_TOOL$> = SigRec<1>
		StageRec<PRS_STAGE_PROC_INV_ACTION$> = SigRec<2>
				
		
				
			*WRITE StageRec ON StageTable,StageKey THEN
				Send_Dyn(RecCnt:' ':StageKey:' ':SigRec<1>:' ':SigRec<2>)
			*END
		
		
		
		
		
	END	;* End of Stage REcord read			
	
	
REPEAT

GOTO Bail


/*

SELECT StageTable

Done = 0
RecCnt = 0
FixCnt = 0

LOOP
	READNEXT StageKey ELSE Done = 1
UNTIL Done
	
		READ StageRec FROM StageTable,StageKey THEN
			RecCnt += 1
			ScratchLen		= StageRec<PRS_STAGE_SCRATCH_LEN$>
			BSideScratchLen	= StageRec<PRS_STAGE_BSIDE_SCRATCH_LEN$>
			
			StageRec<PRS_STAGE_SCRATCH_LEN$>		= ICONV(ScratchLen,'MD2')
			StageRec<PRS_STAGE_BSIDE_SCRATCH_LEN$>	= ICONV(BSideScratchLen,'MD2')
			
			IF StageRec<PRS_STAGE_SCRATCH_LEN$> NE '' OR StageRec<PRS_STAGE_BSIDE_SCRATCH_LEN$> NE '' THEN
			
				WRITE StageRec ON StageTable,StageKey THEN
					FixCnt += 1
					Send_Info(RecCnt:' ':FixCnt)
					*Send_Dyn(RecCnt:' ':StageKey:' Scratch Len: ':OCONV(StageRec<PRS_STAGE_SCRATCH_LEN$>,'MD2'):' BSide: ':OCONV(StageRec<PRS_STAGE_BSIDE_SCRATCH_LEN$>,'MD2'))
				END
			END
			
 		END	;* End of LWI Record Read
 	

REPEAT

Send_Dyn(RecCnt:' ':FixCnt)

*/


DEBUG

SelectSent = 'SELECT CLEAN_INSP BY-DSND WO_NO'

RList(SelectSent,TARGET_ACTIVELIST$,'','','')

DEBUG

Done = 0
RecCnt = 0
FixCnt = 0

LOOP
	READNEXT CIKey ELSE Done = 1
UNTIL Done 
	
	
		READ CIRec FROM CITable,CIKey THEN
		
			RecCnt += 1
			
			WONo = CIRec<CLEAN_INSP_WO_NO$>
			
			SpecScratchLen			= CIRec<CLEAN_INSP_SPEC_SCRATCH_LEN$>
			BSideSpecScratchLen		= CIRec<CLEAN_INSP_SPEC_BSIDE_SCRATCH_LEN$>
			
			InspScratchLen			= CIRec<CLEAN_INSP_INSP_SCRATCH_LEN$>
			BSideInspScratchLen		= CIRec<CLEAN_INSP_INSP_BSIDE_SCRATCH_LEN$>
			
			CIRec<CLEAN_INSP_SPEC_SCRATCH_LEN$>			= ICONV(SpecScratchLen,'MD2')
			CIRec<CLEAN_INSP_SPEC_BSIDE_SCRATCH_LEN$>	= ICONV(BSideSpecScratchLen,'MD2')
			CIRec<CLEAN_INSP_INSP_SCRATCH_LEN$>			= ICONV(InspScratchLen,'MD2')
			CIRec<CLEAN_INSP_INSP_BSIDE_SCRATCH_LEN$>	= ICONV(BSideInspScratchLen,'MD2')
			
			
			IF SpecScratchLen NE '' OR BSideSpecScratchLen NE '' OR InspScratchLen NE '' OR BSideInspScratchLen THEN
			
				*WRITE CIRec ON CITable,CIKey THEN
					FixCnt += 1
					Send_Info(RecCnt:' ':FixCnt:' ':WONo)
					*Send_Dyn(RecCnt:' ':CIKey:' Scratch Len: ':OCONV(CIRec<CLEAN_INSP_SPEC_SCRATCH_LEN$>,'MD2'):' BSide: ':OCONV(CIRec<CLEAN_INSP_kSPEC_BSIDE_SCRATCH_LEN$>,'MD2'))
				*END
			END
			
 		END	;* End of LWI Record Read
 	

REPEAT

Send_Dyn(RecCnt:' ':FixCnt:' ':WONo)






GOTO Bail


/*
WriteFlag = 0
Line = ''


IF StageRec<PRS_STAGE_CLEAN_TOOL$> NE '' OR StageRec<PRS_STAGE_CLEAN_RECIPE$> NE '' THEN
	StageRec<PRS_STAGE_CLEAN_SIG_REQ$> = 1
	Line = 'Clean '
	WriteFlag = 1
END

IF StageRec<PRS_STAGE_BRIGHTLIGHT$> = 1 OR StageRec<PRS_STAGE_MICROSCOPE$> = 1 THEN
	StageRec<PRS_STAGE_INSP_SIG_REQ$> = 1
	Line := 'Insp '
	WriteFlag = 1
END

IF StageRec<PRS_STAGE_SURFSCAN_RECIPE$> NE '' THEN
	StageRec<PRS_STAGE_SURFSCAN_SIG_REQ$> = 1
	Line := 'SurfScan'
	WriteFlag = 1
END
*/

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


END



