COMPILE ROUTINE LOAD_RDS_ORDER_ITEM(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info, Send_Dyn, obj_WO_Step, Set_Status
DECLARE FUNCTION Get_Status, Set_Printer, obj_RDS


$INSERT ORDER_DET_EQU
$INSERT WO_LOG_EQU
$INSERT WO_STEP_EQU
$INSERT RDS_EQU


OPEN 'ORDER_DET' TO OrderDetTable ELSE
	DEBUG
	GOTO Bail
END

OPEN 'RDS' TO RDSTable ELSE
	DEBUG
	GOTO Bail
END

SELECT OrderDetTable
debug
Done = 0
RecCnt = 0
LOOP
	READNEXT OrdDetKey ELSE Done = 1
UNTIL Done
	READ OrderDetRec FROM OrderDetTable,OrdDetKey THEN
		RecCnt += 1
		OrderItemNo = FIELD(OrdDetKey,'*',2)
		WorkOrderRec = XLATE('WO_LOG',OrderDetRec<ORDER_DET_WO_NO$>,'','X')
		WorkOrderSteps = WorkOrderRec<WO_LOG_WO_STEP_KEY$>
		FOR W = 1 TO COUNT(WorkOrderSteps,@VM) + (WorkOrderSteps NE '')
			WOStepKey = WorkOrderSteps<1,W>
			RDSNos = XLATE('WO_STEP',WOStepKey,WO_STEP_RDS_KEY$,'X')
			FOR I = 1 TO COUNT(RdsNos,@VM) + (RDSNos NE '')
				READV Test FROM RDSTable,RDSNos<1,I>,RDS_ORDER_ITEM$ THEN
					Send_Info(RecCnt:' ':WOStepKey:' ':RDSNos<1,I>)
					IF Test NE '' THEN GOTO Skip
				END
				WRITEV OrderItemNo on RDSTable,RDSNos<1,I>,RDS_ORDER_ITEM$ THEN
					Send_Info(RecCnt:' ':WOStepKey:' ':RDSNos<1,I>)
				END
			
			NEXT I
		Skip:
		NEXT W
	
	END	;* End of OrdDetRec read

REPEAT



IF Get_Status(errCode) THEN DEBUG


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

END
