          SUBROUTINE (SYSTEM.KEY)
** Version# 24.0002[1] - 10/20/2010 - 03:35pm - SMITJR - eclipse
** Copied from BP PHYS.DVR.PRINT.SHEET Version# 24 - 12/11/2003 - 02:38pm - ROELANTV - develop

*** Subroutine - PHYS.DVR.PRINT.SHEET
*-------------------------------------------------------------------------*
*** This Subroutine will gather input from the user regarding print options
*** and pass them into Phantom to printed or held.
*-------------------------------------------------------------------------*
*** SYSTEM.KEY - If the program is called from the phantom status -    (IN)
***              schedul edit to edit an existing scheduled report,
***              this is the ID of the schedule record in the
***              SYSTEM.QUEUE file.
*-------------------------------------------------------------------------*
*** COMMON USED:
*** None Used
*-------------------------------------------------------------------------*
EQU CT.ID.X TO 20
EQU CT.ID.Y TO 1
EQU CT.ID.LEN TO 5
EQU SORT.X TO 19
EQU SORT.Y TO 5
EQU SORT.LEN TO 30
EQU STRT.X TO 19
EQU STRT.Y TO 6
EQU STRT.LEN TO 6
EQU END.X TO 19
EQU END.Y TO 7
EQU END.LEN TO 6
EQU BRK.X TO 26
EQU BRK.Y TO 9
EQU BRK.LEN TO 15
EQU TYPE.X TO 26
EQU TYPE.Y TO 8
EQU TYPE.LEN TO 10

          SCREEN
          GOSUB INIT
          IF DEFAULT.RECORD='' THEN
             ERR.MESS 2,1,BELL:'No column default data exists for this report',YES
             GOTO FINISH
          END

*** Need to check if system queue record passed in to edit scheduled report
          UT.OPEN.FILE 'SYSTEM.QUEUE',SQFILE,ERR.MSG
          IF ERR.MSG#'' THEN GOTO FINISH

          UNUSED = ''
          IF SYSTEM.KEY THEN
             READV UNUSED FROM SQFILE,SYSTEM.KEY,1 ELSE NULL
          END

          IF UNUSED THEN
*** Get the parameters for editing
             PH.EDIT = YES
             PH.READ.ARGS ARG.ERR,SYSTEM.KEY,RPT.DFLT,USR.ID,CT.ID,START.ID,END.ID,TYPE,BRK,SORT
             DRPT$ = RPT.DFLT
          END ELSE
             PH.EDIT = NO
             CT.ID    = ''                          ;*Count ID
             START.ID = ''                          ;*Start ID
             END.ID   = ''                          ;*End ID
             SORT     = 'Ctrl#'                     ;*Sort Type
             TYPE     = 'Sheets'                    ;*Print to Sheet or Card
             BRK      = 'No Page Breaks'            ;*Include Breaks & Type
          END

*** No fill in the screen values in case we are editing from scheduler edit
          GOSUB PRINT.CT.ID
          FRMT = 'L#':SORT.LEN
          PRINT @(SORT.X,SORT.Y):SORT FRMT:
          FRMT = 'R#':STRT.LEN
          PRINT @(STRT.X,STRT.Y):START.ID FRMT:
          FRMT = 'R#':END.LEN
          PRINT @(END.X,END.Y):END.ID FRMT:
          FRMT = 'L#':BRK.LEN
          PRINT @(BRK.X,BRK.Y):BRK FRMT:
          FRMT = 'L#':TYPE.LEN
          PRINT @(TYPE.X,TYPE.Y):TYPE FRMT:

          MENU.LOAD  2,11, 5,1,'P'               ;*Loads the Print Hotkey
          MENU.LOAD 10,11, 4,1,'H'               ;*Loads the Hold Hotkey
          MENU.LOAD 17,11, 4,1,'O'               ;*Loads the Option Hotkey
          MENU.LOAD 23,11, 6,1,'C'               ;*Loads the Setup Hotkey
*-------------------------------------------------------------------------*
***User inputs the Count ID
INID:     INP CT.ID,CT.ID.X,CT.ID.Y,CT.ID.LEN,'MCU',V_'WORK.MISC,1,,PHYS:'
          IF F12 THEN GOTO FILEIT
          IF QUIT AND PH.EDIT THEN GOTO FILEIT
          IF CT.ID='' THEN PRINT BELL:; GOTO INID
          GOSUB PRINT.CT.ID
*-------------------------------------------------------------------------*
***Input the sort type
INSORT:   INP SORT,SORT.X,SORT.Y,SORT.LEN,V_"D:":SORT.BY
          IF F12 THEN GOTO FILEIT
          IF QUIT AND PH.EDIT THEN GOTO FILEIT
          ON MOVE+1 GOTO INSORT,INSORT,INID,INSORT,INSTRT,INSTRT
*-------------------------------------------------------------------------*
***Input the Start ID
INSTRT:   INP START.ID,STRT.X,STRT.Y,STRT.LEN,'R'
          IF F12 THEN GOTO FILEIT
          IF QUIT AND PH.EDIT THEN GOTO FILEIT
          ON MOVE+1 GOTO INSTRT,INSTRT,INSORT,INSTRT,INEND,INEND
*-------------------------------------------------------------------------*
***Input the End ID
INEND:    INP END.ID,END.X,END.Y,END.LEN,'R'
          IF F12 THEN GOTO FILEIT
          IF QUIT AND PH.EDIT THEN GOTO FILEIT
          ON MOVE+1 GOTO INEND,INEND,INSTRT,INEND,INTYPE,INTYPE
*-------------------------------------------------------------------------*
***Input the media type, SHEET or CARD
INTYPE:   INP TYPE,TYPE.X,TYPE.Y,TYPE.LEN,V_'D:Sheets':VM:'Cards'
          IF F12 THEN GOTO FILEIT
          IF QUIT AND PH.EDIT THEN GOTO FILEIT
          ON MOVE+1 GOTO INTYPE,INTYPE,INEND,INTYPE,INBRK,INBRK
*-------------------------------------------------------------------------*
***       Input the line break type if any
INBRK:    INP BRK,BRK.X,BRK.Y,BRK.LEN,V_'D:':BRK.BY
          IF F12 THEN GOTO FILEIT
          IF QUIT AND PH.EDIT THEN GOTO FILEIT
          ON MOVE+1 GOTO INBRK,INBRK,INTYPE,INBRK,INBRK,INBRK
*-------------------------------------------------------------------------*
*** Print Count ID#
PRINT.CT.ID:*
          IF CT.ID = '' THEN RETURN;* original screen setup
          FRMT = 'R%':CT.ID.LEN
          PRINT @(CT.ID.X,CT.ID.Y):CT.ID FRMT:
          PHYS.ID = 'PHYS:':CT.ID"R%5"
          READ PHYS FROM WORKFILE,PHYS.ID ELSE PRINT BELL:; GOTO INID
          LAST.ID = PHYS<6> - 1
          PRINT @(20,2):PHYS<1> "L#30":
          PRINT @(20,3):PHYS<2> "L#4":
          PRINT @(19,4):LAST.ID "R#6":
          BRK.BY   = 'No Page Breaks':VM:'Line'
          READ LAYOUT FROM CTRLFILE,'PROD.LOCATION.LAYOUT~':PHYS<2> THEN
             HEADING = LAYOUT<5>
             LOCLEN  = LAYOUT<6>
             CNT = DCOUNT(LOCLEN,VM)
             FOR HDG = 1 TO CNT
                IF LOCLEN<1,HDG>+0#0 THEN BRK.BY:=VM:HEADING<1,HDG>
             NEXT HDG
          END
          RETURN
*-------------------------------------------------------------------------*
          ***JAMESV 9/18/98  add error messages to error traps
SUBS:*
          ON OPTION GOTO DOIT,DOIT,REP.OPTS,SETUP
*-------------------------------------------------------------------------*
*** Just set report options
REP.OPTS:*
          PH.EXE
          RETURN
*-------------------------------------------------------------------------*
DOIT:     ***Calls PHR and passes users selections
          IF START.ID = '' THEN
             ERR.MESS 5,8,BELL:'Please enter a start control number'
             RETURN TO INSTRT
          END

          IF END.ID = '' THEN
             ERR.MESS 5,9,BELL:'Please enter an ending control number'
             RETURN TO INEND
          END

          IF TYPE='' THEN
             ERR.MESS 5,10,BELL:'Please enter "Sheets" or "Cards"'
             RETURN TO INTYPE
          END

          IF START.ID > END.ID THEN
             ERR.MESS 5,3,BELL:'The starting control number must not':AM:'be larger then the ending control number.'
             RETURN TO INSTRT
          END

          IF BRK = '' THEN
             ERR.MESS 5,10,BELL:'Please enter a Page Break on'
             RETURN TO INBRK
          END

          IF PH.EDIT THEN
             PH.DEL.ARGS ARG.ERR,SYSTEM.KEY
          END
          PH.EXE PHR.NAME:VM:DVR.NAME,CT.ID,START.ID,END.ID,TYPE,BRK,SORT
          IF F12 THEN RETURN

          RETURN TO FINISH
*-------------------------------------------------------------------------*
SETUP:    ***Calls routine for the Setup Hotkey & passes req'd info
          REPORT.LAYOUT.V.MAINT TITLE,RECORD.PREFIX
          RETURN
*-------------------------------------------------------------------------*
INIT:     ***Initialize the variables
          RECORD.PREFIX = 'COUNT.SHEET.SETUP'   ;*User settings
          REPORT.V.COL.GET.DATA RECORD.PREFIX,'*DEFAULT',DEFAULT.RECORD
          IF DEFAULT.RECORD='' THEN RETURN
          DVR.NAME = 'PHYS.DVR.PRINT.SHEET'
          PHR.NAME = 'PHYS.PHR.PRINT.SHEET.MRO'
          TITLE    = 'Print Count Sheet Setup'   ;*Report Title
          DRPT$    = 'Count Sheet Printing'      ;*Report Printing Default
          SORT.BY  = 'Ctrl#':VM:'Price Line By Description':VM:'Location by Ctrl#':VM:'Location by PLine by Desc':VM:'Location by PLine by SellGroup':VM:'Location by Description'                     ;*Valid Sort Options

          RETURN
*-------------------------------------------------------------------------*
FILEIT:*
          IF NOT(PH.EDIT) THEN GOTO FINISH
*** Only save the report settings if editing a previously
*** scheduled report
          IF F12 THEN
             CONFIRM.ABORT SURE
             IF SURE THEN GOTO FINISH ELSE GOTO INID
          END
          PH.DEL.ARGS ARG.ERR,SYSTEM.KEY
          IF ARG.ERR THEN PRINT BELL:; GOTO FINISH
*** Save off arguement changes to the System Queue file by
*** calling PH.SCHDULE.LOG
          SCHED.DATA   = DRPT$<1>
          PTR.ID       = DFLT.PTR
          LOCA         = LOCATION
          DRPT$<1>     = ''
          DRPT$<27>    = 'HOLD'
          IF DRPT$<36> = '' THEN DRPT$<36> = USER.ID

          * Build the ARGS array which will then be written out to
          * the System Queue file in a new record in field 3
          ARGS     = ''
          ARGS<1>  = PHR.NAME          ;* Phantom subroutine name
          ARGS<3>  = USER.ID           ;* User ID
          ARGS<4>  = LOCA              ;* Location
          ARGS<5>  = PTR.ID            ;* Default printer
          ARGS<6>  = SCHED.DATA<1,1>
          ARGS<9>  = LOWER(DRPT$)      ;* Standard reporting options

          ARGS<10> = CT.ID
          ARGS<11> = START.ID
          ARGS<12> = END.ID
          ARGS<13> = TYPE
          ARGS<14> = BRK
          ARGS<15> = SORT

          ARGS = TRIM(ARGS,AM,'T')
          * Pass the phantom routine and driver routine to PH.SCHEDULE.LOG
          * which will write them out to field 2 of the SYSTEM.QUEUE
          * record then enabled users to recall and edit the process.
          PROG.NAMES = PHR.NAME:VM:DVR.NAME
          PH.SCHEDULE.LOG SCHED.DATA,PROG.NAMES,ARGS
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*


!SMITJR~10/20/10~15:35
