          SUBROUTINE (OID,GEN,LDID,LDID.LIST,QSIGN,XRATE,COPY.COST,KEYS,AMTS,SUBTOTAL.LDIDS,SHOW.PRC,BACK.TO,INI.CMT,GP.VIEW,VALID.SUB.DATA,ST.POS,END.POS,LD.ARRAY,PRICE.EDIT.OK,LINE,PRC.KEY,DO.TAG.COPY.COST)
** Version# 21.0001[9] - 09/17/2014 - 11:43am - TSMITH - eclipse
*** V21.0001 Change - Custom Coding . - 09/17/2014 - TSMITH - eclipse

*** SUBROUTINE : JAVA.SUBTOTALS.GET.DATA
*-------------------------------------------------------------------------*
*** This subroutine gets the data for solar's subtotal dialog screen.
*-------------------------------------------------------------------------*
*** OID            - order id                                         [In]
*** GEN            - open order generation                            [In]
*** LDID           - ledger detail ID                                 [In]
*** LDID.LIST      - ledger detail ID list                            [In]
*** QSIGN          - the order's qsign                                [In]
*** XRATE                                                            [Out]
*** COPY.COST                                                        [Out]
*** KEYS                                                             [Out]
*** AMTS                                                             [Out]
*** SUBTOTAL.LDIDS                                                   [Out]
*** SHOW.PRC                                                         [Out]
*** SHOW.PRC
*** INI.CMT                                                          [Out]
*** GP.VIEW                                                          [Out]
*** VALID.SUB.DATA - Used for the Back-To validation (disps and ids) [Out]
*** ST.POS                                                           [Out]
*** END.POS                                                          [Out]
*** LD.ARRAY                                                         [Out]
*** PRICE.EDIT.OK                                                    [Out]
*** LINE           - The line the subtotal should be placed.         [In]
*-------------------------------------------------------------------------*

          DIM LD2(50)

          *** Get Override flag from control file
          CTRB.ID = "COST.OVERRIDE~":LED(2)<1,GEN,1>
          READV COPY.COST FROM CTRBFILE,CTRB.ID,1 ELSE COPY.COST=''
          KEYS           = ''
          AMTS           = ''
          SUBTOTAL.LDIDS = ''
          VALID.SUB.DATA = ''




          * Set up the xchange rate info
          IF LED(92)<1,GEN,2> THEN
             XRATE = OCONV(LED(92)<1,GEN,2>,'MR4')
          END ELSE
             XRATE = 1
          END

          IF LDID='' THEN
             MAT LD = ''
             LD(1) = 'S'
             * create the ld for the subtotal
             OE.NEW.LDID OID,LDID,LDID.LIST,LINE
             * add it to LDID.LIST
             LINE.XREF = AM:AM:AM:AM:LINE
             OE.INSERT.LDID LDID.LIST,LINE.XREF,,LDID
          END ELSE
             MATBUILD SV.LD FROM LD
             IF SV.LD = '' THEN
                MATPARSE LD FROM LD.ARRAY
             END
          END

          GOSUB VALID.SUBS

          ** Check to see if a back to subtotal was passed in.
          IF BACK.TO # '' THEN
             IF BACK.TO # 'Top of Order' THEN
                LOCATE BACK.TO IN VALID.TOTS<1> SETTING TPOS THEN
                   LD(43) = VALID.TLDIDS<1,TPOS>
                END ELSE
                   LD(43) = BACK.TO
                END
             END ELSE
                LD(43) = BACK.TO
             END
          END

          COGS.VIEW.OK = NO
          COGS.EDIT.OK = NO
          COST.VIEW.OK = NO
          COST.EDIT.OK = NO
          POE.BID.EDIT.OK = NO
          POE.OPEN.EDIT.OK = NO
          SUBTOTAL.LDIDS = ''
          SLS.SUB        = ''
          COGS.SUB       = ''
          COST.SUB       = ''
          WGHT.SUB.GEN   = ''
          LOAD.SUB.GEN   = ''
          OE.SUBTOTALS.INIT OID,GEN,LDID,LDID.LIST,QSIGN,COGS.VIEW.OK,COGS.EDIT.OK,COST.VIEW.OK,COST.EDIT.OK,SUBTOTAL.LDIDS,SLS.SUB.GEN,COGS.SUB.GEN,COST.SUB.GEN,WGHT.SUB.GEN,LOAD.SUB.GEN,ST.POS,END.POS,POE.BID.EDIT.OK,POE.OPEN.EDIT.OK,PRC.KEY,PRC.KEY.OVRD,NO,COPY.COST,DO.TAG.COPY.COST,DO.COPY.COST,TAG.FOUND


          IF USER.ID = "JACKC" THEN
          COGS.VIEW.OK = NO
          END



          IF NOT(COGS.VIEW.OK) THEN
             COGS.SUB = ''
          END
          IF NOT(COST.VIEW.OK) THEN
             COST.SUB = ''
          END
          FORM          = LD(15)<1,GEN,1>
          BASN          = LD(15)<1,GEN,2>
          SLS.SUB       = LD(8)<1,GEN>*QSIGN
          COGS.SUB      = LD(10)<1,GEN>*QSIGN
          COST.SUB      = LD(27)<1,GEN>*QSIGN
          SHOW.PRC      = LD(21)
          KEYS<1,1> = COGS.VIEW.OK
          KEYS<1,2> = COGS.EDIT.OK
          KEYS<1,3> = COST.VIEW.OK
          KEYS<1,4> = COST.EDIT.OK
          KEYS<1,5> = POE.BID.EDIT.OK
          KEYS<1,6> = POE.OPEN.EDIT.OK
          AMTS<1,1> = SLS.SUB/XRATE
          AMTS<1,2> = COGS.SUB/XRATE
          AMTS<1,3> = COST.SUB/XRATE
          AMTS<1,4> = WGHT.SUB.GEN
          AMTS<1,5> = LOAD.SUB.GEN

          * Prepass for subtotal pricing detail Y/N
          BT.CN  = LED(1)<1,GEN>
          IF BT.CN = '675' AND LD(1)='S' THEN
          SHOW.PRC = '1'
          END


          IF NUM(LD(43)) AND LD(43) # '' AND LD(43) # 0 THEN
             LD.GET2 MAT LD2, LD(43)
             BACK.TO = TRIM(LD2(3)<1,1> "L#20"):' ':OCONV(LD2(8)<1,GEN>*QSIGN,'MR2#10')
          END ELSE
             BACK.TO = LD(43)
          END
          IF BACK.TO = '' OR BACK.TO = 0 THEN BACK.TO = 'Last Subtotal'

          IF LD(8)='' AND LD(3)=''  THEN
             INI.CMT = 'Subtotal -------'
          END ELSE
             INI.CMT    = LD(3)
          END


          METH = LED(97)<1,GEN,3>
          BEGIN CASE
             CASE METH = 'Weighted Avg'; GP.VIEW = 0
             CASE METH = 'Flat GP%';     GP.VIEW = 1
             CASE OTHERWISE;             GP.VIEW = 1
          END CASE

          MATBUILD LD.ARRAY FROM LD

          CT = DCOUNT(LDID.LIST, VM)
          FOR I = 1 TO CT
             LD.GET LDID.LIST<1,I>
             GET.ALL.PRD LED(2)<1,GEN,1>,LD(1),QSIGN
             OE.CHECK.PRC.RESTRICT OID, GEN,LDID.LIST<1,I>,PRICE.EDIT.OK
             IF LD(15)<1,GEN,15> THEN
                PRICE.EDIT.OK = 'MATRIX.NO'
             END
             IF NOT(PRICE.EDIT.OK) THEN EXIT
             IF PRICE.EDIT.OK = 'MATRIX.NO' THEN EXIT
          NEXT I
          RETURN
*-------------------------------------------------------------------------*
VALID.SUBS: *
          OE.SUBTOTALS.GET.TOT.LIST LDID,LDID.LIST,GEN,QSIGN,XRATE,VALID.TLDIDS,VALID.TOTS

          VALID.SUB.DATA<1>   = VALID.TLDIDS
          VALID.SUB.DATA<2>   = VALID.TOTS

          RETURN
!TSMITH~09/17/14~11:43
