          PH.ARGS DRPT,BR,BRCHS,SD,ED,SEL.UID,SEL.ORD,SEL.PAT
** Version# 12.0002[6] - 07/03/2012 - 02:03pm - TSMITH - eclipse
*** V12.0002 Change - Custom Coding . - 07/03/2012 - TSMITH - eclipse
** Copied from BP SOE.PHR.LEDGER.LOG Version# 12 - 02/22/2002 - 04:08pm - KEITHS - develop

*** Subroutine : SOE.PHR.LEDGER.LOG
*-------------------------------------------------------------------------*
*** Order Change Log Report.  Displays certain change log entries that
*** meet designated selection criteria.
*-------------------------------------------------------------------------*
*** Parameters:
***       DRPT      - Report printing options                         (IN)
***       BR        - Literal response to branch prompt               [IN]
***       BRCHS     - Branch(es)                                      [IN]
***       SD        - Start Date                                      [IN]
***       ED        - End Date                                        [IN]
***       SEL.UID   - Select User Id                                  (IN)
***       SEL.ORD   - Select Type:  Sales, Transfers, Purchase, ALL   [IN]
***       SEL.PAT   - Enter string to select by: Any log entry containing
***                   this string will be selected.                   (IN)
*-------------------------------------------------------------------------*
*** Common Variables Used:  DRPT
*-------------------------------------------------------------------------*
          BRS = CHANGE(BRCHS,VM,',')

          OK   = 0
          SDT  = OCONV(SD,'D4/')
          EDT  = OCONV(ED,'D4/')
          SEL.PAT = OCONV(SEL.PAT,'MCU')
          SEL.ORD = SEL.ORD[1,1]

          BEGIN CASE
             CASE SEL.ORD = 'A'
                HD.ORD = 'All Orders'
             CASE SEL.ORD = 'S'
                HD.ORD = 'Sales Orders'
             CASE SEL.ORD = 'T'
                HD.ORD = 'Transfer Orders'
             CASE SEL.ORD = 'P'
                HD.ORD = 'Purchase Orders'
          END CASE

          UT.TEMPFILE.CREATE FLNM.ID,TEMPFILE

          UT.PH.MSG 'Selecting ....'
          GOSUB SEL.IDS

          UT.PH.MSG 'Spooling...'
*-------------------------------------------------------------------------*
          HDG = 'Order Change Log Report for ':SDT:' to ':EDT
          HDG = HDG"L#60":'  Page :^#####'
          HDG<1,2> = 'Slct User : ':SEL.UID:' - Slct Pattern : ':SEL.PAT:' - Order Type : ':HD.ORD
          BRANCH.ALLOW = 109
          IF LEN(BRS) > BRANCH.ALLOW THEN BRS = BRS[1,BRANCH.ALLOW]:'...'
          HDG<1,3> = "Branches:  ":BRS
          HDG<1,4> = "Date....  Time....  User ID.  Order#....  Comment...   Name......................."

          IF DRPT<33> = '' THEN
             TITLE = 'Order Change Log Report for ':SDT:' to ':EDT
          END ELSE
             TITLE = DRPT<33>:'  ':SDT:' to ':EDT
          END
          PRINTER.ON 120,TITLE,DOC.ID,HDG,RPT.DFLT=DRPT

          SSELECT TEMPFILE

          LOOP
          READNEXT ID ELSE EXIT
          GOSUB PRT.ONE
          REPEAT

          PRINTER.OFF DOC.ID

          UT.PH.CLEANUP FLNM.ID
          SEND.MESSAGE 'Phantom',USER.ID,TITLE:' is Complete'

          STOP
*-------------------------------------------------------------------------*
PRT.ONE:  READ WRK FROM TEMPFILE,ID ELSE WRK = ''

          PRINT OCONV(WRK<1,2>,'D2/')                  "L#8":'  ':
          PRINT OCONV(WRK<1,3>,'MTS')                  "L#8":'  ':
          PRINT WRK<1,4>                               "L#8":'  ':
          PRINT FIELD(ID,'~',2)                        "L#10":'  ':
          PRINT FIELD(WRK<1,6,1>,' ',1)                "L#10":'   ':
          PRINT TRANS('ENTITY',TRANS('LEDGER',FIELD(ID,'~',2),1,'X'),1,'X')<1,1,1>



          CT = DCOUNT(WRK<1,6>,SVM)
          FOR J = 2 TO CT
          PRINT SPACE(40):
          PRINT WRK<1,6,J>                             "L#40"
          NEXT J

          RETURN
*-------------------------------------------------------------------------*
SEL.IDS:  *
          IF SEL.ORD = 'A' THEN  O.SLCT = '"S]" "T]" "P]"'
          ELSE                   O.SLCT = '"':SEL.ORD:']"'

          EXECUTE 'SELECT LEDGER.LOG WITH @ID ':O.SLCT CAPTURING MSG

          LOOP
          READNEXT OID ELSE EXIT
          MATREAD LED FROM LEDFILE, OID ELSE MAT LED = ""
          IF BR # "ALL" THEN
             OK = 0
             NUM.GENS = DCOUNT(LED(12),@VM)
             FOR GEN = 1 TO NUM.GENS
             PRC.BR = LED(2)<1,GEN,1>
             LOCATE PRC.BR IN BRCHS<1> SETTING POS THEN
                OK = 1
                GEN = NUM.GENS
             END
             NEXT GEN
             IF NOT(OK) THEN GOTO SKIPID
          END
          READV WRK FROM LEDLFILE,OID,10 ELSE WRK = ''
          WRK = RAISE(WRK)
          CT  = DCOUNT(WRK,AM)
          FOR K = 1 TO CT
          DT = WRK<K,2>
          IF DT < SD OR DT > ED                        THEN GOTO SKIPCMT
          IF SEL.UID THEN IF SEL.UID # WRK<K,4>        THEN GOTO SKIPCMT
          IF SEL.PAT THEN
             CMT = OCONV(WRK<K,6>,'MCU')
             IF NOT(INDEX(TRIM(CMT),TRIM(SEL.PAT),1))  THEN GOTO SKIPCMT
             END
          WRITE WRK<K> ON TEMPFILE,DT"R%5":WRK<K,3>"R%5":'~':OID:'~':K
SKIPCMT:  NEXT K
SKIPID:   REPEAT

          RETURN
!TSMITH~07/03/12~14:03
