COMPILE SUBROUTINE Export_SSR( Dummy )

DECLARE FUNCTION Msg, Dialog_Box, Utility, Environment_Services
DECLARE FUNCTION Set_Printer, Get_Printer, obj_Install, Utility, obj_MUWafers

DECLARE SUBROUTINE Btree.Extract, RList, END_Dialog, Make.List, Msg, ErrMsg, SetInitDirOptions

$INSERT LSL_USERS_EQU
$INSERT MSG_EQUATES
$INSERT RLIST_EQUATES
$INSERT OIPRINT_EQUATES
$INSERT WO_LOG_EQU
$INSERT WO_STEP_EQU
$INSERT WO_MAT_EQUATES
$INSERT COMPANY_EQU
$INSERT QUOTE_EQU
$INSERT QUOTE_SPEC_EQU
$INSERT RECIPE_EQU
$INSERT ORDER_DET_EQU
$INSERT PROD_SPEC_EQU

CRLF$ = \0D0A\

OPEN 'REACT_RUN' TO ReactRunTable ELSE
	ErrMsg('Unable to open "REACT_RUN" table in EXPORT_SSR routine.')
	RETURN
END

OPEN 'DICT.REACT_RUN' TO DictReactRun ELSE
	ErrMsg('Unable to open "DICT.REACT_RUN" table in EXPORT_SSR routine.')
	RETURN
END

Def = ""
Def<MTEXT$> = "Selecting Reactor Run Records..."
Def<MTYPE$> = "U"

MsgUp = Msg(@WINDOW, Def)

SelectSent = 'SELECT REACT_RUN WITH UNLOAD_DT ':QUOTE(UnloadDt):' BY REACTOR BY PS_NO'

SelectSent = 'SELECT WO_STEP WITH SCHEDULED = "0" OR WITH SCHEDULED = "" '
RList(SelectSent,TARGET_ACTIVELIST$,'','','')


WOStepKeys = ''
Done = 0
LOOP
	READNEXT WOStepKey ELSE Done = 1
UNTIL Done
	WOStepKeys<-1> = WOStepKey
REPEAT

CONVERT @VM TO @FM IN WOStepKeys

IF WOStepKeys = '' THEN
	Msg(@window, MsgUp)
	ErrMsg('No Work Orders remain unscheduled.')
	RETURN
END


* FileName = "C:\OIReport\EPI.csv"
FileName = Environment_Services('GetReportsRootPath') : "\EPI.csv"
OsByte = 0

OpenFile:

OSDelete FileName
OSOpen FileName TO OsFile ELSE
	OSWrite "" TO FileName
	IF Status() THEN
		Msg(@window, MsgUp)
		debug
		RETURN
	END
   
	OSOpen FileName TO OSFile ELSE 
		Msg(@window, MsgUp)
		debug
		RETURN
	END
END

