COMPILE ROUTINE FIX_QUOTE_DET(Dummy)
ROWDEF(CHARSTR)

DECLARE SUBROUTINE obj_Schedule,Send_Dyn,Send_Info
DECLARE FUNCTION Get_Status, Set_Printer

$INSERT QUOTE_EQU
$INSERT QUOTE_DET_EQU

OPEN 'QUOTE' TO FileIn ELSE
	debug
	GOTO Bail
END

OPEN 'QUOTE_DET' TO FileOut ELSE
	debug
	GOTO Bail
END



SELECT FileIn
Done = 0
RecCnt = 0
LOOP
	READNEXT @ID ELSE Done = 1
UNTIL Done
	READ QuoteRec FROM FileIn,@ID THEN		
			
		IF QuoteRec<QUOTE_PROD_SPEC_ID$> NE '' THEN
		
		QuoteDetKey = @ID:'*':1
		READ QuoteDetRec FROM FileOut,QuoteDetKey ELSE QuoteDetRec = ''
			IF QuoteRec<QUOTE_PROD_SPEC_ID$> NE '' AND QuoteRec<QUOTE_PREV_PROD_SPEC_IDS$> NE '' THEN
				IF QuoteDetRec<QUOTE_DET_PROC_STEP$> = '' THEN
					FOR I = 1 TO COUNT(QuoteRec<QUOTE_PREV_PROD_SPEC_IDS$>,@VM) + (QuoteRec<QUOTE_PREV_PROD_SPEC_IDS$> NE '')
						QuoteDetRec<QUOTE_DET_PROC_STEP$,I> = I
						QuoteDetRec<QUOTE_DET_PROC_PSN$,I>	= QuoteRec<QUOTE_PREV_PROD_SPEC_IDS$,I>
						QuoteDetRec<QUOTE_DET_PROC_DESC$,I>	= ''
					NEXT I
					QuoteDetRec<QUOTE_DET_PROC_STEP$,I> = I
					QuoteDetRec<QUOTE_DET_PROC_PSN$,I>	= QuoteRec<QUOTE_PROD_SPEC_ID$>
					QuoteDetRec<QUOTE_DET_PROC_DESC$,I>	= ''
					
					*debug
					
					WRITE QuoteDetRec ON FileOut,QuoteDetKey ELSE Null
				END
				
			END
		END
		RecCnt += 1
		Send_Info(RecCnt)
	END

REPEAT






IF Get_Status(errCode) THEN DEBUG


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

END
