COMPILE ROUTINE LOAD_SIGS(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, Send_Dyn, obj_WO_Step, Set_Status, Btree.Extract, obj_RDS, RList, ErrMsg
DECLARE SUBROUTINE obj_Tables, obj_WO_Mat
DECLARE FUNCTION Get_Status, Set_Printer, obj_RDS, ErrMsg, obj_Tables

$INSERT RDS_EQU
$INSERT WO_LOG_EQU
$INSERT WO_MAT_EQUATES
$INSERT ORDER_EQU
$INSERT PROD_SPEC_EQU

EQU TARGET_ACTIVELIST$ TO 5

OPEN 'RDS' TO FileIn ELSE
	debug
	GOTO Bail
END

OPEN 'WO_MAT' TO WOMatTable ELSE
	debug
	GOTO Bail
END



SELECT FileIn

Done = 0
RecCnt = 0
LOOP
	READNEXT RDSNo ELSE Done = 1
UNTIL Done 
	READ RDSRec FROM FileIn,RDSNo THEN
		RecCnt += 1
		Send_Info(RecCnt)
		ReactorType = XLATE('REACTOR',@RECORD<2>,1,'X')
		ReactorNo = RDSRec<RDS_REACTOR$>

		WOMatKey = ''
		IF ReactorType NE 'EPP' AND ReactorNo NE '' THEN
		   WONo = RDSRec<6>
		   CassNo = RDSRec<260>
		   IF WONo NE '' AND CassNo NE '' THEN
		        WOMatKey = WONo:'*':CassNo
		   END
		
			
			IF WOMatKey NE '' THEN
			
				LogFile		= 'WO_MAT'
			
				WOMatRec = XLATE('WO_MAT',WOMatKey,'','X')
				
				IF NOT(INDEX(WOMatRec<WO_MAT_INV_ACTION$>,'Load',1)) THEN
					
					InvLocation	= 'CR*R':RDSRec<RDS_REACTOR$>:'L'
					
					InvAction	= 'Load'
					LInvDTM		= OCONV(RDSRec<RDS_DATE_IN$>,'D4/'):' ':OCONV(RDSRec<RDS_TIME_IN$>,'MT')
					ScanUserID	= RDSRec<RDS_OPERATOR_IN$>
					
					IF ICONV(LInvDTM,'DT') THEN
						Parms  = LogFile:@RM
						Parms := WONo:@RM
						Parms := CassNo:@RM
						Parms := InvLocation:@RM
						Parms := InvAction:@RM
						Parms := LInvDTM:@RM
						Parms := ScanUserID
						
						Set_Status(0)
						
						Send_Dyn(RDSNo)
						
						obj_WO_Mat('AddInvTrans',Parms)
						
						IF Get_Status(errCode) THEN DEBUG
					END
				END
				
				IF NOT(INDEX(WOMatRec<WO_MAT_INV_ACTION$>,'Unload',1)) THEN
					
					InvAction	= 'Unload'
					
					IF RDSRec<RDS_DATE_OUT$> = RDSRec<RDS_DATE_IN$> AND RDSRec<RDS_TIME_IN$> = RDSRec<RDS_TIME_OUT$> THEN
					
						TimeOut = RDSRec<RDS_TIME_OUT$>
						TimeOut += 60
						
						InvDtm = OCONV(RDSRec<RDS_DATE_OUT$>,'D4/'):' ':OCONV(TimeOut,'MT')
					END ELSE
						InvDTM = OCONV(RDSRec<RDS_DATE_OUT$>,'D4/'):' ':OCONV(RDSRec<RDS_TIME_OUT$>,'MT')
					END
					
					ScanUserID	= RDSRec<RDS_OPERATOR_OUT$>
					InvLocation	= 'CR*R':RDSRec<RDS_REACTOR$>:'U'
					
					IF ICONV(InvDTM,'DT') THEN
						Parms  = LogFile:@RM
						Parms := WONo:@RM
						Parms := CassNo:@RM
						Parms := InvLocation:@RM
						Parms := InvAction:@RM
						Parms := InvDTM:@RM
						Parms := ScanUserID
						
						Set_Status(0)
						
						Send_Dyn(RDSNo)
						
						obj_WO_Mat('AddInvTrans',Parms)
						
						IF Get_Status(errCode) THEN DEBUG
					END
					
				END
				
			END ;* End of check for WO_MAT_KEY
		END
	END	;* End of read

REPEAT
* * * * * * *
Bail:
* * * * * * *

END
