          SUBROUTINE  (TYPE)
** Version# 61.0002[7] - 03/05/2010 - 10:29pm - SMITJR - eclipse
*** V61.0002 Change - Custom Coding 15404~ - 03/05/2010 - SMITJR - eclipse
** Copied from BP JOB.TRACKING.VIEW Version# 61 - 11/20/2007 - 03:32pm - ZACHW - main
*** Subroutine - JOB.TRACKING.VIEW
*-------------------------------------------------------------------------*
*** This subroutine will allow user to specify an entity and an end date
*** to view all of the job queues for that entity before or equal to that
*** end date.  If entity entered is a customer and that customer is a bill
*** to with more than one ship to, system will prompt if user wants to
*** view trackers pertaining only to the account entered or trackers per-
*** taining to all ship tos associated to that bill to account.
*** We have also added tracker
*** transaction type to the tracking log file and this field will either
*** be MANUAL or SYSTEM.  Manual meaning tracker was manually entered by
*** a user or SYSTEM meaning system generated tracker for some reason.
*** There is a transaction type control record where you can set up to see
*** All, Manual, or System type trackers in this queue.
*-------------------------------------------------------------------------*
*** TYPE -(IN)- specify the type of log you want to view.
*-------------------------------------------------------------------------*
*** COMMON - TIME.ZONE$ - System Time Zone
*-------------------------------------------------------------------------*
          GOSUB INIT

          * Make sure user is authorized to access this info
          CHECK.KEY KEY:'.ACTIVITY.VIEW',ENTRY.OK,LEVEL
          IF NOT(ENTRY.OK) THEN RETURN

          WINDOW SCRN=SCRN
*-------------------------------------------------------------------------*
START1:   *** Full Restart, clear select options
          GOSUB INIT2
*-------------------------------------------------------------------------*
START2:   *** Retain select options and clear screen
          CLEAR.SCREEN
*-------------------------------------------------------------------------*
          IF CHNG.VIEW THEN
             MENU.LOAD 16,21, 3,1,'S'; *Select
          END ELSE
             MENU.LOAD 16,21, 6,1,'S'; *Select
          END
          IN.SCROLL = NO
          IF CN = '' THEN
INP.CN:      INP CN,13,1,35,'TENTITY;X;9;9',V_'S:':VERF.SUB
             REMIND.FLAG = YES
             IF QUIT THEN GOTO FINISH
             IF CN = '' THEN GOTO INP.CN
          END
          BEGIN CASE
          CASE TYPE = 'U'
             PRINT @(13,1):OCONV(CN,'TINITIALS;X;3;3') "L#35"
          CASE TYPE = 'O'
             PRINT @(13,1):CN                          "L#35"
          CASE OTHERWISE
             PRINT @(13,1):OCONV(CN,'TENTITY;X;1;1')   "L#35"
          END CASE
          PRINT @(59,1):OCONV(END.DT,'D4/') "L#10"
          IF NOT(AUTOEXIT) AND FIRST THEN          ;* do not need the date
          END.DT=END.DT
             IF QUIT THEN GOTO FINISH
             IF END.DT = '' THEN END.DT=('MO/DA/YR')
          END
*-------------------------------------------------------------------------*
SKIPIN:   BEGIN CASE
          CASE TYPE = 'U'
             PRINT @(13,1):OCONV(CN,'TINITIALS;X;3;3') "L#35"
          CASE TYPE = 'O'
             PRINT @(13,1):CN                          "L#35"
          CASE OTHERWISE
             PRINT @(13,1):OCONV(CN,'TENTITY;X;1;1')   "L#35"
          END CASE

          ENTS = CN                                    ;* default

          * Get list of the IDs
          GOSUB GET.IDS

START3:   IF IDS = '' THEN IDS = '@@@'
          *** position of current ID in IDS list
          IF FIRST OR NOT(SV.ID) THEN
             LGN = DCOUNT(IDS,AM)
          END ELSE
             LOCATE SV.ID IN IDS SETTING LGN ELSE LGN = DCOUNT(IDS,AM)
          END
          LINE   = 0          ; * current line on the screen
          LN.IDX = ''         ; * each line's info such as ID, line count.

          GOSUB DISPLAY
          FIRST = NO          ;* first time to get in the program

          MENU.CLEAR
          IF CHNG.VIEW THEN
             MENU.LOAD 16,21, 3, 1,'S'; *Select
             MENU.LOAD  2,21, 4, 1,'V'; *View
             MENU.LOAD  9,21, 4, 1,'E'; *Edit
             MENU.LOAD 22,21, 3, 1,'N'; *New
             MENU.LOAD 28,21, 8, 6,'I'; *Edit Item
             MENU.LOAD 39,21, 3, 1,'A'; *Append
             MENU.LOAD 45,21, 6, 2,'X'; *Expand
             MENU.LOAD 54,21, 5, 2,'Y'; *Synop
             MENU.LOAD 62,21, 4, 4,'Q'; *Job Queue
             MENU.LOAD 69,21, 9, 1,'C'; *Change View
          END ELSE
             MENU.LOAD 16,21, 7, 1,'S'; *Select
             MENU.LOAD  2,21, 4, 1,'V'; *View
             MENU.LOAD  9,21, 4, 1,'E'; *Edit
             MENU.LOAD 25,21, 8, 1,'N'; *New
             MENU.LOAD 36,21, 9, 6,'I'; *Edit Item
             MENU.LOAD 48,21, 6, 1,'A'; *Append
             MENU.LOAD 57,21, 6, 2,'X'; *Expand
             MENU.LOAD 66,21, 5, 2,'Y'; *Synop
             MENU.LOAD 74,21, 4, 4,'Q'; *Job Queue
          END

          LINE = 1                            ;* first line on the screen
*-------------------------------------------------------------------------*
          IF REMIND.FLAG  THEN
             REMINDER.VIEW CN,,16,80,23
             REMIND.FLAG = NO
          END
MOVENEXT: PASSER.COM<2> = LN.IDX<LINE,1>
          ACT.ID$       = LN.IDX<LINE,1>
IN$$1:    INP A,27,LINE+2,0
          BEGIN CASE
          CASE QUIT;              GOTO RESTART
          CASE MOVE=1 OR MOVE=3;  GOTO MOVENEXT
          CASE MOVE=2; IF LINE > 1     THEN LINE-=1 ELSE GOSUB UP.ONE
          CASE MOVE>3; IF LINE < SLGTH THEN LINE+=1 ELSE GOSUB DN.ONE
          CASE LASTKEY=12;       GOSUB PG.UP
          CASE LASTKEY=14;       GOSUB PG.DN
          END CASE
          GOTO MOVENEXT
*-------------------------------------------------------------------------*
MOUSE$:   IF NOT(IN.SCROLL) THEN RETURN
*-------------------------------------------------------------------------*
CHECK.MOUSE.POSITION: *** Check where they click and move them to that pos
          NEWX = ''
          NEWY = ''
          GET.MOUSE.POSITION NEWX,NEWY

          *** page up (click above vscroll area)
          IF NEWY <= 3 THEN
             GOSUB PG.UP
             RETURN TO MOVENEXT
          END

          *** page down (click below vscroll area)
          IF NEWY >= 21 THEN
             GOSUB PG.DN
             RETURN TO MOVENEXT
          END

          *** must be a double click
          IF LINE = (NEWY-3) THEN
            GOTO EDITCMT
          END

          SV.LINE = LINE
          IF NEWY > 3 THEN
            LINE = NEWY - 3
          END

          IF LINE < 1 OR LINE > SLGTH THEN LINE = SV.LINE

          RETURN TO MOVENEXT
*-------------------------------------------------------------------------*
PG.UP:    *** one page up
          LINE  = 1                            ;* first line on the screen
          EOF   = NO
          FOR J = 1 TO SLGTH UNTIL EOF         ;* through whole screen
             GOSUB UP.ONE
          NEXT J
          RETURN
*-------------------------------------------------------------------------*
PG.DN:    *** one page down
          LINE  = SLGTH                        ;* last line on the screen
          EOF   = NO
          FOR J = 1 TO SLGTH UNTIL EOF         ;* through whole screen
             GOSUB DN.ONE
          NEXT J
          RETURN
*-------------------------------------------------------------------------*
UP.ONE:   *** up one line

UP.ONE1:  GO.UP = YES

          CMT   = ''
          LOCATE LN.IDX<LINE,1> IN IDS SETTING LGN THEN
             SORT.ID = IDS<LGN>
             *** same tracker use same CMT
             IF SORT.ID = LASTID THEN
                *** skip run GET.ELOG
                CMT = LASTCMT
             END
          END ELSE
             EOF = YES
          END

          LN  = LN.IDX<LINE,2>   ; * last line printed for the tracker

          IF LN<2 THEN
             LGN += 1            ; * next ID in the IDS list
             LN   = ''
             CMT  = ''           ; * need to run GET.ELOG
          END ELSE
             LN  -= 1            ; * go up one line
          END

          *** same tracker use same CMT
          IF CMT # '' THEN GOTO SKIP.GET.ELOG

          GOSUB GET.ELOG

          IF EOF THEN
             PRINT BELL:; RETURN
          END

SKIP.GET.ELOG:

          IF LN = '' THEN
             *** get the last line on the tracker
             LN = DCOUNT(CMT<1>,VM)
          END
          *** scroll down and set first line to null
          SCROLL.DOWN 1,3,78,19,1
          LN.IDX = DELETE(LN.IDX,SLGTH)
          LN.IDX = INSERT(LN.IDX,1;'')
          GOSUB DISP.LN

          RETURN
*-------------------------------------------------------------------------*
DN.ONE:   *** up one line

DN.ONE1:  GO.UP = NO

          LN  = LN.IDX<LINE,2>    ; * last line printed fot the tracker
          LN += 1                 ; * go down one line
          CMT = ''                ; * clear CMT

          LOCATE LN.IDX<LINE,1> IN IDS SETTING LGN THEN
            SORT.ID = IDS<LGN>
            *** same tracker use same CMT
            IF ID = LASTID THEN
               *** skip run GET.ELOG
               CMT = LASTCMT
            END
          END ELSE
            EOF   = YES
          END

          IF CMT # '' THEN GOTO SKIP.GETELOG

REREAD:   GOSUB GET.ELOG

          IF EOF THEN
             PRINT BELL:; RETURN
          END

SKIP.GETELOG:

          IF LN>DCOUNT(CMT<1>,VM) THEN
             LGN  -= 1                ;* next ID in the IDS list
             LN    = 1                ;* first line of the tracker
             GOTO REREAD
          END
          *** scroll up and set last line to null
          SCROLL.UP 1,3,78,19,1
          LN.IDX = DELETE(LN.IDX,1)
          GOSUB DISP.LN

          RETURN
*-------------------------------------------------------------------------*
GET.ELOG: EOF = NO; RETRY = NO
          SORT.ID = IDS<LGN>

          *** If a null tracker ID exists and there are no more trackers
          *** in our selected list, then return here
          IF SORT.ID = '' AND (LGN > ID.CT OR LGN < 1) THEN
             EOF = YES; RETURN
          END
          *** If there are no more valid trackers to fill the screen
          IF LINE > DCOUNT(LN.IDX,AM) THEN EOF = YES; RETURN

          IDTYPE = FIELD(SORT.ID,'~',3)
          ID     = FIELD(SORT.ID,'~',4)
          IF IDTYPE = 'T' THEN
             *** read CMT from TRACKING.LOG
             READ ELOG FROM CLOGFILE,ID ELSE
                IF LGN > ID.CT OR LGN < 1 THEN EOF = YES; RETURN
                RETRY = YES
                ELOG  = ''
             END

             IF DOPT = 1 OR ELOG<58> = '' THEN
                JOB.TRACKING.GET.CMT CMT,ELOG,1,1
             END ELSE
                CMT = ELOG<58>:' ':ELOG<59>
             END
          END ELSE
             *** read CMT from ENTITY.LOG
             READ ELOG FROM ELOGFILE,ID ELSE
                IF LGN > ID.CT OR LGN < 1 THEN EOF = YES; RETURN
                RETRY = YES
                ELOG  = ''
             END
             CMT = ELOG<5>
          END
          *** Make sure this matches the selection criteria
          GOSUB CHK.MATCH
          IF NOT(MATCH.OK) THEN RETRY = YES

          *** If this log isn't good,try and get the next one...
          IF RETRY THEN
             IF GO.UP THEN LGN += 1 ELSE LGN -= 1
             GOTO GET.ELOG
          END

          IF NOT(EXP) THEN CMT = CMT<1,1>  "L#50"   ;* only one line
          IF LEN(CMT) > 50 THEN
             TMP = CMT
             FOLD TMP,50,CMT
          END
          RETURN
*-------------------------------------------------------------------------*
GET.IDS:  *** Get the list of TRACKING.LOG ids to display..
          IDS   = JOB.TRACKING.VIEW.DATA(ENTS,TYPE,TRANS.TYPE,END.DT)
          ID.CT = DCOUNT(IDS,AM)
          RETURN
*-------------------------------------------------------------------------*
CHK.MATCH:*** Check selection criteria from selection hotkey
          *** Returns match.ok flag

          * If the user's authorization level (LEVEL) is less than this
          * trackers authorization level (ELOG<4>) then there is NO MATCH
          * since the user is NOT allowed to view this one.
          IF (LEVEL < ELOG<4>) THEN
             MATCH.OK = NO
             RETURN
          END

          MATCH.OK = YES
          IF NOT(SELS) THEN RETURN

          *** Go check if pattern matches
          GOSUB CHK.PAT
          IF NOT(PAT.OK) THEN MATCH.OK = NO; RETURN

          *** Match Security Level. Type 0-Equals, 1-Not Equals
          LOCATE ELOG<4> IN SEL.LVL<1> SETTING XX THEN
             IF TYPS<2> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<2>) AND SEL.LVL THEN MATCH.OK = NO; RETURN
          END

          *** Match User. Types; 0-Equal To, 1-Not Equal To
          LOCATE OCONV(ELOG<1>,'MCU') IN SEL.USR<1> SETTING XX THEN
             IF TYPS<3> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<3>) AND SEL.USR THEN MATCH.OK = NO; RETURN
          END

          *** Match Security. Type 0-Equals, 1-Not Equals
          LOCATE OCONV(ELOG<6>,'MCU') IN SEL.SRCS<1> SETTING XX THEN
             IF TYPS<4> THEN MATCK.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<4>) AND SEL.SRCS THEN MATCH.OK = NO; RETURN
          END

          *** Match Users Followup Status. Types;0-Equal To,1-Not Equal To
          IF SEL.STAT # '' THEN
             LOCATE USER.ID IN ELOG<8> SETTING UPOS THEN
                LOCATE ELOG<9,UPOS> IN SEL.STAT<1> SETTING XX THEN
                   IF TYPS<5> THEN MATCH.OK = NO; RETURN
                END ELSE
                   IF NOT(TYPS<5>) THEN MATCH.OK = NO; RETURN
                END
             END ELSE
                MATCH.OK = NO; RETURN
             END
          END

          *** Match Entity Id. Types; 0-Equal To, 1-Not Equal To
          LOCATE ELOG<19> IN SEL.ENT<1> SETTING XX THEN
             IF TYPS<6> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<6>) AND SEL.ENT THEN MATCH.OK = NO; RETURN
          END

          *** Match Work Catagory. Types; 0-Equal To, 1-Not Equal To
          LOCATE ELOG<38> IN SEL.CAT<1> SETTING XX THEN
             IF TYPS<7> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<7>) AND SEL.CAT THEN MATCH.OK = NO; RETURN
          END

          *** Match Work Area 1. Types; 0-Equal To, 1-Not Equal To
          LOCATE ELOG<28,1> IN SEL.WRK<1> SETTING XX THEN
             IF TYPS<8> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<8>) AND SEL.WRK THEN MATCH.OK = NO; RETURN
          END

          *** Match Work Area 2. Types; 0-Equal To, 1-Not Equal To
          LOCATE ELOG<28,2> IN SEL.SAR<1> SETTING XX THEN
             IF TYPS<9> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<9>) AND SEL.SAR THEN MATCH.OK = NO; RETURN
          END

          *** Match External Status. Types; 0-Equal To, 1-Not Equal To
          LOCATE ELOG<29,1> IN SEL.PRI<1> SETTING XX THEN
             IF TYPS<10> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<10>) AND SEL.PRI THEN MATCH.OK = NO; RETURN
          END

          *** Match Internal Priority. Types; 0-Equal To, 1-Not Equal To
          LOCATE OCONV(ELOG<18,1>,'MCU') IN SEL.INT.STAT<1> SETTING XX THEN
             IF TYPS<11> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<11>) AND SEL.INT.STAT THEN MATCH.OK = NO; RETURN
          END

          *** Match External Priority. Types; 0-Equal To, 1-Not Equal To
          LOCATE OCONV(ELOG<29,2>,'MCU') IN SEL.EXT.STAT<1> SETTING XX THEN
             IF TYPS<12> THEN MATCH.OK = NO; RETURN
          END ELSE
             IF NOT(TYPS<12>) AND SEL.EXT.STAT THEN MATCH.OK = NO; RETURN
          END

          RETURN
*-------------------------------------------------------------------------*
CHK.PAT:  *** Check Pattern Match, returns pat.ok flag
          *** TYPS is the type of search: ''-Containing, 1-Not Containing,
          *** 2-Beginning With, 3-Ending With or 4-Exact Match

          PAT.OK = YES
          IF NOT(SEL.PAT) THEN RETURN

          TMP = CMT
          IF NUM(FIELD(ID,'.',1)) THEN
             READV WRK FROM CUSFILE,FIELD(ID,'.',1),1 THEN TMP := WRK
          END

          TMP  = TRIM(OCONV(TMP,'MCU'))
          KWRD = TRIM(OCONV(ELOG<32>,'MCU'))

          PAT.CT  = DCOUNT(SEL.PAT<1>,VM)
          FOR SEL = 1 TO PAT.CT WHILE PAT.OK

             PAT = TRIM(SEL.PAT<1,SEL>); *Already MCU

             BEGIN CASE
             CASE TYPS<1> = ''; *Containing
                IF NOT(INDEX(TMP,PAT,1)) AND NOT(INDEX(KWRD,PAT,1)) THEN
                   PAT.OK = NO
                END
             CASE TYPS<1> = 1; *Not Containing
                IF INDEX(TMP,PAT,1) OR INDEX(KWRD,PAT,1) THEN
                   PAT.OK = NO
                END
             CASE TYPS<1> = 2; *Beginning With
                SEL.LEN = LEN(PAT)
                IF TMP[1,SEL.LEN] # PAT THEN
                   PAT.OK = NO
                END
             CASE TYPS<1> = 3; *Ending With
                PAT.LEN = LEN(PAT)
                SEL.LEN = LEN(TMP) - PAT.LEN + 1
                IF TMP[SEL.LEN,PAT.LEN] # PAT THEN
                   PAT.OK = NO
                END
             CASE TYPS<1> = 4; *Exact Match
                IF TMP # PAT THEN
                   PAT.OK = NO
                END
             END CASE
          NEXT SEL

          RETURN
*-------------------------------------------------------------------------*
DISPLAY:  ***

          *** Display the system Time Zone as part of the Time col heading.
          LEFT.OVER.SPACE = (3-LEN(TIME.ZONE$))
          PRINT @(19,2):'Time':TIME.ZONE$:STR('Í',LEFT.OVER.SPACE)

          IF DOPT = 1 THEN
             DCMT = 'Comment'
          END ELSE
             DCMT = 'Problem/Solution'
          END

          DPOS = ((51-LEN(DCMT))/2)+27
          PRINT @(27,2):STR('Í',51)
          PRINT @(DPOS,2):DCMT

          EOF   = NO
          GO.UP = NO
          IN.SCROLL = YES
          LOOP UNTIL LINE >= SLGTH
             *** get a tracker
             GOSUB GET.ELOG
             IF EOF THEN EXIT

             CT = DCOUNT(CMT<1>,VM)
             *** display all the info/lines for that tracker
             FOR LN = 1 TO CT UNTIL LINE >= SLGTH
                LINE += 1
                GOSUB DISP.LN
             NEXT LN
             LGN -= 1                        ;* descenting
          REPEAT

          RETURN
*-------------------------------------------------------------------------*
DISP.LN:  IF LN=1 THEN
             PRINT  @(1,LINE+2):ELOG<1>                 "L#8"
             PRINT @(10,LINE+2):OCONV(ELOG<2>,'D2/')    "L#8"
             PRINT @(19,LINE+2):OCONV(ELOG<3>,'MTH')    "L#7"
          END ELSE
             *** just show one time
             PRINT  @(1,LINE+2):''                      "L#8"
             PRINT @(10,LINE+2):''                      "L#8"
             PRINT @(19,LINE+2):''                      "L#7"
          END
          PRINT @(27,LINE+2):CMT<1,LN>                  "L#50"

          LN.IDX<LINE> = SORT.ID:VM:LN

          *** same tracker use same CMT
          *** do not need to run GET.ELOG for each line
          LASTID  = SORT.ID         ; * save last tracker ID
          LASTCMT = CMT             ; * save last CMT
          RETURN
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO SELIT,VIEWEDIT,VIEWEDIT,ADDIT,EDITCMT,APPCMT,EXPIT,SYNOP,JOBQ,CHNG.VIEW
*-------------------------------------------------------------------------*
VIEWEDIT: IF OPTION = 2 THEN VIEW.ONLY = YES ELSE VIEW.ONLY = NO
          LOCATE LN.IDX<LINE,1> IN IDS SETTING LGN THEN
             CMT = ''
             SORT.ID = LN.IDX<LINE,1>
             TP      = FIELD(SORT.ID,'~',3)
             LOG.ID  = FIELD(SORT.ID,'~',4)
             IF TP = 'T' THEN
                READ CLOG FROM CLOGFILE,LOG.ID ELSE CLOG = ''
                JOB.TRACKING.GET.CMT CMT,CLOG,1,1
             END ELSE
                READV CMT FROM ELOGFILE,LOG.ID,5 ELSE CMT=''
             END
             UT.VIEW.EDIT.STR CMT,VIEW.ONLY
          END
          RETURN
*-------------------------------------------------------------------------*
ADDIT:    *** Create a new Job Queue
          LOCATE LN.IDX<LINE,1> IN IDS SETTING LGN THEN
             SORT.ID = LN.IDX<LINE,1>
             TP      = FIELD(SORT.ID,'~',3)
          END ELSE
             SORT.ID = ''
             TP      = TYPE
          END

          IF TYPE = 'O' THEN CN = 'ORD~':CN

          IF TP = 'T' THEN
             READV TST FROM INIFILE,CN,4 ELSE TST = ''
             IF TST<1,12> THEN
                MSG  = 'User ':CN:' is flagged for No Job Queues.':AM
                MSG := 'You can not create a tracker for ':CN:'.'
                MESS 5,5,MSG
IN$$2:          INP A,0,0,0
             END ELSE
                JOB.TRACKING.ENTRY CN:AM:AM:SEL.SRC:AM:AM:AM:AM:YES
             END
          END ELSE
             ENTITY.LOG.ENTRY CN:AM:AM:SEL.SRC
          END

          IF TYPE = 'O' THEN CN = FIELD(CN,'~',2)
          RETURN TO START1
*-------------------------------------------------------------------------*
EDITCMT:  IF LN.IDX<LINE,1>='' THEN PRINT BELL:; RETURN
          LOCATE LN.IDX<LINE,1> IN IDS SETTING LGN THEN
             SORT.ID = LN.IDX<LINE,1>
             TP      = FIELD(SORT.ID,'~',3)
             LOG.ID  = FIELD(SORT.ID,'~',4)
             IF TP = 'T' THEN
                READV CN FROM CLOGFILE,LOG.ID,19 ELSE CN = ''
                JOB.TRACKING.ENTRY CN:AM:LOG.ID:AM:AM:AM:AM:AM:YES
             END ELSE
                CN.NUM  = FIELD(LOG.ID,'.',1)
                LGN.NUM = FIELD(LOG.ID,'.',2)
                ENTITY.LOG.ENTRY CN.NUM:AM:LGN.NUM
             END
             SV.ID = LN.IDX<LINE,1>
             CHNGE = YES
          END
          RETURN
*-------------------------------------------------------------------------*
APPCMT:   IF LN.IDX<LINE,1>='' THEN PRINT BELL:; RETURN
          LOCATE LN.IDX<LINE,1> IN IDS SETTING LGN THEN
             SORT.ID = LN.IDX<LINE,1>
             TP      = FIELD(SORT.ID,'~',3)
             LOG.ID  = FIELD(SORT.ID,'~',4)
             IF TP = 'T' THEN
                READV CN FROM CLOGFILE,LOG.ID,19 ELSE CN = ''
                JOB.TRACKING.ENTRY CN:AM:LOG.ID:AM:AM:AM:AM:'A':AM:YES
             END ELSE
                CN.NUM  = FIELD(LOG.ID,'.',1)
                LGN.NUM = FIELD(LOG.ID,'.',2)
                ENTITY.LOG.ENTRY CN.NUM:AM:LGN.NUM:AM:AM:AM:AM:'A'
             END
             ID    = LN.IDX<LINE>
             SV.ID = LN.IDX<LINE,1>
             CHNGE = YES
          END
          RETURN
*-------------------------------------------------------------------------*
EXPIT:    IF EXP THEN RETURN
          EXP   = YES
          SV.ID = ''
          CHNGE = YES
          RETURN TO START3
*-------------------------------------------------------------------------*
SYNOP:    IF NOT(EXP) THEN RETURN
          EXP   = NO
          SV.ID = ''
          CHNGE = YES
          RETURN TO START3
*-------------------------------------------------------------------------*
JOBQ:     USER.QUEUE.VIEW2 USER.ID
          RETURN
*-------------------------------------------------------------------------*
CHNG.VIEW:*** Change View
          DISP.OPTS = 'Comment':VM:'Problem/Solution'
          TITLE     = 'Display Options'
          MENU.TABLE CHOICE,,,1,2,16,,,DISP.OPTS,TITLE,DOPT
          LOCATE CHOICE IN DISP.OPTS<1> SETTING NDOPT ELSE NDOPT = 1
          IF NDOPT # DOPT THEN
             DOPT  = NDOPT
             CHNGE = YES
             RETURN TO START3
          END
          RETURN
*-------------------------------------------------------------------------*
SELIT:    *** Select option

          SV.QUIT  = QUIT              ;* save the common variable
          USER.QUEUE.SELECT USER.ID,SELS,TYPS,SELECT.CT
          QUIT     = SV.QUIT           ;* reinstall the common variable
          SELECT.CT   += 1

          SEL.PAT      = OCONV(SELS<1>,'MCU')
          SEL.LVL      = SELS<2>
          SEL.USR      = OCONV(SELS<3>,'MCU')
          SEL.SRCS     = OCONV(SELS<4>,'MCU')
          SEL.STAT     = SELS<5>
          SEL.ENT      = SELS<6>
          SEL.CAT      = SELS<7>
          SEL.WRK      = SELS<8>
          SEL.SAR      = SELS<9>
          SEL.PRI      = SELS<10>
          SEL.INT.STAT = OCONV(SELS<11>,'MCU')
          SEL.EXT.STAT = OCONV(SELS<12>,'MCU')

          SV.ID    = ''
          LN.IDX   = ''
          LINE     = 0

          RETURN TO START2
*-------------------------------------------------------------------------*
INIT:     *** initialize
          SEL.SRC     = TYPE<1,2>
          TYPE        = TYPE<1,1>

          IF TYPE = '' THEN TYPE = 'C'        ;* set default type

          CN          = ''
          SCRN        = ''
          EXP         = YES                   ;* show the whole info
          AUTOEXIT    = NO                    ;* do not stay in the screen
          CHNG.VIEW   = NO                    ;* for MENU.LOAD
          REMIND.FLAG = YES                   ;* show reminder
          BEGIN CASE
          CASE FIELD(TYPE,'~',1) = 'CUST'
             KEY = 'CUST'
             CN  = FIELD(TYPE,'~',2)
             TYPE = 'C'
             VERF.SUB = 'VERF.CUS.ID'
             SCRN     = 'CUS.LOG.VIEW'
          CASE FIELD(TYPE,'~',1) = 'VENDOR'
             KEY = 'VENDOR'
             CN  = FIELD(TYPE,'~',2)
             TYPE = 'V'
             VERF.SUB = 'VERF.VEN.ID'
             SCRN     = 'VEN.LOG.VIEW'
          CASE INDEX(TYPE,'~',1)
             IF FIELD(TYPE,'~',1) = 'ORD' THEN
                CN   = FIELD(TYPE,'~',2)
                KEY  = 'ORD'
                TYPE = 'O'
                SCRN = 'ORD.LOG.VIEW'
                IF CN # '' THEN AUTOEXIT = YES
                VERF.SUB = ''
             END
          CASE TYPE='U'
             VERF.SUB = 'VERF.USER.ID'; KEY = 'USER'
             SCRN     = 'USER.LOG.VIEW'
             CHECK.KEY 'USER.JOB.QUEUE',,ULEVEL
             IF ULEVEL+0 <= 1 THEN CN = USER.ID; AUTOEXIT= YES
          CASE TYPE='V'
             VERF.SUB = 'VERF.VEN.ID'; KEY = 'VENDOR'
             SCRN     = 'VEN.LOG.VIEW'
          CASE TYPE='C'
             VERF.SUB = 'VERF.CUS.ID'; KEY = 'CUST'
             SCRN     = 'CUS.LOG.VIEW'
          CASE OTHERWISE
             READV TST FROM INIFILE,TYPE,1 THEN
                USER.QUEUE.VIEW2 TYPE
                RETURN
                END
             READV TST FROM CUSFILE,TYPE,7 ELSE PRINT BELL:; RETURN
             CN        = TYPE
             CHNG.VIEW = YES
             CSUB      = ''
             IF TST<1,1> OR TST<1,2> THEN
                KEY  = 'CUST'
                SCRN = 'CUS.LOG.VIEW'
             END ELSE
                KEY  = 'VENDOR'
                SCRN = 'VEN.LOG.VIEW'
             END
             AUTOEXIT = YES
          END CASE

          *** Determine how to activate hotkeys
          IF TYPE   = 'C' OR TYPE = 'U' OR TYPE = 'V' THEN
             CHNG.VIEW = YES
          END

          *** Display only these type of trackers; Manual, System, or All
          READ TRANS.TYPE FROM CTRLFILE,'ACT.LOG.DFLT.TRANS' ELSE
             TRANS.TYPE = ''
          END
          IF NOT(TRANS.TYPE) THEN TRANS.TYPE = 'MANUAL'
          RETURN
*-------------------------------------------------------------------------*
INIT2:    *** initialize

          *** clear select options
          TYPS         = ''               ;* type of the search
          *** 1-Not Containing, 2-Beginning With
          *** 3-Ending With or 4-Exact Match
          SELS         = ''               ;* detail of options
          SEL.PAT      = ''               ;* pattern
          SEL.USR      = ''               ;* user
          SEL.LVL      = ''               ;* security level
          SEL.SRCS     = ''               ;* security
          SEL.STAT     = ''               ;* users followup status
          SEL.ENT      = ''               ;* entity ID
          SEL.CAT      = ''               ;* work catagory
          SEL.WRK      = ''               ;* work area 1
          SEL.SAR      = ''               ;* work area 2
          SEL.PRI      = ''               ;* external status
          SEL.INT.STAT = ''               ;* internal priority
          SEL.EXT.STAT = ''               ;* external priority
          SELECT.CT    = 0

          ***If default source was passed in update select source
          IF SEL.SRC # '' THEN
             SELS<4>   = OCONV(SEL.SRC,'MCU')
             SEL.SRCS  = SELS<4>
             SELECT.CT = 1
          END

          IDS          = ''               ;* list of IDs
          SV.ID        = ''               ;* ID selected by the Hot key
          END.DT       = DATE()           ;* default date
          FIRST        = YES              ;* first time to run the program
          CHNGE        = NO               ;* for re select the shipto
          DOPT         = 1                ;* default view
          CHOICE       = 1                ;* multi customer
          SLGTH        = 17               ;* screen length
          RETURN
*-------------------------------------------------------------------------*
RESTART:  ***
          IF NOT(AUTOEXIT) THEN PN=''; CN=''; GOTO START1
*-------------------------------------------------------------------------*
FINISH:   ***
          WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
!SMITJR~03/05/10~22:29
