          SUBROUTINE (OID,GEN,LDID,LBL.NO,TOL.QTY,UDATA)
** Version# 11.0004[236] - 06/26/2013 - 10:43am - TSMITH - eclipse
*** V11.0004 Change - Custom Coding . - 06/26/2013 - TSMITH - eclipse
** BatchBuild Version# 1.0 - TSMITH
** This software is used to build a submittal for the user by assmebling all
** of the spec sheets attached to each product on the order and merging them
** using PDFTK. 
*-------------------------------------------------------------------------*
*** OID      - Order ID                                            [IN]
*** GEN      - Generation                                          [IN]
*** LDID     - Not Used
*** LBL.NO   - Not Used
*** TOL.QTY  - Total quantity shipped of last item (not useful)    (OUT)
*** UDATA    - Not Used
*-------------------------------------------------------------------------*
*** LED, LD, and PRD are self-contained in this routine. They do not need
*** to be current
*-------------------------------------------------------------------------*
          MODE = OID[1,1]
          IF MODE # 'S' THEN RETURN
          MATREAD LED FROM LEDFILE,OID ELSE MAT LED = ''
          OE.GET.QSIGN QSIGN,OID,GEN

          BR    = LED(2)<1,GEN,1>
          BT.CN = LED(1)<1,GEN,1>
          ST.CN = LED(5)<1,GEN,1>
          GET.CUS BR,BT.CN,ST.CN,QSIGN



          TB = CHAR(9)
          DESCTB = CHAR(10)
          DATA = ''
          JOB = OCONVT(LED(13)<1,GEN,1>,'MCT')
          IF JOB = '' THEN
          JOB = OCONV(TRANS('ENTITY',ST.CN,1,'X')<1,1,1>,'MCT')
          END

          DATA<-1> = '@ECHO off'
          DATA<-1> = 'ECHO Your submittal is being generated. Please wait...'
          DATA<-1> = 'ECHO When finished your submittal will open automatically. A blank submittal header'
          DATA<-1> = 'ECHO will be available in the c:\pdf\':JOB:'\ folder.'
          DATA<-1> = 'net use x: \\172.22.124.12\products >nul 2>&1'
          DATA<-1> = 'mkdir c:\pdf >nul 2>&1'
          DATA<-1> = 'copy x:\libiconv2.dll c:\pdf >nul 2>&1'
          DATA<-1> = 'copy x:\pdftk.exe c:\pdf >nul 2>&1'

          DATA<-1> = 'mkdir c:\pdf\':'"':JOB:'" >nul 2>&1'
          DATA<-1> = 'copy x:\submittal_cover_page.docx c:\pdf\':'"':JOB:'" >nul 2>&1'
          DATA<-1> = 'copy x:\submittal_header.doc c:\pdf\':'"':JOB:'" >nul 2>&1'

          MATBUILD SV.LD FROM LD

          OE.GET.LDID.LIST LDID.LIST,OID,GEN
          LDID.CT = DCOUNT(LDID.LIST,VM)
          FOR LDID.CTR = 1 TO LDID.CT
              LDID = LDID.LIST<1,LDID.CTR>
              LD.GET LDID


          GET.ALL.PRD BR,LD(1),QSIGN,GROUP
          PN      = LD(1)
          DESC    = TRANS('PRODUCT',PN,1,'X')<1,1,1>
          CONVERT "/" TO "-" IN DESC
          IF SUM(LD(5)<1,GEN>)+SUM(LD(6)<1,GEN>) = 0 THEN GOTO SKIP.LD
          SPEC.LIST=''
          UT.OPEN.FILE 'IMG.XREF',IMGFILE
          ROOT = 'P~':PN
          IMAGE.FLAG = NO
          BSCAN REC.ID,REC.VAL FROM IMGFILE,ROOT USING '&INDEX&.XREFS' ELSE NULL
          IF REC.ID = ROOT THEN
          IMAGE.FLAG = YES
          END
          IF IMAGE.FLAG = NO THEN GOTO SKIP.LD
          REC.VAL = REC.VAL<1,1>
          PATH = TRANS('IMG.ARCHIVES',TRANS('IMG.XREF',REC.VAL,7,'X'),2,'X')<1,1,1>;
          TYPE = OCONV(TRANS('IMG.XREF',REC.VAL,2,'X'),'MCL');
          POSITION=LD(24)<1,2>
          IF POSITION < 10 THEN
          POSITION = "0":POSITION
          END
          FULL.PATH = 'X:\':(PATH:'/':REC.VAL:'.':TYPE)[17,30]
          CONVERT "/" TO "\" IN FULL.PATH
          COMMAND = 'copy ':FULL.PATH:' c:\pdf\':'"':JOB:'" >nul 2>&1'
          SORT = 'ren c:\pdf\':'"':JOB:'"\':REC.VAL:'.':TYPE:' ':POSITION:'_':'"':DESC:'".':TYPE:' >nul 2>&1'
          CUST = TRANS('ENTITY',ST.CN,1,'X')<1,1,1>

          DATA<-1> = COMMAND
          DATA<-1> = SORT
SKIP.LD:  NEXT LDID

          MATPARSE LD FROM SV.LD
          DATA<-1>  = 'cd c:\pdf\':JOB
          CUST = TRANS('ENTITY',ST.CN,1,'X')<1,1,1>
          DATA<-1>  = 'c:\pdf\pdftk.exe *.pdf cat output "':CUST:'_':JOB:'.pdf"'
          DATA<-1>  = '"':CUST:'_':JOB:'.pdf"'
          DATA<-1>  = 'exit'

*          DATA<-1>  = 'pause'
          DCT = DCOUNT(DATA,AM)
          FOR J = 1 TO DCT

          PRINT DATA<J>
          NEXT J


FINISH:   RETURN
*-------------------------------------------------------------------------*
!TSMITH~06/26/13~10:43
