SUBROUTINE REACTOR_LOG_RPT1_PRN( FromDate, ThruDate )
! 
* LIST REACTOR_LOG  ID-SUPP BREAK-ON REACTOR "'V'" JUSTLEN 5 BREAK-ON CATEGORY "'V'" JUSTLEN 11 BREAK-ON SERVICE "'V'" JUSTLEN 13 NOTES START_DATE JUSTLEN 10 START_TIME JUSTLEN 10 END_DATE JUSTLEN 8 END_TIME JUSTLEN 8 TOTAL ELAPSED_HOURS JUSTLEN 7 COLHEAD 'Hours' HEADING " Run Date: 'TS39'Page 'P''LS22'Reactor Log Report 03/11/96 To 03/11/96"
! 
*PRINTER ON
declare function set_printer
* IF THIS CODE IS EVER USED, IT MUST CHANGE TO USE THE ADDTABLE OIPI CALLING METHOD
* 
* HEADING/FOOTING
TheHeader = " Reactor Log Report 'T' PAGE # 'P' "
if FromDate or  ThruDate then
    TheHeader := "for Selected Dates From (":oconv( FromDate, 'D2/' ):") Thru (":oconv( ThruDate, 'D2/' ):")"
end
ColHeader = "React" : @vm : "Category" : @vm : "Service" : @vm : "Notes" : @vm : "Start Date": @vm:"Start Time":@vm:"End Date":@vm:"End Time":@vm:"Hours"
ColHeader<-1> = str( '-', 5 ):@vm:str( '-', 13 ):@vm:str( '-', 20 ):@vm:str( '-', 22 ):@vm:str( '-', 10 ):@vm:str( '-', 10):@vm:str( '-', 10 ):@vm:str( '-', 10 ):@vm:str( '-', 10 )
HeadPos   = '.5,1,1.25,2,1.06,1.06,1,1,1'
convert ',' to @fm in HeadPos
*FOOTING ""
Void = set_printer( 'FONTHEADFOOT' )
Void = set_printer( 'HEADER', TheHeader, HeadPos, ColHeader )

* 
@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
* 
* ZERO ACCUMULATORS FOR EACH BREAK
* 
ELAPSEDULHOURS.REACTOR.TOTAL=0
ELAPSEDULHOURS.REACTOR.COUNT=0
ELAPSEDULHOURS.CATEGORY.TOTAL=0
ELAPSEDULHOURS.CATEGORY.COUNT=0
ELAPSEDULHOURS.SERVICE.TOTAL=0
ELAPSEDULHOURS.SERVICE.COUNT=0
ELAPSEDULHOURS.GRAND.TOTAL=0
ELAPSEDULHOURS.GRAND.COUNT=0
* 
* NULL PREVIOUS BREAK BUCKETS
* 
PREV.REACTOR=''
LAST.REACTOR.BREAK = 1
PREV.CATEGORY=''
LAST.CATEGORY.BREAK = 1
PREV.SERVICE=''
LAST.SERVICE.BREAK = 1
* 
! 
READRECORD:
! 
* 
* 
* ZERO BREAK FLAGS TO FALSE
* 
REACTOR.BREAK=0
CATEGORY.BREAK=0
SERVICE.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
Viod = 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
CATEGORY.BREAK=1
CATEGORY=PREV.CATEGORY
SERVICE.BREAK=1
SERVICE=PREV.SERVICE
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.CATEGORY={CATEGORY}
I.CATEGORY=S.CATEGORY
S.SERVICE={SERVICE}
I.SERVICE=S.SERVICE
*M.NOTES=FMT({NOTES},"T#20") ; 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.ENDULDATE={END_DATE}
I.ENDULDATE=S.ENDULDATE
S.ENDULTIME={END_TIME}
I.ENDULTIME=S.ENDULTIME
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
CATEGORY.BREAK=3
SERVICE.BREAK=3
END
* 
IF (S.CATEGORY NE PREV.CATEGORY) OR CATEGORY.BREAK THEN
CATEGORY=PREV.CATEGORY
PREV.CATEGORY=S.CATEGORY
CATEGORY.BREAK+=1
SERVICE.BREAK=3
END
* 
IF (S.SERVICE NE PREV.SERVICE) OR SERVICE.BREAK THEN
SERVICE=PREV.SERVICE
PREV.SERVICE=S.SERVICE
SERVICE.BREAK+=1
END
* 
* 
IF FIRST.PASS THEN
FIRST.PASS=0
GOTO DETAIL
END
* 
* 
! 
BREAKS:
! 
* 
* PRINT BREAK TOTAL(S) AND ACCUMULATE TOTAL(S)
* 
* 
IF SERVICE.BREAK THEN
Void = set_printer( 'TEXT', '' )
PRINTLINE = '':@vm
PRINTLINE:= '':@vm
PRINTLINE:=SERVICE:@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= fmt( OCONV(ELAPSEDULHOURS.SERVICE.TOTAL ,"MD2"), "R#9" )
Void = set_printer( 'TEXTCOL', PRINTLINE )
Void = set_printer( 'TEXT', '' )
* 
ELAPSEDULHOURS.CATEGORY.TOTAL+=ELAPSEDULHOURS.SERVICE.TOTAL
ELAPSEDULHOURS.SERVICE.TOTAL=0
ELAPSEDULHOURS.CATEGORY.COUNT+=ELAPSEDULHOURS.SERVICE.COUNT
ELAPSEDULHOURS.SERVICE.COUNT=0
END
* 
IF CATEGORY.BREAK THEN
Void = set_printer( 'TEXT', '' )
PRINTLINE = '':@vm
PRINTLINE:=OCONV(CATEGORY,"[REACT_LOG_CAT_CONV]"):@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= fmt( OCONV(ELAPSEDULHOURS.CATEGORY.TOTAL ,"MD2"), "R#9" )
Void = set_printer( 'TEXTCOL', PRINTLINE )
Void = set_printer( 'TEXT', '' )
* 
ELAPSEDULHOURS.REACTOR.TOTAL+=ELAPSEDULHOURS.CATEGORY.TOTAL
ELAPSEDULHOURS.CATEGORY.TOTAL=0
ELAPSEDULHOURS.REACTOR.COUNT+=ELAPSEDULHOURS.CATEGORY.COUNT
ELAPSEDULHOURS.CATEGORY.COUNT=0
END
* 
IF REACTOR.BREAK THEN
Void = set_printer( 'TEXT', '' )
PRINTLINE = REACTOR:@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= '':@vm
PRINTLINE:= fmt( OCONV(ELAPSEDULHOURS.REACTOR.TOTAL ,"MD2"), "R#9" )
Void = set_printer( 'TEXTCOL', PRINTLINE )
Void = set_printer( 'TEXT', '' )
* 
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:= fmt( OCONV(ELAPSEDULHOURS.GRAND.TOTAL ,"MD2"), "R#9" )
Void = set_printer( 'TEXTCOL', PRINTLINE )
Void = set_printer( 'TEXT', '' )
* 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.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.CATEGORY NE "" THEN S.CATEGORY=OCONV(S.CATEGORY,"[REACT_LOG_CAT_CONV]")
IF S.STARTULDATE NE "" THEN S.STARTULDATE=OCONV(S.STARTULDATE,"D2/")
IF S.STARTULTIME NE "" THEN S.STARTULTIME=OCONV(S.STARTULTIME,"MTH")
IF S.ENDULDATE NE "" THEN S.ENDULDATE=OCONV(S.ENDULDATE,"D2/")
IF S.ENDULTIME NE "" THEN S.ENDULTIME=OCONV(S.ENDULTIME,"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.SERVICE.TOTAL+=I.ELAPSEDULHOURS
ELAPSEDULHOURS.SERVICE.COUNT+=1
I.ELAPSEDULHOURS=''
END
* 
* PRINT DETAIL LINE
* 
PRINTLINE =  S.REACTOR:@vm
PRINTLINE:= S.CATEGORY:@vm
PRINTLINE:= S.SERVICE:@vm
PRINTLINE:= S.NOTES:@vm
PRINTLINE:= S.STARTULDATE:@vm
PRINTLINE:= S.STARTULTIME:@vm
PRINTLINE:= S.ENDULDATE:@vm
PRINTLINE:= S.ENDULTIME:@vm
PRINTLINE:= fmt( S.ELAPSEDULHOURS, "R#9" )
Void = set_printer( 'TEXTCOL', PRINTLINE )
Void = set_printer( 'TEXT', '' )
* 
IF NEW.MARK.LEVEL THEN
S.REACTOR=''
S.CATEGORY=''
S.SERVICE=''
S.NOTES=''
S.STARTULDATE=''
S.STARTULTIME=''
S.ENDULDATE=''
S.ENDULTIME=''
S.ELAPSEDULHOURS=''
PREVIOUS.MARK.LEVEL=NEW.MARK.LEVEL
GOTO DETAIL
END
* 
GOTO READRECORD
* 
END

