compile function RDS_SRPT1()
begin condition
pre:
post:
end condition
declare function getprinterlist, getprofilestring, writeprofilestring, extdevicemode, Set_Printer, Printer_Select
declare function msg, set_property, send_event, dialog_box, utility, get_property
declare function set_printer, Get_Status, obj_Install
declare subroutine rlist, or_view, activate_save_select, yield, Set_Status
declare subroutine btree.extract, update_index, rlist, end_dialog
declare subroutine activate_save_select
declare function msg, key_sort, utility, fieldcount, ex_vm_rem

$insert lsl_users_equ
$insert msg_equates
$insert rlist_equates
$INSERT PRINTSETUP_EQUATES

* IF THIS CODE IS EVER USED, IT MUST CHANGE THE MSG CALLS WITH MCOL=-2 MROW=-2

Params = dialog_box( 'RDS_SRPT1', @window, '*CENTER' )

if Params = 'CANCEL' or Params = '' then
    return 0
end

if Params = 'CANCEL' or Params = '' then
    return 0
end
open 'SYSLISTS' to SysListsTable else
    Void = msg( '', 'Unable to open SYSLISTS...' )
    return 0
end
ListsId = 'REACTOR_LOG_SRPT1*':@station
write '' on SysListsTable, ListsId else
    Void = msg( '', 'Unable to clear SYSLISTS ':ListsId:'...' )
    return 0
end
convert '*' to @fm in Params
DateInFrom   = Params<1> ; *
DateInThru   = Params<2> ; *
CustIds      = Params<3> ; *
Reactors     = Params<4> ; *
Design       = Params<5> ; * GRID OPTION

If Len(Design) Then Design:=' '
*************************************************************
* NEXT REPORT TRY ONLY USING SLIST
*************************************************************
WithStmt = ''
WithStmt = " WITH DATE_IN FROM '":DateInFrom:"' TO '": DateInThru:"' "

if ( Reactors <> '' ) then
    swap @vm with "' '" in Reactors
    Reactors = "'":Reactors:"'"
    WithStmt:=' AND WITH REACTOR = ':Reactors
end

if ( CustIDs <> '' ) then
    swap @vm with "' '" in CustIDs
    CustIDs = "'":CustIDs:"'"
    WithStmt:=' AND WITH CUST_NO = ':CustIDs
end

TblNme = "RDS"
DatFnt='"Courier New,6" '
HdrFnt='"Courier New,7,B" '
TtlFnt='"Courier New,10,B" '

RptWdt = 124
TtlMid = RptWdt/2
RptDte = OCONV(Date(),"D4/")
LenDte = Len(RptDte)
RptTtl = obj_Install('Get_Prop','CompTitle'):" Wafer Process History Report"
LenTtl = Len(RptTtl)
RptPgs = "Pg. 'P'"
LenPgs = Len(RptPgs)

TitleLine1 = ''
TitleLine2 = ''
TitleLine3 = ''

TtlBeg = TtlMid - (LenTtl/2) 
TtlSpc = TtlBeg - LenDte
TitleLine1 := '"':RptDte:Space(TtlSpc):RptTtl 

TtlEnd = TtlMid - (LenTtl/2) 
TtlSpc = TtlEnd - LenPgs
TitleLine1 := Space(TtlSpc):RptPgs:"'L'"

If Reactors <> '' then
   TReactors = Reactors
   swap "'" with '' in TReactors
   Swap " " With ", " In TReactors
   If Len(TReactors) > 3 Then 
      TReactors[-4,4]= " & ":TReactors[-2,2]
      RptTtl = "Reactors ":TReactors
   End Else
      RptTtl = "Reactor ":TReactors
  End    
   LenTtl = Len(RptTtl)   
   TtlSpc = Space(TtlMid-(LenTtl/2))
   TitleLine2 = TtlSpc:RptTtl:"'L'"
end else
   TitleLine2 = ''
end

RptTtl= "Dates: ":DateInFrom:" Through ": DateInThru
LenTtl = Len(RptTtl) 
TtlSpc = Space(TtlMid-(LenTtl/2))
TitleLine3 = TtlSpc:RptTtl:'" ' 

Feed = "'L'"

WithStmt = 'SELECT RDS BY REACTOR BY DATE_IN BY TIME_IN ':WithStmt

Void = utility( 'CURSOR', 'H' )

rlist( WithStmt, target_savelist$, ListsId, '', '' )

activate_save_select( ListsId )

Stmt = ''
BreakOnVar = '"':"'V'":'" '

*Set up fields to print on report, one field per line.
Fld01 = 'ABBREV_OR_CO_NAME COLHEAD "':Feed:'Customer" JUSTLEN "T20" COLFONT ':DatFnt
Fld02 = 'BREAK-ON REACTOR ':BreakOnVar:'COLHEAD "':Feed:'R#" JUSTLEN "C4" COLFONT ':DatFnt 
Fld03 = 'PART_NUM COLHEAD "':Feed:'Part No." JUSTLEN 20 COLFONT ':DatFnt
Fld04 = 'WO COLHEAD "':Feed:'WO" JUSTLEN C7 COLFONT ':DatFnt
Fld05 = 'SEQ COLHEAD "':Feed:'RDS#" JUSTLEN 8 COLFONT ':DatFnt 
Fld06 = 'RUN_ORDER_NUM COLHEAD "':Feed:'RO#" JUSTLEN C4 COLFONT ':DatFnt 
Fld07 = 'TOTAL WAFERS_IN COLHEAD "Wafers':Feed:'In" JUSTLEN 8 COLFONT ':DatFnt 
Fld08 = 'TOTAL WFRS_OUT COLHEAD "Wafers':Feed:'Out" JUSTLEN 8 COLFONT ':DatFnt 
Fld09 = 'TOTAL TOT_REJ COLHEAD "':Feed:'Rejects" JUSTLEN "R9" COLFONT ':DatFnt
Fld10 = 'DATE_IN COLHEAD "Date':Feed:'In" JUSTLEN C8 COLFONT ':DatFnt  
Fld11 = 'TIME_IN COLHEAD "Time':Feed:'In" JUSTLEN C8 COLFONT ':DatFnt
Fld12 = 'DATE_OUT COLHEAD "Date':Feed:'Out" JUSTLEN C8 COLFONT ':DatFnt  
Fld13 = 'TIME_OUT COLHEAD "Time':Feed:'Out" JUSTLEN C8 COLFONT ':DatFnt
Fld14 = 'TOTAL HRS_LOAD_TO_UNLOAD COLHEAD "Elapsed':Feed:'Hours" JUSTLEN R9 COLFONT ':DatFnt 
Fld15 = 'HOURS_PER_CASSETTE COLHEAD "Hours':Feed:'Cassette" JUSTLEN R10 COLFONT ':DatFnt 
Fld16 = 'TOTAL PRICE_CASSETTE COLHEAD "Price Per':Feed:'Cassette"  JUSTLEN 12 COLFONT ':DatFnt
Fld17 = 'STATUS COLHEAD "':Feed:'Status" JUSTLEN "T12" COLFONT ':DatFnt

Stmt:= "LIST ":TblNme:" "
Stmt:= Fld01 
Stmt:= Fld02 
Stmt:= Fld03 
Stmt:= Fld04 
Stmt:= Fld05 
Stmt:= Fld06 
Stmt:= Fld07 
Stmt:= Fld08 
Stmt:= Fld09 
Stmt:= Fld10 
Stmt:= Fld11 
Stmt:= Fld12 
Stmt:= Fld13 
Stmt:= Fld14 
Stmt:= Fld15 
Stmt:= Fld16 
Stmt:= Fld17

Hdng = ""
Hdng:= 'HEADING '
Hdng:= TitleLine1
Hdng:= TitleLine2 
Hdng:= TitleLine3
Hdng:= 'HDRFONT ':TtlFnt 
Hdng:= 'COLHDRFONT ':HdrFnt
Hdng:= ' ID-SUPP KEEP-TOGETHER BOX ':Design:'LANDSCAPE'

Stmt:= Hdng

* Added after upgrade to OI4.13a to reset default printer in OIPI32 engine.

PrintPath = Printer_Select('',1)	;* Select Default printer

Void = set_printer( 'INIT', '', '', .63:@fm:.63:@fm:.25:@fm:'', 0,'',PrintPath )
Void = Set_Printer('TERM')

Set_Status(0)
call slist( Stmt )

IF Get_Status(errCode) THEN DEBUG



Void = utility( 'CURSOR', 'A' )
write '' on SysListsTable, ListsId else
    Void = msg( '', 'Unable to clear SYSLISTS ':ListsId:'...' )
    return 0
end
return 0
