COMPILE ROUTINE LOAD_SUB_PART(Dummy)
ROWDEF(CHARSTR)

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


$INSERT PART_EQUATES
$INSERT	SUB_PART_EQUATES


EQU TARGET_ACTIVELIST$ to 5


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

OPEN 'SUB_PART' TO SubPartTable ELSE
	ErrMsg('Unable to open SUB_PART')
	GOTO Bail
END	


SelectSent = 'SELECT PART WITH BASE_SUB_PN NE ""'

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
		BaseSubPN = XLATE('PART',PartNo,'BASE_SUB_PN','X')
		SubPN = PartRec<PART_SUB_PART_NO$>
		

		IF SubPN MATCHES "6N'-'1A'-'2A" ELSE SubPN = BaseSubPN
		
		READ SubPartRec FROM SubPartTable,SubPN ELSE SubPartRec = ''
		
		LOCATE PartNO IN SubPartRec<SUB_PART_PART_NO$> BY 'AR' USING @VM  SETTING Pos ELSE
			SubPartRec = INSERT(SubPartRec,SUB_PART_PART_NO$,Pos,0,PartNo)
		END
		
		WRITE SubPartRec ON SubPartTable,SubPN THEN
			RecCnt += 1	
			Send_Dyn(RecCnt:' ':PartNo:' ':SubPN)
		END
			
		
	END
REPEAT






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

END


