COMPILE ROUTINE MOVE_SURF_SCAN(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE Send_Dyn,Send_Info
DECLARE FUNCTION Get_Status

$INSERT SURF_SCAN
$INSERT SURFACE_SCAN_EQUATES
$INSERT RDS_EQU


OPEN 'RDS' TO RDSTable ELSE
	Send_Dyn('Unable to open "RDS" table for conversion')
	GOTO Bail
END

OPEN 'SURF_SCAN' TO TableIn ELSE
	Send_Dyn('Unable to open "SURF_SCAN" table for conversion')
	GOTO Bail
END

OPEN 'SURFACE_SCAN' TO TableOut ELSE
	Send_Dyn('Unable to open "SURFACE_SCAN" table for conversion')
	debug
	GOTO Bail
END

SELECT TableIn

RecCnt = 0
debug
Done = 0

LOOP
	READNEXT SSKey ELSE Done = 1
UNTIL Done
	READ SSRec FROM TableIn,SSKey THEN
		RDSNo	= SSKey[1,'*']
		Stage	= SSKey[COL2()+1,'*']
		
		RDSRec = XLATE('RDS',RDSNo,'','X')
		
		WOStepKey = RDSRec<RDS_WO_STEP_KEY$>
		WONo	= WOStepKey[1,'*']
		WOStep	= WOStepKey[COL2()+1,'*']
		
		CassNo	= XLATE('RDS',RDSNo,'CASS_NO','X')
		
		SurfScanRec = SSRec
		SurfScanRec<SURFACE_SCAN_SCAN_DTM$> = SSRec<1>
		SurfScanRec<SURFACE_SCAN_RDS_NO$>	= RDSNo
		
		
		
		BEGIN CASE
			CASE WONo = ''		; WriteFlag = 0
			CASE WOStep = ''	; WriteFlag = 0
			CASE CassNo = ''	; WriteFlag = 0
			CASE Stage = ''		; WriteFlag = 0
			CASE 1				; WriteFlag = 1
		END CASE
	
		
		IF WriteFlag THEN
		
			SurfScanKey = WONo:'*':WOStep:'*':CassNo:'*':Stage
			READ Dummy FROM TableOut,SurfScanKey ELSE
				WRITE SurfScanRec ON TableOut,SurfScanKey THEN
					Send_Dyn(RecCnt)
				END
			END
		END
			
	END	;* End of RDS record read

REPEAT

IF Get_Status(errCode) THEN DEBUG

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

END
