COMPILE ROUTINE FIX_CLEAN_INSP(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, RList, obj_Clean_Insp, Set_Status
DECLARE FUNCTION Get_Status, Set_Printer, NextKey

$INSERT OIPRINT_EQUATES

$INSERT REACT_RUN_EQUATES
$INSERT CLEAN_INSP_EQUATES
$INSERT REACTOR_EQUATES
$INSERT RLIST_EQUATES
$INSERT WO_STEP_EQUATES
$INSERT PRS_STAGE_EQUATES

OPEN 'REACT_RUN'	TO RRTable		ELSE GOTO Bail
OPEN 'CLEAN_INSP' 	TO CITable		ELSE GOTO Bail
OPEN 'PRS_STAGE' 	TO StageTable	ELSE GOTO Bail

SelectSent = 'SELECT CLEAN_INSP WITH STAGE = "UNLOAD"'

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

IF Get_Status(errCode) THEN
	RETURN
END

debug

Done = 0
RecCnt = @RECCOUNT
FixCnt = 0
LOOP
	READNEXT CINo ELSE Done = 1
UNTIL Done OR FixCnt > 10000
	
	WriteFlag = 1
	
	READ CIRec FROM CITable,CINo THEN
		
		Stage	= CIRec<CLEAN_INSP_STAGE$>
		
		IF Stage = 'UNLOAD' THEN
			
			DELETE CITable,CINo THEN
				
				FixCnt += 1
				Send_Dyn(CINo:' ':LEN(CIRec):' ':CIRec)
			END
		END 
	END
		

	Send_Info(RecCnt:' ':FixCnt:' ':(RecCnt - FixCnt))
	
REPEAT



GOTO Bail

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




GOTO Bail

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



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

END
