COMPILE ROUTINE LOAD_CUST_PART(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE Send_Dyn,Send_Info, Send_Dyn, Set_Status, RList, ErrMsg
DECLARE FUNCTION Get_Status, Set_Printer

$INSERT RDS_EQU
$INSERT QUOTE_DET_EQU
$INSERT ORDER_DET_EQU
$INSERT QUOTE_EQU
$INSERT PROD_SPEC_EQU
$INSERT PART_EQUATES
$INSERT CUST_PART_EQUATES


EQU TARGET_ACTIVELIST$ to 5


OPEN 'PART' TO PartTable ELSE
	ErrMsg('Unable to open PART')
	GOTO Bail
END	

OPEN 'CUST_PART' TO CustPartTable ELSE
	ErrMsg('Unable to open CUST_PART')
	GOTO Bail
END	


OPEN 'QUOTE' TO QuoteTable ELSE
	Errmsg('Unable to open QUOTE')
	GOTO Bail
END


OPEN 'PROD_SPEC' TO PSNTable ELSE
	ErrMsg('Unable to open PROD_SPEC')
	GOTO Bail
END	


SelectSent = 'SELECT PART'

RList(SelectSent,TARGET_ACTIVELIST$, "", "", "")

IF Get_Status(errCode) THEN
	ErrMsg(errCode)
	GOTO Bail
END

DEBUG

RecCnt = 0
Done = 0

LOOP
	READNEXT PartNo ELSE Done = 1
UNTIL Done
	READ PartRec FROM PartTable,PartNo THEN
		
		CustNo			= PartRec<PART_CUST_NO$>
		CustPartNo		= PartRec<PART_CUST_PART_NO$>
		
		ShipSpecNo = PartRec<PART_PROC_STEP_PSN$>[-1,'B':@VM]
		
		IF CustNo NE '' AND CustPartNo NE '' THEN
		
			ProdSpecRec = XLATE('PROD_SPEC',ShipSpecNo,'','X')
			
			LOCATE CustPartNo IN ProdSpecRec<PROD_SPEC_CUST_PART_NO$> USING @VM SETTING Pos THEN
				CustPnDesc		= ProdSpecRec<PROD_SPEC_PN_DESC$,Pos>
				InboundPNo		= ProdSpecRec<PROD_SPEC_INBOUND_CUST_PN$,Pos>
			END ELSE
				CustPnDesc = ''
				InboundPNo = ''
			END
			
			
			
			SpecNo			= ProdSpecRec<PROD_SPEC_SPEC_NUM$>
			SpecDesc		= ProdSpecRec<PROD_SPEC_SPEC_DESC$>
			SpecRev			= ProdSpecRec<PROD_SPEC_REV_NUM$>
			SpecRevDt		= ProdSpecRec<PROD_SPEC_REV_DATE$>
			SpecHardcopy	= ProdSpecRec<PROD_SPEC_HARD_COPY$>
			
			
			
			PartRec = ''
			
			PartRec<CUST_PART_DESC$>					= CustPNDesc
			PartRec<CUST_PART_INBOUND_CUST_PART_NO$>	= InboundPNo
			PartRec<CUST_PART_SPEC_NO$>					= SpecNo
			PartRec<CUST_PART_SPEC_REV$>				= SpecRev
			PartRec<CUST_PART_SPEC_REV_DT$>				= SpecRevDt
			PartRec<CUST_PART_SPEC_DESC$>				= SpecDesc
			PartRec<CUST_PART_SPEC_HARDCOPY$>			= SpecHardcopy
			PartRec<CUST_PART_PART_NO$>					= PartNo
			PartRec<20> = ShipSpecNo
			
			WRITE PartRec ON CustPartTable,CustNo:'*':CustPartNo THEN
				RecCnt += 1
				
				Send_Info(RecCnt:' ':CustNo:'*':CustPartNo)
			END
		END
	END
REPEAT






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

END


