          SUBROUTINE (HITS)
** Version# 4.0002[2] - 09/02/2010 - 01:10pm - SMITJR - eclipse
*** V4.0002 Change - Custom Coding .. - 09/02/2010 - SMITJR - eclipse
** Copied from BP DICT.PRD.HITS Version# 4 - 03/08/1999 - 01:22pm - CASEY - develop
          BEG.DT = DICT.COMMON<3> "R%5"
          END.DT = DICT.COMMON<4> "R%5"
          PN = FIELD(@ID,'~',1)

          IF SEL.BR='' THEN SEL.BR=SECURITY<9>
          BR.CT = DCOUNT(SEL.BR,VM)
          HITS = 0
          GOSUB SUMYR

          RETURN
*-------------------------------------------------------------------------*
SUMYR:    *
          FOR BRX=1 TO BR.CT
             BR = SEL.BR<1,BRX>
             ROOT = PN:'~':BR:'~':BEG.DT

*** Changed to use the PSUBFILE instead of the prod.trans file.
             LOOP
             BSCAN ID FROM PSUBFILE,ROOT USING "&INDEX&" ELSE EXIT
             ROOT = ''
             IF FIELD(ID,'~',1)#PN OR FIELD(ID,'~',2)#BR THEN EXIT
             IF FIELD(ID,'~',3)+0 > END.DT               THEN EXIT
             GOSUB SUM.ID
             REPEAT

          NEXT BRX

          RETURN
*-------------------------------------------------------------------------*
SUM.ID:   *
          READV QTY FROM PSUBFILE,ID,1 ELSE QTY = ''
          OID    = FIELD(ID,'~',4)
          LOCA   = FIELD(ID,'~',8)
          TYPE   = FIELD(ID,'~',7)
          MODE   = OID[1,1]
          IF MODE = "S" AND INDEX(STK.TYPES.DMD$,TYPE[1,1],1) THEN
             QTY = -QTY
             IF QTY > 0 THEN
                HITS += 1
             END
          END
          RETURN
!SMITJR~09/02/10~13:10
