COMPILE ROUTINE LOAD_Shipments(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 COC_EQU
$INSERT RDS_EQU
$INSERT WO_LOG_EQU
$INSERT ORDER_EQU
$INSERT PROD_SPEC_EQU

EQU TARGET_ACTIVELIST$ TO 5

OPEN 'COC' 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 ShipNo ELSE Done = 1
UNTIL Done 
	IF ShipNo < 52351 THEN GOTO SkipIt
	
	READ ShipRec FROM FileIn,ShipNo THEN
		RecCnt += 1
		Send_Info(RecCnt)
		
		WONo	= ShipRec<COC_WO$>
		WOSteps = ShipRec<COC_WO_STEP$>
		CassNos = ShipRec<COC_CASS_NO$>
		RDSNos  = ShipRec<COC_RDS_NO$>
		PickDTM = ShipRec<COC_PICK_DTM$>
		
		FOR I = 1 TO COUNT(WOSteps,@VM) + (WOSteps NE '')
			WOStep = WOSteps<1,I>
			CassNo = CassNos<1,I>
			RDSNo = RDSNos<1,I>
			
			IF RDSNo = '' THEN

				WMOutKey = WONo:'*1*':CassNo
				WMOActions = XLATE('WM_OUT',WMOutKey,50,'X')
				IF INDEX(WMOActions,'Ship',1) THEN 
					NULL
				END ELSE
			
					LogFile		= 'WM_OUT'
					InvLocation	= 'SR*SB'
					InvAction	= 'Ship'
					InvDTM		= OCONV(PickDTM,'DT2/^HS')
					ScanUserID	= ShipRec<COC_PICK_BY$>
					
					Parms  = LogFile:@RM
					Parms := WONo:@RM
					Parms := CassNo:@RM
					Parms := InvLocation:@RM
					Parms := InvAction:@RM
					Parms := InvDTM:@RM
					Parms := ScanUserID
					
					Set_Status(0)
					obj_WO_Mat('AddInvTrans',Parms)
			
				END
				
			END ELSE
				
				WOMatKey = WONo:'*':CassNo
				WOMatActions = XLATE('WO_MAT',WOMatKey,8,'X')
				IF INDEX(WOMatActions,'Ship',1) THEN
					NULL
				END ELSE
				
					LogFile		= 'WO_MAT'
					InvLocation	= 'SR*SB'
					InvAction	= 'Ship'
					InvDTM		= OCONV(PickDTM,'DT2/^HS')
					
					ScanUserID	= ShipRec<COC_PICK_BY$>
					
					Parms  = LogFile:@RM
					Parms := WONo:@RM
					Parms := CassNo:@RM
					Parms := InvLocation:@RM
					Parms := InvAction:@RM
					Parms := InvDTM:@RM
					Parms := ScanUserID
					
					Set_Status(0)
					
					obj_WO_Mat('AddInvTrans',Parms)
					
					IF Get_Status(errCode) THEN DEBUG
					
				END
			
			END
		
		
		NEXT I
	
		
	END	;* End of read

* * * * * * *
SkipIt:
* * * * * * *

REPEAT


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

END
