          SUBROUTINE (TID,TREC,RPT.VALS,COL.RECORD,OPEN.AMT)
** Version# 7.0001[1] - 08/11/2011 - 02:53pm - SMITJR - eclipse

*** Subroutine: AR.AGING.PRINT.SUMMARY
*-------------------------------------------------------------------------*
*** Routine to print a sinlge summary AR Aging line for a single customer
*-------------------------------------------------------------------------*
*** TID      - Record from tempfile which contains summary totals      [IN]
*** TREC     - Temp file record containing aging for a single customer [IN]
*** RPT.VALS - Sort options                                            [IN]
*** COL.RECORD - Report column data                                    [IN]
*** OPEN.AMT   - Open order amount                                     [IN]
*-------------------------------------------------------------------------*
*** Common Variables: None Used
*-------------------------------------------------------------------------*
          CURR.FLG = RPT.VALS<1,1>
          XCURR    = RPT.VALS<1,2>
          LEVEL    = RPT.VALS<2>
          SORT.OPT = RPT.VALS<3>
          AOD      = RPT.VALS<4>

          BT.CN  = FIELD(TID,'~',2)
          ST.CN  = FIELD(TID,'~',4)
          ST.INDEX = TRANS('ENTITY',ST.CN,9,'X')
          IF LEVEL[1,1] = 'S' THEN CN = ST.CN ELSE CN = BT.CN

          HB  = TREC<13>
          SBR = TREC<14>

          BEGIN CASE
          CASE SORT.OPT = 9;  SORT.BR = HB
          CASE SORT.OPT = 10; SORT.BR = SBR
          CASE OTHERWISE;     SORT.BR = ''
          END CASE

          READV CUS.NAME FROM CUSFILE,CN,1 ELSE CUS.NAME = ''

          STOTALS     = ''
          STOTALS<1>  = OCONV(TREC<3>,'MR2')     ;* Future
          STOTALS<2>  = OCONV(TREC<4>,'MR2')     ;* Current
          STOTALS<3>  = OCONV(TREC<5>,'MR2')     ;* 31-60
          STOTALS<4>  = OCONV(TREC<6>,'MR2')     ;* 61-90
          STOTALS<5>  = OCONV(TREC<7>,'MR2')     ;* 91-120
          STOTALS<6>  = OCONV(TREC<8>,'MR2')     ;* Over 120
          STOTALS<7>  = OCONV(TREC<9>,'MR2')     ;* Deposits
          STOTALS<8>  = OCONV(SUMMATION(TREC[AM,3,7]),'MR2')  ;* Balance
          STOTALS<9>  = OCONV(TREC<10>,'D4/')    ;* Last Pmt Dt
          STOTALS<10> = OCONV(TREC<11>,'MR2')    ;* Last Pmt Amt
          STOTALS<12> = HB                       ;* Home Br
          STOTALS<13> = SBR                      ;* Sale Br
          STOTALS<14> = TREC<15>                 ;* Terms

          * Determine if open amount column is being included on the
          * report before deciding to calculate it
          REPCOLS = COL.RECORD<1>
          LOCATE '17' IN REPCOLS<1> SETTING VPOS THEN NEED.OPEN=YES ELSE
             NEED.OPEN = NO
          END

          IF NEED.OPEN THEN
             IF LEVEL[1,1] # 'B' THEN OP.CN = ST.CN ELSE OP.CN = BT.CN
             * Get open order total for current ship-to customer only
             OPEN.ORDER.AMT OPEN.AMT,OP.CN:AM:OP.CN,,,,SORT.BR
          END ELSE OPEN.AMT = 0

          STOTALS<17> = OCONV(OPEN.AMT,'MR2')    ;* Open order amount

          PRE.STR  =  '&':CN  "L#6":' '
          PRE.STR :=  ST.INDEX  "L#34"
          REPORT.LAYOUT.V.PRINT.STR STOTALS,'',COL.RECORD,'',PRE.STR
          PRINT PRE.STR:'  ':

          * Phone Number
          READV CUS.PHONE FROM CUSFILE,CN,17 ELSE CUS.PHONE = ''
          PRINT CUS.PHONE<1,1> "L#14"
          RETURN
*-------------------------------------------------------------------------*
!SMITJR~08/11/11~14:53
