compile subroutine car_rpt1_prn( IssueDateFrom, IssueDateThru )
! 
* LIST CAR ID-SUPP SEQ JUSTLEN '5' COLHEAD 'CAR#' CUST_CITY JUSTLEN '50' CONTACT_NAME WO COMPLAINT_TYPE JUSTLEN '30' EST_LOSS_VALUE ACT_LOSS_VALUE  HEADING " Customer Advisories by Customer by Issue Date 'T' PAGE # 'P' by selected Issue dates from (2/1/98) Thru (3/13/98 ) "
! 
*PRINTER ON
* 
* HEADING/FOOTING
declare function set_printer, MSG
Font = 'Courier New,8,L,0'
convert ',' to @fm in Font
HeadPos = '.5,3,1.5,.75,1.8,.75,1,1'
convert ',' to @fm in HeadPos
TheHeader = " Customer Advisories by Customer by Issue Date 'T' PAGE # 'P' by selected issue dates from (":oconv(IssueDateFrom, 'D2/'):") Thru (":oconv(IssueDateThru, 'D2/' ):')':@fm
ColHeader = "Car#" : @vm : "Customer/City" : @vm : "Contact Name" : @vm : "WO" : @vm : "Complaint Type" : @vm : "Issue" : @vm : "Estimated" : @vm : "Actual"
ColHeader<-1> = "" : @vm : "" : @vm : "" : @vm : "" : @vm : "" : @vm : "Date" : @vm : "Loss Value" : @vm : "Loss Value"
Tvar = str( '_', 7):@vm:str( '_', 42):@vm:str( '_', 30):@vm:str( '_', 14):@vm
Tvar:= str( '_',30 ):@vm:str( '_', 12 ):@vm:str( '_', 15):@vm:str( '_', 15 )
*COLHEADER = ''
ColHeader<-1> = Tvar
*TheHeader = ''
Void = set_printer( 'FONTHEADFOOT', Font )
Void = set_printer( 'HEADER', TheHeader, HeadPos, ColHeader )
Void = set_printer( 'FONT', Font )

*FOOTING ""
* 
@RECCOUNT=0
FIRST.PASS=1
LAST.RECORD=0
READERR=0
* 
* OPEN DICT AND DATA FILES
* 
OPEN "DICT","CAR" TO @DICT ELSE return
OPEN "","CAR" TO FILE.IN ELSE return
* 
* MAKE COLUMN HEADING
*
* 
* ZERO ACCUMULATORS FOR EACH BREAK
* 
ESTULLOSSULVALUE.GRAND.TOTAL=0
ESTULLOSSULVALUE.GRAND.COUNT=0
* 
ACTULLOSSULVALUE.GRAND.TOTAL=0
ACTULLOSSULVALUE.GRAND.COUNT=0
* 
! 
READRECORD:
! 
* 
* 
@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
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.SEQ={SEQ}
I.SEQ=S.SEQ
S.CUSTULCITY={CUST_CITY}
I.CUSTULCITY=S.CUSTULCITY
S.CONTACTULNAME={CONTACT_NAME}
I.CONTACTULNAME=S.CONTACTULNAME
S.WO={WO}
I.WO=S.WO
S.COMPLAINTULTYPE={COMPLAINT_TYPE}
I.COMPLAINTULTYPE=S.COMPLAINTULTYPE
S.ISSUEDATE={ISSUE_DATE}
I.ISSUEDATE=S.ISSUEDATE
S.ESTULLOSSULVALUE={EST_LOSS_VALUE}
I.ESTULLOSSULVALUE=S.ESTULLOSSULVALUE
S.ACTULLOSSULVALUE={ACT_LOSS_VALUE}
I.ACTULLOSSULVALUE=S.ACTULLOSSULVALUE
* 
* 
IF FIRST.PASS THEN
FIRST.PASS=0
GOTO DETAIL
END
* 
* 
! 
BREAKS:
! 
* 
* 
* PERFORM LAST RECORD OUTPUT IF DONE
* 
IF LAST.RECORD THEN
PRINTLINE = "***":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= "":@vm
PRINTLINE:= OCONV(ESTULLOSSULVALUE.GRAND.TOTAL ,"MD2,$"):@vm
PRINTLINE:= OCONV(ACTULLOSSULVALUE.GRAND.TOTAL ,"MD2,$"):@vm
TableColInfo = '>+720':@vm:'<+4320':@vm:'<+2160':@vm:'>+1080':@vm:'<+2592':@vm:'>+1080':@vm:'>+1440':@vm:'>+1440'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 
* PRINT
* @ANS=@REC.COUNT
* PRINT {RLIST_TEXT_1}
IF READERR THEN
@ANS=READERR
Void = set_printer( 'TEXT', {RLIST_TEXT_3} )
END
return
END
* 
! 
DETAIL:
! 
* 
* DO CONVERSIONS IF ANY
* 
IF S.SEQ NE "" THEN S.SEQ=OCONV(S.SEQ,"MD0")
IF S.WO NE "" THEN S.WO=OCONV(S.WO,"MD0")
IF S.ISSUEDATE NE "" THEN S.ISSUEDATE=OCONV(S.ISSUEDATE,"D2/")
IF S.ESTULLOSSULVALUE NE "" THEN S.ESTULLOSSULVALUE=OCONV(S.ESTULLOSSULVALUE,"MD2,$")
IF S.ACTULLOSSULVALUE NE "" THEN S.ACTULLOSSULVALUE=OCONV(S.ACTULLOSSULVALUE,"MD2,$")
*
* 
* ACCUMULATE TOTAL(S)
* 
IF NUM(I.ESTULLOSSULVALUE) AND I.ESTULLOSSULVALUE NE "" THEN
ESTULLOSSULVALUE.GRAND.TOTAL+=I.ESTULLOSSULVALUE
ESTULLOSSULVALUE.GRAND.COUNT+=1
I.ESTULLOSSULVALUE=''
END
IF NUM(I.ACTULLOSSULVALUE) AND I.ACTULLOSSULVALUE NE "" THEN
ACTULLOSSULVALUE.GRAND.TOTAL+=I.ACTULLOSSULVALUE
ACTULLOSSULVALUE.GRAND.COUNT+=1
I.ACTULLOSSULVALUE=''
END
* 
 
* PRINT DETAIL LINE
* 
PRINTLINE =  S.SEQ:@vm
PRINTLINE:=  S.CUSTULCITY:@vm
PRINTLINE:=  S.CONTACTULNAME:@vm
PRINTLINE:=  S.WO:@vm
PRINTLINE:=  S.COMPLAINTULTYPE:@vm
PRINTLINE:=  S.ISSUEDATE:@vm
PRINTLINE:=  S.ESTULLOSSULVALUE:@vm
PRINTLINE:=  S.ACTULLOSSULVALUE
TableColInfo = '>+720':@vm:'<+4320':@vm:'<+2160':@vm:'>+1080':@vm:'<+2592':@vm:'>+1080':@vm:'>+1440':@vm:'>+1440'
Void = set_printer( 'ADDTABLE', TableColInfo, '', PRINTLINE, '', '', 1, TB_NONE ) 
* 
* 
GOTO READRECORD
* 
END

