COMPILE ROUTINE RDS_RESET_CLEANS(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, obj_WO_Log, Set_Status, obj_WO_Step, RList, obj_WO_Mat
DECLARE SUBROUTINE ErrMsg, RDS_React_Run
DECLARE FUNCTION Get_Status, Set_Printer, obj_WO_Mat


$INSERT RDS_EQU
$INSERT SURFACE_SCAN_EQUATES
$INSERT WO_MAT_EQUATES
$INSERT COC_EQU



OPEN 'RDS' TO RDSTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'WO_MAT' TO WOMatTable ELSE
	DEBUG 
	GOTO Bail
END

OPEN 'SURFACE_SCAN' TO SurfaceScanTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'COC' TO ShipTable ELSE
	DEBUG
	GOTO Bail
END

RDSNos = ''


RDSNos  = '512475':@FM
RDSNos := '513180':@FM
RDSNos := '513506':@FM
RDSNos := '513564':@FM
RDSNos := '513595':@FM
RDSNos := '513601':@FM
RDSNos := '513602':@FM
RDSNos := '513603'


KeyCnt = COUNT(RDSNos,@FM) + (RDSNos NE '')



FOR K = 1 TO KeyCnt
	RDSNo = RDSNos<K>

	READ RDSRec FROM RDSTable,RDSNo THEN
		
		WONo = RDSRec<RDS_WO$>
		WOStep = RDSRec<RDS_WO_STEP_KEY$>[-1,'*']	
		CassNo = RDSRec<RDS_CASS_NO$>
		
		READ SurfaceScanRec FROM SurfaceScanTable,WONo:'*':WOStep:'*':CassNo:'*PC' THEN
			
			SurfaceScanRec<SURFACE_SCAN_SCAN_TOOL$>			= ''
			SurfaceScanRec<SURFACE_SCAN_SCAN_USER$>			= '' 
			SurfaceScanRec<SURFACE_SCAN_SCAN_DTM$>			= ''  

			SurfaceScanRec<SURFACE_SCAN_SUM_OF_DEF_MIN$>	= ''
			SurfaceScanRec<SURFACE_SCAN_SUM_OF_DEF_MAX$>	= ''
			SurfaceScanRec<SURFACE_SCAN_SUM_OF_DEF_AVG$>	= ''
			SurfaceScanRec<SURFACE_SCAN_HAZE_AVG_AVG$>		= ''
			
			WRITE SurfaceScanRec ON SurfaceScanTable,WONo:'*':WOStep:'*':CassNo:'*PC' THEN
				Send_Dyn(RDSNo:' SurfaceScan ':WONo:'*':WOStep:'*':CassNo:'*PC':' Reset')
			END
		END	;* End of SURFACE_SCAN record read
		
		READ WOMatRec FROM WOMatTable,WONo:'*':CassNo THEN
			
			SigCnt = COUNT(WOMatRec<WO_MAT_SIG_PROFILE$>,@VM) + (WOMatRec<WO_MAT_SIG_PROFILE$> NE '')
			
			LOCATE '1UNLOAD' IN WOMatRec<WO_MAT_SIG_PROFILE$> USING @VM SETTING Pos THEN
				FOR I = Pos+1 TO SigCnt
					WOMatRec<WO_MAT_SIGNATURE$,I> = ''
					WOMatRec<WO_MAT_SIG_DTM$,I> = ''
		
				NEXT I
			END
			
			ShipNo = WOMatRec<WO_MAT_SHIP_NO$>
			
			WRITE WOMatRec ON WOMatTable,WONo:'*':CassNo THEN
				Send_Dyn(RDSNo:' WO_Mat ':WONo:'*':CassNo:' Signatures Cleared')
			END	
			
			DEBUG
					
			READ ShipRec FROM ShipTable,ShipNo THEN
				LOCATE CassNo IN ShipRec<COC_CASS_NO$> USING @VM SETTING Pos THEN
					ShipRec<COC_CASS_RETURNED$,Pos> = 1
					
					WRITE ShipRec ON ShipTable,ShipNo THEN
						Send_Dyn(RDSNo:' WO_Mat ':WONo:'*':CassNo:' ShipNo ':ShipNo:' CassReturned flag set...')
					END
				END				
			END
					
			
			RDSRec<RDS_POST_EPI_SIG$>		= ''
			RDSRec<RDS_POST_EPI_SIG_DATE$>	= ''
			RDSRec<RDS_POST_EPI_SIG_TIME$> 	= ''
			RDSRec<RDS_SUP_VER_SIG$>		= ''
			RDSRec<RDS_SUP_VER_SIG_DATE$>	= ''
			RDSRec<RDS_SUP_VER_SIG_TIME$>	= ''
			RDSRec<RDS_POST_CODE$>			= ''
			RDSRec<RDS_POST_BOAT_ID$>		= ''
			RDSRec<RDS_POST_SRD_NUM$> 		= '' 
			RDSRec<RDS_SHIFT$>				= ''
			RDSRec<RDS_LPD_POSTCLEAN$>		= ''
			RDSRec<RDS_STATUS$>				= 'I'	;* "InProcessing"
			RDSRec<RDS_ADE_READ$>			= ''
			RDSRec<RDS_SHIP_NO$>			= ''
						
			WRITE RDSRec ON RDSTable,RDSNo THEN
				Send_Dyn(RDSNo:' RDS fields cleared.')
			END
			
			* Hook conversion code after the write
					
			CALL RDS_React_Run(RDSNo)
			
		END	;* End of WOMat record read
	END	;* End of RDS record read
NEXT K






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

END
