          SUBROUTINE (PASSER,PRT.SELCT,TOL.CNT,BOX.QTY )
** Version# 7.0001[9] - 08/03/2017 - 01:46pm - TSMITH - eclipse
*** V7.0001 Change - Custom Coding . - 08/03/2017 - TSMITH - eclipse

*** Subroutine - UD.LABEL.DOC.PRINT
*-------------------------------------------------------------------------*
*** This subroutine is used to print the user defined labels/documents
*-------------------------------------------------------------------------*
*** PASSER this is a AM separated array that is broken down as follows:
***       <1> - Order ID
***       <2> - GEN
***       <3> - original gen
***       <4> - lowered value of the LED array
***       <5> - lowered value of the LD array
***       <6> - LDID
***       <7> - original LDID (typically item selected)            [IN]
***             However, if call originated at
***             Warehouse Picking Confirmation screen then
***             the following information is encoded:
***             <7,1> = 'PICK.CONF'   - String to identify
***                                     source of call
***             <7,2> = TOTAL.PKG.CNT - Total package count
***                                     defined on that screen
***       <8> - UID (user defined ID?)
***       <9> - not used
***       <10> - Label Qty
***       <11> - UQTY (user defined qty?)
***       <12> - UFORMAT (user defined format?)
***       <13> - document/label format
***       <14> - VM list of LDIDS
***       <15> - carton OID (CTN.OID)
***       <16> - TYPE (the type of label printing)
***       <17> - Receive mode  (use for transfer only)
***       <18> - lowered value of CUS array
***       <19> - lowered value of CUSS array
***       <20> - quantity (QTY)
***       <21> - Call from (1 - OE, 2 - RF, null = unknown)
***       <22> - print selection lists
***       <23> - format ID
***       <24> - PICK.CONF (i.e. Called from Whse Pick Confirm)
***       <25> - total package count (from Whse Pick Confirmation)
***       <26> - Qsign
***       <27> - MODE(this is could be the order mode or user
***              defined mode)
***       <28> - the list of label formats (lowered)
***       <29> - subroutine name
***       <30> - form name
***       <31> - DDE subroutine
***       <32> - Authorization key
***       <33> - carton data (lowered)
***       <34> - total print
***       <35> - ISPEC - Label Type                                (IN)
***                'IM' = Item  Specific, Multi-Call
***                'IS' = Item  Specific, Single-Call
***                'OM' = Order Specific, Multi-Call
***                'OS' = Order Specific, Single-Call
***                'NO' = No autolooping ==> ALWAYS ONLY 1 Label
***       <36> - QTYP - An integer indicating the TYPE of label    (IN)
***              printing selected by the user. The set of integer
***              Constants to be used for this variable are
***              defined in UD.DOC.PRINT.GET.SELCTS.

*** PRT.SELCT - A text string indicating the TYPE of the label     (IN)
***         printing selected by the user.  (Aka the "Print
***         Selection")
*** TOT.CNT   - total print count                                  <IN>
***          TOL.CNT<1> contains the number of labels to print.
***                     This program makes the BEST GUESS at the
***                     number of number of labels needed.
***          TOL.CNT<2> MAY contain a 'Y' if the user changes
***                     the number of labels to print.
*** BOX.QTY   - boxed quantity                                     <IN>
*-------------------------------------------------------------------------*
          GOSUB INIT
          GOSUB SET.VARS
          GOSUB PRINT.IT

          RETURN
*-------------------------------------------------------------------------*
SET.VARS: ***set the variables using PASSER
          OID = PASSER<1>
          GEN = PASSER<2>
          ORIG.GEN = PASSER<3>
          IF JAVA.PROC$ THEN
             LED.REC = RAISE(PASSER<4>)
             MATPARSE LED FROM LED.REC
             LD.REC = RAISE(PASSER<5>)
             MATPARSE LD FROM LD.REC
             CUS.REC = RAISE(PASSER<18>)
             MATPARSE CUS FROM CUS.REC
             CUSS.REC = RAISE(PASSER<19>)
             MATPARSE CUSS FROM CUSS.REC
          END
          LDID = PASSER<6>
          ORIG.LDID = PASSER<7>
          UID       = PASSER<8>
          LDIDS     = PASSER<14>
          SUBR.NAME = PASSER<29>
          FORM      = PASSER<30>
          ISPEC     = PASSER<35>
          QTYP      = PASSER<36>
          DDE.SUBR  = PASSER<31>
          SELCT     = PRT.SELCT
          LD.CT     = DCOUNT(LDIDS,VM)
          TOT.PRT   = 0
          CTN.DATA  = RAISE(PASSER<33>)
          TYPE      = PASSER<16>
          CTN.OID   = PASSER<15>
          OTYPE     = PASSER<37>



               SRT.LOCS  = ''
             SRT.LDIDS = ''
             SHIP.BR = 1
             PRT.LDIDS = LED(49)
             LD.CT     = DCOUNT(LDIDS,AM)
             FOR J = 1 TO LD.CT
                LDID  = PRT.LDIDS<J>
                LD.GET LDID
                PN = LD(1)

                   IF PN # '' AND (NUM(PN) OR PN = 'C' OR PN[1,2] = "L#") THEN
                   IF PN = 'C' THEN LOC = '*' ELSE
                      LOC = LD(7)<1,GEN,1>
                      LOC = FIELD(LOC,'~',2)
                      IF LOC = '' THEN
                         PRD.LOCATION.GET PRI.LOC,PN,SHIP.BR
                         LOC = PRI.LOC
                      END
                   END
                   IF LOC = '' THEN LOC = 'ZZZ'

                   LOC := J "R%4"
                   LOCATE LOC IN SRT.LOCS BY 'AL' SETTING POS ELSE NULL
                   SRT.LOCS  = INSERT(SRT.LOCS,POS;LOC)
                   SRT.LDIDS = INSERT(SRT.LDIDS,POS;LDID)
                END
             NEXT J
             PRT.LDIDS = SRT.LDIDS


           LDID.CT = DCOUNT(PRT.LDIDS,AM)
          FOR LD.NO = 1 TO LDID.CT
             LDID   = PRT.LDIDS<LD.NO>
          NEXT LD.NO


          RETURN
*-------------------------------------------------------------------------*
PRINT.IT: *** print the labels/documents
          IF TYPE = 'N' THEN
             BEGIN CASE
             CASE UID<1,2> = 'SRE.INT'
                LDIDS = ''
                ORIG.LDID = 1
                UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY
             CASE SELCT = SELCT.ALL.ITEMS OR SELCT = SELCT.ORDER.ONLY
                VALID.OID = FIELD(ORIG.LDID<1>,'~',1)
                FOR XX = 1 TO LD.CT
                   OID       = FIELD(LDIDS<1,XX>,'~',1)

                   * Check to see if this is on the selected order
                   IF SELCT = SELCT.ORDER.ONLY THEN
                      IF OID # VALID.OID THEN CONTINUE
                   END

                   GID       = FIELD(LDIDS<1,XX>,'~',2)+0
                   ORIG.LDID = FIELD(LDIDS<1,XX>,'~',3)
                   TOL.CNT   = FIELD(LDIDS<1,XX>,'~',4)
                   *MATREAD LED FROM LEDFILE,OID ELSE CONTINUE
                   *LOCATE GID IN LED(12)<1> SETTING GEN ELSE CONTINUE
                   *LD.GET LDID
                   *faking so only one label will print at a time since
                   *we're dealing with shipment notifications
                   QTYP = SELCT.VALUE.CURRENT.ITEM
                   TOT.PRT += TOL.CNT
                   UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY
                NEXT XX
                TOL.CNT<1> = TOT.PRT
             CASE SELCT = SELCT.CURRENT.ITEM
                OID       = FIELD(ORIG.LDID<1>,'~',1)
                GID       = FIELD(ORIG.LDID<1>,'~',2)+0
                IF TOL.CNT<1> + 0 = 0 THEN
                   TOL.CNT   = FIELD(ORIG.LDID<1>,'~',4)
                END
                ORIG.LDID = FIELD(ORIG.LDID<1>,'~',3)
                MATREAD LED FROM LEDFILE,OID ELSE MAT LED = ''
                LOCATE GID IN LED(12)<1> SETTING GEN ELSE GEN = ''
                LD.GET LDID
                QTYP = SELCT.VALUE.CURRENT.ITEM
                UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY
             END CASE
          END ELSE
             BEGIN CASE
             *------------------------------------------------------------*
             CASE UID<1,2> = 'SRE.INT' AND TYPE = 'P'
                LDIDS = ''
                ORIG.LDID = 1
                UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY

              *------------------------------------------------------------*
              CASE CTN.DATA AND SELCT = SELCT.ORDER.ONLY AND (SUBR.NAME = '*CTN.OUT' OR SUBR.NAME = '*CTNSHP.OUT')
                CTN.ID = OID[2,99]
                OID    = FIELD(CTN.DATA<11,1>,'.',1)   ;*CTN.OIDS
                IF OID THEN
                   GID       = FIELD(CTN.DATA<11,1>,'.',2)   ;*CTN.OIDS
                   LDID      = CTN.DATA<7,1>
                   ORIG.LDID = LDID
                   MATREAD LED FROM LEDFILE,OID ELSE MAT LED = ''
                   LOCATE GID IN LED(12)<1> SETTING GEN ELSE GEN = ''
                   LD.GET LDID
                   QTYP = SELCT.VALUE.CURRENT.ITEM
                   UID  = CTN.DATA

                   * Make sure there is a label printer and turn off
                   * java so that the printer will turn on.
                   SV.ECLIPSE.FORMS   = USE.ECLIPSE.FORMS$
                   USE.ECLIPSE.FORMS$ = NO
                   PRINT.LOC          = LOCATION
                   UT.GET.PTRS PRINT.LOC,,,FORMS
                   LOCATE 'LABELS' IN FORMS<1> SETTING DUM ELSE
                      MSG = 'No printer found with LABELS loaded'
                      SEND.MESSAGE 'Phantom',USER.ID,MSG
                      RETURN
                   END
                   SV.JAVA.PROC   = JAVA.PROC$
                   SV.JAVA.PASSER = JAVA.PASSER$
                   JAVA.PROC$     = ''
                   JAVA.PASSER$   = ''
                   FOR PRT.LP = 1 TO TOL.CNT<1>
                      OID = CTN.ID
                      UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,1,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY
                   NEXT PRT.LP
                   USE.ECLIPSE.FORMS$ = SV.ECLIPSE.FORMS
                   JAVA.PROC$         = SV.JAVA.PROC
                   JAVA.PASSER$       = SV.JAVA.PASSER
                END

             *------------------------------------------------------------*
             CASE UID<1,2> = 'PACK.MAINT' AND SUBR.NAME = '*PRODUCT.OUT'
                UID<1,4> = LOWER(LOWER(CTN.DATA))
                UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY,LOC

             *------------------------------------------------------------*
             CASE CTN.DATA AND SELCT = SELCT.ORDER.ONLY
                CTN.CT = DCOUNT(CTN.DATA<11>,VM)
*                FOR XX = 1 TO CTN.CT
                   OID      = FIELD(CTN.DATA<11,1>,'.',1)   ;*CTN.OIDS
                   OID = CTN.OID
                   IF OID THEN
                      GID      = FIELD(CTN.DATA<11,1>,'.',2)   ;*CTN.OIDS
                      LDID     = CTN.DATA<7,1>
                      ORIG.LDID= LDID
                      MATREAD LED FROM LEDFILE,OID ELSE MAT LED = ''
                      LOCATE GID IN LED(12)<1> SETTING GEN ELSE GEN = ''
                      LD.GET LDID
                      QTYP     = SELCT.VALUE.CURRENT.ITEM
                      *TOT.CNT  = CTN.DATA<5,XX>                 ;*LABELS
                      IF SUBR.NAME = '*CTN.OUT' OR SUBR.NAME = '*CTNSHP.OUT' THEN
                         UID = CTN.DATA
                         OID = CTN.OID
                      END
                      UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY
                   END
*                NEXT XX

             *------------------------------------------------------------*
             CASE UID<1,2> = 'PACK.MAINT'
                UID<1,4> = LOWER(LOWER(CTN.DATA))
                UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY

             *------------------------------------------------------------*
             CASE OTHERWISE
                IF OTYPE='P' AND UID<1,1>#'' THEN
                   *Use the part number passed from RF.INQ so that we print a
                   *label for a kit component rather than for the kit
                   LD(1) = UID<1,1>
                END
                UD.DOC.PRINT.ONE OID,GEN,ORIG.LDID,LDIDS,TOL.CNT,SUBR.NAME,FORM,ISPEC,QTYP,UID,DDE.SUBR,BOX.QTY
             END CASE
          END

          RETURN
*-------------------------------------------------------------------------*
INIT:     *** Initialize items needed in the rest of this subroutine
          *---------------------------------------------------------------*

          * Get the Print Selection TEXT STRING Constants that are
          * displayed to the user, and the INTEGER VALUES Constants that
          * represent these strings.
          UD.DOC.PRINT.GET.SELCTS SELCT.CURRENT.ITEM,SELCT.ALL.ITEMS,SELCT.ORDER.ONLY,SELCT.VALUE.CURRENT.ITEM,SELCT.VALUE.ALL.ITEMS,SELCT.VALUE.ORDER.ONLY

          RETURN
*-------------------------------------------------------------------------*
!TSMITH~08/03/17~13:46
