          SUBROUTINE (PASSER)
** Version# 35.0001[1] - 09/09/2010 - 01:04pm - SMITJR - eclipse
** Copied from BP PHYS.DVR.VARIANCE Version# 35 - 09/03/2003 - 06:15pm - AKAUPISC - develop

** Subroutine - PHYS.DVR.VARIANCE
*-------------------------------------------------------------------------*
** Driver program for Physical Inventory Variance Report
** This routine allows input of selection criteria for items to print
** on the physical variance report.
*-------------------------------------------------------------------------*
** PASSER (Not Used)                                                  (IN)
*-------------------------------------------------------------------------*
          SCREEN

          *** Go initialize our variables and load our Hotkeys...
          GOSUB INIT

*-------------------------------------------------------------------------*
*** Count ID# Input...
INID:     INP CT.ID,15,1,5,V_'WORK.MISC,1,,PHYS:'

          IF F12 THEN GOTO FINISH

          IF CT.ID = '' THEN PRINT BELL:; GOTO INID

          PHYS.ID  = 'PHYS:':CT.ID "R%5"
          READ PHYS FROM WORKFILE,PHYS.ID ELSE PHYS = ''

          NEXT.ID  = PHYS<6>
          LAST.ID  = NEXT.ID - 1

          PRINT @(15,1):CT.ID    "R%5"
          PRINT @(15,2):PHYS<1>  "L#30"
          PRINT @(15,3):PHYS<2>  "L#4"
          PRINT @(19,4):LAST.ID  "R#6"
*-------------------------------------------------------------------------*
*** Ctrl#/Prc Line Input...
INSRT:    INP SRT,20,5,8,V_'D:Ctrl#':VM:'Prc Line'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INSRT,INSRT,INID,INSRT,INSORTBY,INSORTBY
*-------------------------------------------------------------------------*
*** Sort by Input...
INSORTBY: INP DSND.SORT,38,5,18,V_'D:':SORT.BY

          IF F12 THEN GOTO FINISH

          LOCATE DSND.SORT IN SORT.BY<1> SETTING SORT.POS ELSE
             PRINT BELL:; GOTO INSORTBY
          END

          IF SORT.POS = 4 THEN
             SORT = 2
             SRT  = 'Prc Line'
             PRINT @(20,5):SRT
          END

          IF SRT = 'Ctrl#' THEN
             ON MOVE+1 GOTO INSORTBY,INSRT,INID,INSORTBY,INSTRT,INSTRT
          END ELSE
             ON MOVE+1 GOTO INSORTBY,INSRT,INID,INSORTBY,INPLNE,INPLNE
          END
*-------------------------------------------------------------------------*
*** Start Control # Input... Only get here if 'Ctrl#' is chosen as sortby.
INSTRT:   INP START.ID,19,6,6,'R'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INSTRT,INSTRT,INSRT,INSTRT,INEND,INEND
*-------------------------------------------------------------------------*
*** End Control # Input... Only get here if 'Ctrl#' is chosen as sortby.
INEND:    INP END.ID,19,7,6,'R'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INEND,INEND,INSTRT,INEND,INBASIS,INBASIS
*-------------------------------------------------------------------------*
*** Priceline Input... Only get here if 'Prc Line' is chosen as sortby.
INPLNE:   INP TMP.PLINE,20,8,10,V_'PRICE.LINE'
          IF CHANGED AND TMP.PLINE # "*Multi*" THEN
             PLINE = TMP.PLINE
          END
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INPLNE,INPLNE,INSRT,INPLNE,INBASIS,INBASIS
*-------------------------------------------------------------------------*
*** Cost Basis Input...
INBASIS:  INP BAS,20,9,20,V_'S:VERF.GLOBAL.BASIS'
          IF F12 THEN GOTO FINISH
          IF MOVE=2 THEN IF SRT='Ctrl#' THEN GOTO INEND ELSE GOTO INPLNE
          ON MOVE+1 GOTO INBASIS,INBASIS,INSRT,INBASIS,INPDT,INPDT
*-------------------------------------------------------------------------*
*** Price Date Input...
INPDT:    INP PDATE,20,10,10,'VD4/'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INPDT, INPDT, INBASIS, INPDT, INSUM, INSUM
*-------------------------------------------------------------------------*
*** Sum/Det/Var/Product Var Input...
INSUM:    INP SUM.DET,27,11,23,V_'D:':DETAIL.OPTS
          IF F12 THEN GOTO FINISH
          IF SUM.DET[1,1] = 'P' THEN
             SORT.POS  = 4
             DSND.SORT = 'By Product by Loc'
             PRINT @(38,5):DSND.SORT "L#18"
          END
          ON MOVE+1 GOTO INSUM,INSUM,INPDT,INSUM,INNULL,INNULL
*-------------------------------------------------------------------------*
*** Nulls = 0 (Y/N) Input...
INNULL:   INP NULL0,20,12,1,'YN'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INNULL,INNULL,INSUM,INNULL
*-------------------------------------------------------------------------*
*** Tagged Locs (Incl/Excl/Only) option...
INTAGS:   INP TAGS,33,13,7,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INTAGS,INTAGS,INNULL,INTAGS
*-------------------------------------------------------------------------*
*** Show Post Dated Orders Input...
INPOSTDET:INP POST.DET,27,14,7,V_'D:Detail':VM:'Summary'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INPOSTDET,INPOSTDET,INTAGS,INPOSTDET
*-------------------------------------------------------------------------*
*** Min Variance Input...
INVAR:    INP DOL.VAR,21,15,4,'R'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INVAR,INVAR,INPOSTDET,INVAR,INVAR2,INVAR2
*-------------------------------------------------------------------------*
***
INVAR2:   INP EXPR,20,16,3,V_'D:And':VM:'Or'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INVAR2,INVAR2,INVAR,INVAR2,INVAR3,INVAR3
*-------------------------------------------------------------------------*
***
INVAR3:   INP PRCT.VAR,20,17,3,'R'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INVAR3,INVAR3,INVAR2,INVAR3,INVAR3,INVAR3
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO DOIT,DOIT,DOIT,PSEL
*-------------------------------------------------------------------------*
INIT:     *** Initialize variables and load our Hotkeys...

          DRPT$        = 'Variance Report'
          PHYS.ID      = ''
          START.ID     = ''
          END.ID       = ''
          SRT          = 'Ctrl#'
          BAS          = ''
          PLINE        = ''
          PDATE        = DATE()
          SUM.DET      = 'Detail'
          NULL0        = NO
          TAGS         = 'Include'
          DOL.VAR      = ''
          EXPR         = ''
          PRCT.VAR     = ''
          TMP.PLINE    = ''
          DSND.SORT    = ''
          POST.DET     = 'Detail'
          REQ.FLDS     = ''
          SORT.POS     = 1

          PRINT @(20,10):OCONV(PDATE,'D4/') "L#10"

          SORT.BY      = 'By-Asnd Ctrl#':@VM:'By-Dsnd Count':@VM
          SORT.BY     := 'By-Dsnd Count$':@VM:'By Product by Loc':@VM
          SORT.BY     := 'By-Dsnd Cnt Diff':@VM:'By-Dsnd $ Diff'

          DETAIL.OPTS  = 'Summary':VM:'Detail':VM:'Location Variance Only'
          DETAIL.OPTS := VM:'Product Variance Only'

          MENU.LOAD  2,19,5,1,'P'
          MENU.LOAD 10,19,4,1,'H'
          MENU.LOAD 17,19,4,1,'O'
          MENU.LOAD 24,19,4,1,'L'

          RETURN
*-------------------------------------------------------------------------*
PSEL:     *** Multiple Price Line selection...
          PHYS.PLINE.SELECT PLINE
          IF DCOUNT(PLINE,VM) > 1 THEN
             PRINT @(20,8):'*Multi*'  "L#10"
          END ELSE
             PRINT @(20,8):PLINE
          END
          RETURN
*-------------------------------------------------------------------------*
DOIT:     *** Validate the Inputs and then run the report...

          IF SRT = 'Ctrl#' AND SUM.DET[1,1] = 'P' THEN
             PRINT BELL:
             MESS 8,10,'Product Variance option requires Prc Line sort'
             RETURN TO INSRT
          END

          IF SRT = 'Ctrl#' THEN
             IF NUM(START.ID) AND START.ID AND NUM(END.ID) AND END.ID THEN
                IF START.ID > END.ID THEN
                   PRINT BELL:
                   CONTROL.MSG  = 'Start Control # must be less than End '
                   CONTROL.MSG := 'Control #.'
                   MESS 7,10,CONTROL.MSG
                   RETURN TO INSTRT
                END
             END

             IF NUM(END.ID) AND END.ID AND NUM(LAST.ID) AND LAST.ID THEN
                IF END.ID > LAST.ID THEN
                   PRINT BELL:
                   LAST.MSG  = 'End Control # cannot be greater than Last '
                   LAST.MSG := 'Control #.'
                   MESS 7,10,LAST.MSG
                   RETURN TO INEND
                END
             END

             IF START.ID = '' THEN REQ.FLDS<-1> = 'Start Control #'
             IF END.ID   = '' THEN REQ.FLDS<-1> = 'End Control #'

             SORT = 1
          END ELSE
             SORT = 2
          END

          IF BAS AND PDATE = '' THEN REQ.FLDS<-1> = 'Price Date'

          IF REQ.FLDS THEN
             ERR.MESS 14,3,BELL:'Missing Required Fields(s): ':AM:REQ.FLDS
IN$$2:       INPNO A,,,0
             BEGIN CASE
             CASE REQ.FLDS<1> = 'Basis'
                REQ.FLDS = ''
                RETURN TO INBASIS
             CASE REQ.FLDS<1> = 'Start Control #'
                REQ.FLDS = ''
                RETURN TO INSTRT
             CASE REQ.FLDS<1> = 'End Control #'
                REQ.FLDS = ''
                RETURN TO INEND
             CASE REQ.FLDS<1> = 'Price Date'
                REQ.FLDS = ''
                RETURN TO INPDT
             END CASE
          END

          READU PHYS FROM WORKFILE,PHYS.ID ELSE PHYS = ''
          PHYS<10>  = POST.DET
          WRITE PHYS ON WORKFILE,PHYS.ID

          SV.OPTION = OPTION

          GOSUB GET.POST.PICKED
          NULL0<1,2> = POST.DATED.PICKED
          OPTION = SV.OPTION

          PH.EXE 'PHYS.PHR.VARIANCE',CT.ID,START.ID,END.ID,SORT,BAS,PLINE,PDATE,SUM.DET,NULL0,TAGS,DOL.VAR,EXPR,PRCT.VAR,SORT.POS

          IF F12 THEN RETURN

          RETURN TO FINISH
*-------------------------------------------------------------------------*
GET.POST.PICKED: *** Have postdated orders been picked before count
                 *** Responding 'Y' to this prompt indicates to the
                 *** program that all postdated orders (process date less
                 *** than shipdate) have been picked and therefore have
                 *** NOT been included in any count quantities.

          READV POST.PRMPT FROM CTRBFILE,'PHYS.POST.DATED~':PHYS<2>,1 ELSE
             POST.PRMPT = ''
          END

          POST.DATED.PICKED = ''

          IF POST.PRMPT THEN
             MSG = 'Have You Picked all Post-Dated Orders (Y/N) '
IN$$1:       INP.PROMPT POST.DATED.PICKED,MSG,'YN'
          END

          RETURN
*-------------------------------------------------------------------------*
FINISH:   *** Get rid of the Lock on the "" File, close the Driver Screen,
          *** and exit the program...
          RELEASE WORKFILE,PHYS.ID
          WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
!SMITJR~09/09/10~13:04
