compile subroutine reactor_log_rpt3_prn( FromDate, ThruDate, Summary )
! 
* LIST REACTOR_LOG  ID-SUPP BREAK-ON REACTOR "'V'" JUSTLEN 5 BREAK-ON REACT_AREA_DESC "'V'" BREAK-ON REACT_PROB_DESC "'V'" JUSTLEN 30 BREAK-ON REACT_SERV_DESC "'V'" JUSTLEN 30 REACT_ITEM_IDS REACT_ITEMS_DESC  JUSTLEN 30 REACT_ITEM_QTY JUSTLEN 4 COLHEAD 'Qty' NOTES JUSTLEN 30 START_DATE JUSTLEN 10 START_TIME JUSTLEN 10 TOTAL ELAPSED_HOURS JUSTLEN 7 COLHEAD 'Hours' HEADING " Run Date: 'TS39'Page 'P''LS22'Reactor Log Report 07/01/97 To "
! 
*PRINTER ON
declare function set_printer
* 
* HEADING/FOOTING
Font = 'Courier New,6,L,0'
convert ',' to @fm in Font
HeadPos = '.38/1/1.44/1.44/.75/1.44/.5/1.75/.5/.5/.5'
convert '/' to @fm in HeadPos
TheHeader = " Reactor Log Report from (":oconv(FromDate, 'D2/'):") Thru (":oconv(ThruDate, 'D2/' ):')':" 'D' 'T' PAGE # 'P'":@fm
COLHEADER = "React" : @vm : "Area" : @vm : "Problem" : @vm : "Service" : @vm : "Items" : @vm : "Items Description":@vm: "Qty" : @vm : "Notes" : @vm : "Start" : @vm : "Start" : @vm : "Elapse":@fm
COLHEADER:= "or" : @vm : "" : @vm : "" : @vm : "" : @vm : "" : @vm : "" : @vm : "" : @vm: "": @vm : "Date" : @vm : "Time" : @vm : "Hours":@fm
*COLHEADER:= str('_',9):@vm:str('_',16):@vm:str('_',25):@vm:str('_',25):@vm:str('_',25):@vm:str('_',9):@vm:str('_',25):@vm:str('_',9):@vm:str('_',9):@vm:str('_',9):@fm
COLHEADER:= str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@vm:str('_',30):@fm
Void = set_printer( 'FONTHEADFOOT', Font )
Void = set_printer( 'HEADER', TheHeader, HeadPos, ColHeader )
Void = set_printer( 'FONT', Font )
* 
@RECCOUNT=0
FIRST.PASS=1
LAST.RECORD=0
READERR=0
* 
* OPEN DICT AND DATA FILES
* 
OPEN "DICT","REACTOR_LOG" TO @DICT ELSE RETURN
OPEN "","REACTOR_LOG" TO FILE.IN ELSE RETURN
* 
* MAKE COLUMN HEADING
* 
*COLHEADING "Reactor" : @FM : "Reactor Area" : @FM : "React Prob Desc" : @FM : "React Serv Desc" : @FM : "Reactor Items" : @FM : "React Items Desc" : @FM : "Qty" : @FM : "Notes" : @FM : "Start Date" : @FM : "Start Time" : @FM : "Hours"
*COLLENGTH 5 : @FM : 20 : @FM : 30 : @FM : 30 : @FM : 20 : @FM : 30 : @FM : 4 : @FM : 30 : @FM : 10 : @FM : 10 : @FM : 7
* 
* ZERO ACCUMULATORS FOR EACH BREAK
* 
ELAPSEDULHOURS.REACTOR.TOTAL=0
ELAPSEDULHOURS.REACTOR.COUNT=0
ELAPSEDULHOURS.REACTULAREAULDESC.TOTAL=0
ELAPSEDULHOURS.REACTULAREAULDESC.COUNT=0
ELAPSEDULHOURS.REACTULPROBULDESC.TOTAL=0
ELAPSEDULHOURS.REACTULPROBULDESC.COUNT=0
ELAPSEDULHOURS.REACTULSERVULDESC.TOTAL=0
ELAPSEDULHOURS.REACTULSERVULDESC.COUNT=0
ELAPSEDULHOURS.GRAND.TOTAL=0
ELAPSEDULHOURS.GRAND.COUNT=0
* 
* NULL PREVIOUS BREAK BUCKETS
* 
PREV.REACTOR=''
LAST.REACTOR.BREAK = 1
PREV.REACTULAREAULDESC=''
LAST.REACTULAREAULDESC.BREAK = 1
PREV.REACTULPROBULDESC=''
LAST.REACTULPROBULDESC.BREAK = 1
PREV.REACTULSERVULDESC=''
LAST.REACTULSERVULDESC.BREAK = 1
* 
! 
READRECORD:
! 
* 
* 
* ZERO BREAK FLAGS TO FALSE
* 
REACTOR.BREAK=0
REACTULAREAULDESC.BREAK=0
REACTULPROBULDESC.BREAK=0
REACTULSERVULDESC.BREAK=0
* 
* 
@FILE.ERROR.MODE=1
READNEXT @ID,WHICH.VALUE ELSE
@FILE.ERROR.MODE=0
IF STATUS() GT 0 THEN
@ANS=@FILE.ERROR<1>
Void = set_printer('TEXT',  {RLIST_TEXT_5})
RETURN
END
IF @FILE.ERROR<1> EQ 421 THEN
Void = set_printer('TEXT', {RLIST_TEXT_6})
GOTO READRECORD
END
IF @FILE.ERROR<1> NE 111 THEN
@ANS=@FILE.ERROR<1>
Void = set_printer('TEXT', {RLIST_TEXT_4})
READERR+=1
GOTO READRECORD
END
LAST.RECORD=1
REACTOR.BREAK=1
REACTOR=PREV.REACTOR
REACTULAREAULDESC.BREAK=1
REACTULAREAULDESC=PREV.REACTULAREAULDESC
REACTULPROBULDESC.BREAK=1
REACTULPROBULDESC=PREV.REACTULPROBULDESC
REACTULSERVULDESC.BREAK=1
REACTULSERVULDESC=PREV.REACTULSERVULDESC
END
@FILE.ERROR.MODE=0
* 
S.ATID=@ID
* 
IF FIRST.PASS AND LAST.RECORD THEN
Void = set_printer('TEXT', {RLIST_TEXT_2})
RETURN
END
* 
IF LAST.RECORD THEN GOTO BREAKS
* 
IF @REDUCTION.DONE THEN
@FILE.ERROR.MODE=1
READO @RECORD FROM FILE.IN,@ID ELSE
@FILE.ERROR.MODE=0
IF STATUS() GT 0 THEN
@ANS=@FILE.ERROR<1>
Void = set_printer('TEXT', {RLIST_TEXT_5})
RETURN
END
IF @FILE.ERROR<1> NE 100 THEN
@ANS=@FILE.ERROR<1>
Void = set_printer('TEXT', {RLIST_TEXT_4})
READERR+=1
END
GOTO READRECORD
END
@FILE.ERROR.MODE=0
END
* 
@RECCOUNT+=1
* 
* 
* CALCULATE VALUE(S) FOR COLUMN(S)
* 
S.ATID={@ID}
I.ATID=S.ATID
S.REACTOR={REACTOR}
I.REACTOR=S.REACTOR
S.REACTULAREAULDESC={REACT_AREA_DESC}
I.REACTULAREAULDESC=S.REACTULAREAULDESC
S.REACTULPROBULDESC={REACT_PROB_DESC}
I.REACTULPROBULDESC=S.REACTULPROBULDESC
S.REACTULSERVULDESC={REACT_SERV_DESC}
I.REACTULSERVULDESC=S.REACTULSERVULDESC
M.REACTULITEMULIDS={REACT_ITEM_IDS}<1,WHICH.VALUE> ; P.REACTULITEMULIDS=1 ; C.REACTULITEMULIDS=7
* 
* INITIALIZE MULTIVALUE BREAK CHECK VARIABLE
* 
S.REACTULITEMULIDS = M.REACTULITEMULIDS
M.REACTULITEMSULDESC={REACT_ITEMS_DESC}<1,WHICH.VALUE> ; P.REACTULITEMSULDESC=1 ; C.REACTULITEMSULDESC=7
* 
* INITIALIZE MULTIVALUE BREAK CHECK VARIABLE
* 
S.REACTULITEMSULDESC = M.REACTULITEMSULDESC
M.REACTULITEMULQTY={REACT_ITEM_QTY}<1,WHICH.VALUE> ; P.REACTULITEMULQTY=1 ; C.REACTULITEMULQTY=7
* 
* INITIALIZE MULTIVALUE BREAK CHECK VARIABLE
* 
S.REACTULITEMULQTY = M.REACTULITEMULQTY
*M.NOTES=FMT({NOTES},"T#30") ; P.NOTES=1 ; C.NOTES=7
M.NOTES={NOTES} ; P.NOTES=1 ; C.NOTES=7
convert @tm to ' ' in M.NOTES
* 
* INITIALIZE TEXT BREAK CHECK VARIABLE(S)
* 
S.NOTES = M.NOTES
S.STARTULDATE={START_DATE}
I.STARTULDATE=S.STARTULDATE
S.STARTULTIME={START_TIME}
I.STARTULTIME=S.STARTULTIME
S.ELAPSEDULHOURS={ELAPSED_HOURS}
I.ELAPSEDULHOURS=S.ELAPSEDULHOURS
* 
PREVIOUS.MARK.LEVEL=0
* 
* TEST FOR CONTROL BREAK(S)
* 
IF (S.REACTOR NE PREV.REACTOR) OR REACTOR.BREAK THEN
REACTOR=PREV.REACTOR
PREV.REACTOR=S.REACTOR
REACTOR.BREAK+=1
REACTULAREAULDESC.BREAK=3
REACTULPROBULDESC.BREAK=3
REACTULSERVULDESC.BREAK=3
END
* 
IF (S.REACTULAREAULDESC NE PREV.REACTULAREAULDESC) OR REACTULAREAULDESC.BREAK THEN
REACTULAREAULDESC=PREV.REACTULAREAULDESC
PREV.REACTULAREAULDESC=S.REACTULAREAULDESC
REACTULAREAULDESC.BREAK+=1
REACTULPROBULDESC.BREAK=3
REACTULSERVULDESC.BREAK=3
END
* 
IF (S.REACTULPROBULDESC NE PREV.REACTULPROBULDESC) OR REACTULPROBULDESC.BREAK THEN
REACTULPROBULDESC=PREV.REACTULPROBULDESC
PREV.REACTULPROBULDESC=S.REACTULPROBULDESC
REACTULPROBULDESC.BREAK+=1
REACTULSERVULDESC.BREAK=3
END
* 
IF (S.REACTULSERVULDESC NE PREV.REACTULSERVULDESC) OR REACTULSERVULDESC.BREAK THEN
REACTULSERVULDESC=PREV.REACTULSERVULDESC
PREV.REACTULSERVULDESC=S.REACTULSERVULDESC
REACTULSERVULDESC.BREAK+=1
END
* 
* 
IF FIRST.PASS THEN
FIRST.PASS=0
GOTO DETAIL
END
* 
* 
! 
BREAKS:
! 
* 
* PRINT BREAK TOTAL(S) AND ACCUMULATE TOTAL(S)
* 
* 
IF REACTULSERVULDESC.BREAK THEN
Void = set_printer('TEXT', '')
PRINTLINE = "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "***":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= OCONV(ELAPSEDULHOURS.REACTULSERVULDESC.TOTAL ,"MD2")
TableColInfo = '>+547':@vm:'<+1440':@vm:'<+2074':@vm:'<+2074':@vm:'<+1080':@vm:'<+2074':@vm:'>+720':@vm
TableColInfo:= '<+2520':@vm:'<+720':@vm:'<+720':@vm:'>+720'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 

* 
ELAPSEDULHOURS.REACTULPROBULDESC.TOTAL+=ELAPSEDULHOURS.REACTULSERVULDESC.TOTAL
ELAPSEDULHOURS.REACTULSERVULDESC.TOTAL=0
ELAPSEDULHOURS.REACTULPROBULDESC.COUNT+=ELAPSEDULHOURS.REACTULSERVULDESC.COUNT
ELAPSEDULHOURS.REACTULSERVULDESC.COUNT=0
END
* 
IF REACTULPROBULDESC.BREAK THEN
Void = set_printer( 'TEXT', '' )
PRINTLINE = '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= "***":@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= OCONV(ELAPSEDULHOURS.REACTULPROBULDESC.TOTAL ,"MD2"):@vm
TableColInfo = '>+547':@vm:'<+1440':@vm:'<+2074':@vm:'<+2074':@vm:'<+1080':@vm:'<+2074':@vm:'>+720':@vm
TableColInfo:= '<+2520':@vm:'<+720':@vm:'<+720':@vm:'>+720'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 

* 
ELAPSEDULHOURS.REACTULAREAULDESC.TOTAL+=ELAPSEDULHOURS.REACTULPROBULDESC.TOTAL
ELAPSEDULHOURS.REACTULPROBULDESC.TOTAL=0
ELAPSEDULHOURS.REACTULAREAULDESC.COUNT+=ELAPSEDULHOURS.REACTULPROBULDESC.COUNT
ELAPSEDULHOURS.REACTULPROBULDESC.COUNT=0
END
* 
IF REACTULAREAULDESC.BREAK THEN
Void = set_printer( 'TEXT', '' )
PRINTLINE = '':@vm
PRINTLINE:= "***":@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= OCONV(ELAPSEDULHOURS.REACTULAREAULDESC.TOTAL ,"MD2"):@vm
TableColInfo = '>+547':@vm:'<+1440':@vm:'<+2074':@vm:'<+2074':@vm:'<+1080':@vm:'<+2074':@vm:'>+720':@vm
TableColInfo:= '<+2520':@vm:'<+720':@vm:'<+720':@vm:'>+720'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 

* 
ELAPSEDULHOURS.REACTOR.TOTAL+=ELAPSEDULHOURS.REACTULAREAULDESC.TOTAL
ELAPSEDULHOURS.REACTULAREAULDESC.TOTAL=0
ELAPSEDULHOURS.REACTOR.COUNT+=ELAPSEDULHOURS.REACTULAREAULDESC.COUNT
ELAPSEDULHOURS.REACTULAREAULDESC.COUNT=0
END
* 
IF REACTOR.BREAK THEN
Void = set_printer( 'TEXT', '' )
PRINTLINE = OCONV(REACTOR,"MD0"):@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= OCONV(ELAPSEDULHOURS.REACTOR.TOTAL ,"MD2")
TableColInfo = '>+547':@vm:'<+1440':@vm:'<+2074':@vm:'<+2074':@vm:'<+1080':@vm:'<+2074':@vm:'>+720':@vm
TableColInfo:= '<+2520':@vm:'<+720':@vm:'<+720':@vm:'>+720'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 

* 
ELAPSEDULHOURS.GRAND.TOTAL+=ELAPSEDULHOURS.REACTOR.TOTAL
ELAPSEDULHOURS.REACTOR.TOTAL=0
ELAPSEDULHOURS.GRAND.COUNT+=ELAPSEDULHOURS.REACTOR.COUNT
ELAPSEDULHOURS.REACTOR.COUNT=0
END
* 
* PERFORM LAST RECORD OUTPUT IF DONE
* 
IF LAST.RECORD THEN
Void = set_printer( '', 'TEXT' )
PRINTLINE = "***":@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= OCONV(ELAPSEDULHOURS.GRAND.TOTAL ,"MD2")
TableColInfo = '>+547':@vm:'<+1440':@vm:'<+2074':@vm:'<+2074':@vm:'<+1080':@vm:'<+2074':@vm:'>+720':@vm
TableColInfo:= '<+2520':@vm:'<+720':@vm:'<+720':@vm:'>+720'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 

* PRINT
* @ANS=@RECCOUNT
* PRINT {RLIST_TEXT_1}
IF READERR THEN
@ANS=READERR
Void = set_printer('TEXT', {RLIST_TEXT_3})
END
RETURN
END
* 
! 
DETAIL:
! 
* 
* REMOVE APPROPRIATE VALUE FROM MULTI-VALUED COLUMN(S)
* 
NEW.MARK.LEVEL=0
* 
IF C.REACTULITEMULIDS GE PREVIOUS.MARK.LEVEL THEN
REMOVE I.REACTULITEMULIDS FROM M.REACTULITEMULIDS AT P.REACTULITEMULIDS SETTING C.REACTULITEMULIDS
S.REACTULITEMULIDS=I.REACTULITEMULIDS
END
IF C.REACTULITEMULIDS GT NEW.MARK.LEVEL THEN NEW.MARK.LEVEL=C.REACTULITEMULIDS
IF C.REACTULITEMSULDESC GE PREVIOUS.MARK.LEVEL THEN
REMOVE I.REACTULITEMSULDESC FROM M.REACTULITEMSULDESC AT P.REACTULITEMSULDESC SETTING C.REACTULITEMSULDESC
S.REACTULITEMSULDESC=I.REACTULITEMSULDESC
END
IF C.REACTULITEMSULDESC GT NEW.MARK.LEVEL THEN NEW.MARK.LEVEL=C.REACTULITEMSULDESC
IF C.REACTULITEMULQTY GE PREVIOUS.MARK.LEVEL THEN
REMOVE I.REACTULITEMULQTY FROM M.REACTULITEMULQTY AT P.REACTULITEMULQTY SETTING C.REACTULITEMULQTY
S.REACTULITEMULQTY=I.REACTULITEMULQTY
END
IF C.REACTULITEMULQTY GT NEW.MARK.LEVEL THEN NEW.MARK.LEVEL=C.REACTULITEMULQTY
IF C.NOTES GE PREVIOUS.MARK.LEVEL THEN
REMOVE I.NOTES FROM M.NOTES AT P.NOTES SETTING C.NOTES
S.NOTES=I.NOTES
END
IF C.NOTES GT NEW.MARK.LEVEL THEN NEW.MARK.LEVEL=C.NOTES
* 
* DO CONVERSIONS IF ANY
* 
IF S.REACTOR NE "" THEN S.REACTOR=OCONV(S.REACTOR,"MD0")
IF S.REACTULITEMULQTY NE "" THEN S.REACTULITEMULQTY=OCONV(S.REACTULITEMULQTY,"MD0")
IF S.STARTULDATE NE "" THEN S.STARTULDATE=OCONV(S.STARTULDATE,"D2/")
IF S.STARTULTIME NE "" THEN S.STARTULTIME=OCONV(S.STARTULTIME,"MTH")
IF S.ELAPSEDULHOURS NE "" THEN S.ELAPSEDULHOURS=OCONV(S.ELAPSEDULHOURS,"MD2")
* 
* ACCUMULATE TOTAL(S)
* 
IF NUM(I.ELAPSEDULHOURS) AND I.ELAPSEDULHOURS NE "" THEN
ELAPSEDULHOURS.REACTULSERVULDESC.TOTAL+=I.ELAPSEDULHOURS
ELAPSEDULHOURS.REACTULSERVULDESC.COUNT+=1
I.ELAPSEDULHOURS=''
END
* 
* PRINT DETAIL LINE
* 
if Summary else
	PRINTLINE =  S.REACTOR:@vm
	PRINTLINE:=  S.REACTULAREAULDESC:@vm
	PRINTLINE:=  S.REACTULPROBULDESC:@vm
	PRINTLINE:=  S.REACTULSERVULDESC:@vm
	PRINTLINE:=  S.REACTULITEMULIDS:@vm
	PRINTLINE:=  S.REACTULITEMSULDESC:@vm
	PRINTLINE:=  S.REACTULITEMULQTY:@vm
	PRINTLINE:=  S.NOTES:@vm
	PRINTLINE:=  S.STARTULDATE:@vm
	PRINTLINE:=  S.STARTULTIME:@vm
	PRINTLINE:=  S.ELAPSEDULHOURS:@vm
    TableColInfo = '>+547':@vm:'<+1440':@vm:'<+2074':@vm:'<+2074':@vm:'<+1080':@vm:'<+2074':@vm:'>+720':@vm
    TableColInfo:= '<+2520':@vm:'<+720':@vm:'<+720':@vm:'>+720'
    Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 
end
* 
IF NEW.MARK.LEVEL THEN
S.REACTOR=''
S.REACTULAREAULDESC=''
S.REACTULPROBULDESC=''
S.REACTULSERVULDESC=''
S.REACTULITEMULIDS=''
S.REACTULITEMSULDESC=''
S.REACTULITEMULQTY=''
S.NOTES=''
S.STARTULDATE=''
S.STARTULTIME=''
S.ELAPSEDULHOURS=''
PREVIOUS.MARK.LEVEL=NEW.MARK.LEVEL
GOTO DETAIL
END
* 
GOTO READRECORD
* 
END

