COMPILE ROUTINE MOVE_Inv_Trans(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, Utility, Msg, RList, Set_Status, obj_WO_Mat
DECLARE FUNCTION Get_Status

$INSERT WM_IN_EQUATES
$INSERT WM_OUT_EQUATES


OPEN 'WM_OUT' TO FileIn ELSE
	DEBUG
	GOTO Bail
END

SELECT FileIn

RecCnt = 0
Done = 0
LOOP
	ReadNext WMKey ELSE Done = 1
UNTIL Done
	READ WMRec FROM FileIn,WMKey THEN
		IF WMRec<WM_OUT_INV_WH$> NE '' THEN
			
		
			WriteFlag = 0
			
			FOR I = 1 TO COUNT(WMRec<WM_OUT_INV_WH$>,@VM) + (WMRec<WM_OUT_INV_WH$> NE '')
				LogFile = 'WO_MAT'
				WONo	= WMKey[1,'*']
				CassNo	= FIELD(WMKey,'*',3)
				InvWH	= WMRec<WM_OUT_INV_WH$>
				InvLoc	= WMRec<WM_OUT_INV_LOCATION$>
				InvAct	= WMRec<WM_OUT_INV_ACTION$> 
				InvDTM	= OCONV(WMRec<WM_OUT_INV_DTM$>,'DT4/^S')
				ScanID	= WMRec<WM_OUT_INV_USER$> 
				
				InvLocation = InvWH:'*':InvLoc
				
				Parms  = LogFile:@RM
				Parms := WONo:@RM
				Parms := CassNo:@RM
				Parms := InvLocation:@RM
				Parms := InvAct:@RM
				Parms := InvDTM:@RM
				Parms := ScanID
				
				Set_Status(0)
				
				obj_WO_Mat('AddInvTrans',Parms)
				
				IF Get_Status(errCode) ELSE
				
					WMRec = DELETE(WMRec,WM_OUT_INV_WH$,I,0)
					WMRec = DELETE(WMRec,WM_OUT_INV_LOCATION$,I,0)
					WMRec = DELETE(WMRec,WM_OUT_INV_ACTION$,I,0)
					WMRec = DELETE(WMRec,WM_OUT_INV_DTM$,I,0)
					WMRec = DELETE(WMRec,WM_OUT_INV_USER$,I,0)
					
					WriteFlag = 1
					
					*Send_Dyn(WMKey)
				END
			NEXT I
			
			IF WriteFlag THEN
				WRITE WMRec ON FileIn,WMKey THEN
					Send_Dyn(WMKey:' -> Written')
				END
			END ELSE
				Send_Dyn(WMKey:' -> No Write')
			END
		END
	END
REPEAT

		

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

END
