COMPILE ROUTINE TEST_MOVE_ORDER_DETAIL(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Notes, Set_Status, Send_Info, obj_Order, errMsg
DECLARE FUNCTION Get_Status,obj_Order


$INSERT ORDER_EQU
$INSERT WO_LOG_EQU
$INSERT PROD_SPEC_EQU
$INSERT WO_STEP_EQU
$INSERT SCHEDULE_EQU
$INSERT RLIST_EQUATES
$INSERT APPCOLORS

EQU ST$WO				TO 1
EQU ST$ORD_NO			TO 2
EQU ST$QUOTE_NO			TO 3
EQU ST$PRICE			TO 4
EQU ST$LOT_NOS			TO 5
EQU ST$LOT_QTYS			TO 6
EQU ST$PART_NOS			TO 7
EQU ST$SUB_PART_NOS		TO 8
EQU ST$WAF_INV_IDS		TO 9
EQU ST$SCHED_IDS		TO 10
EQU ST$ADD_CHG_DESCS	TO 11
EQU ST$ADD_CHG_AMTS		TO 12
EQU ST$CASS_CNT			TO 13
EQU ST$CASS_QTY			TO 14

ErrorTitle = 'Error in Stored Procedure Test_Move_Order_Detail'
ErrorMsg = ''

OPEN 'ORDER' TO OrderTable ELSE
	ErrorMsg = 'Unable to open "ORDER" table.'
	ErrMsg(ErrorTitle:@SVM:ErrorMsg)
	RETURN
END

OPEN 'WO_LOG' TO WOLogTable ELSE
	ErrorMsg = 'Unable to open "WO_LOG" table.'
	ErrMsg(ErrorTitle:@SVM:ErrorMsg)
	RETURN
END

OPEN 'WO_STEP' TO WOStepTable ELSE
	ErrorMsg = 'Unable to open "WO_STEP" table.'
	ErrMsg(ErrorTitle:@SVM:ErrorMsg)
	RETURN
END

OPEN 'SCHEDULE' TO SchedTable ELSE
	ErrorMsg = 'Unable to open "SCHEDULE" table.'
	ErrMsg(ErrorTitle:@SVM:ErrorMsg)
	RETURN
END	

OrderNo = 16551
DEBUG

READ OrderRec FROM OrderTable,OrderNo THEN
	Set_Status(0)
	WOUpdates = obj_Order('Ord_WOLog',OrderNo:@RM:OrderRec)
	
	IF Get_Status(errCode) THEN DEBUG
	
	FOR I = 1 TO COUNT(WOUpdates,@RM) + (WOUpdates NE '')
		WOUpdate = FIELD(WOUpdates,@RM,I,1)
		
		WONo = WOUpdate<ST$WO>
		
		READ WOLogRec FROM WOLogTable,WONo THEN
			QuoteNo = WOUpdate<ST$QUOTE_NO>
			QuoteDetKeys = XLATE('QUOTE',QuoteNo,35,'X')
			IF INDEX(QuoteDetKeys,@VM,1) ELSE
			
				WOLogRec<WO_LOG_ORDER_NO$>		= OrderNo
				WOLogRec<WO_LOG_QUOTE_NO$>		= WOUpdate<ST$QUOTE_NO>
				WOLogRec<WO_LOG_UNIT_PRICE$>	= WOUpdate<ST$PRICE>
				
				WOLogRec<WO_LOG_LOT_NO$>		= WOUpdate<ST$LOT_NOS>
				WOLogRec<WO_LOG_LOT_QTY$>		= WOUpdate<ST$LOT_QTYS>
				WOLogRec<WO_LOG_PART_NO$>		= WOUpdate<ST$PART_NOS>
				WOLogRec<WO_LOG_SUB_PART_NO$>	= WOUpdate<ST$SUB_PART_NOS>
				WOLogRec<WO_LOG_WAF_INV_ID$>	= WOUpdate<ST$WAF_INV_IDS>
				WOLogRec<WO_LOG_SCHED_ID$>		= WOUpdate<ST$SCHED_IDS>
				WOLogRec<WO_LOG_ADD_CHG_DESC$>	= WOUpdate<ST$ADD_CHG_DESCS>
				WOLogRec<WO_LOG_ADD_CHG_AMT$>	= WOUpdate<ST$ADD_CHG_AMTS>
			
				
				WRITE WOLogRec ON WOLogTable,WONo THEN
					Send_Info('WONo ':WONo)
				END ELSE
					ErrMsg('Unable to write WO_Log Record ':WONo:' in Write event of ORDER Window')
				END
				
			END	;* End of check for
		END	ELSE
			GOTO Skip
		END ;* End of WOLOgRec READ
	NEXT I

END	;* End of ORDER record read

* * * * * * *
SKIP:
* * * * * * *



GOTO Bail

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

END
