          SUBROUTINE (BATCH.TYPE,FILE,ERROR)
** Version# 4.0001[28] - 05/29/2011 - 10:48pm - SMITJR - eclipse
*** V4.0001 Change - Custom Coding CUSTOM - 05/29/2011 - SMITJR - eclipse

*** Subroutine - BATCH.FTP.SEND
*-------------------------------------------------------------------------*
***
***
***
*-------------------------------------------------------------------------*
***
***
***
*-------------------------------------------------------------------------*
***
***
***
*------------------------------------------------------------------------*

          GOSUB INIT

          BEGIN CASE
             CASE BATCH.TYPE = 'STMT'
                BATCH.STMT.FTP.SEND FILE,FTP.ERROR
             CASE BATCH.TYPE = 'BATCH.INV'
                BATCH.INV.FTP.SEND FILE,FTP.ERROR
             CASE OTHERWISE
                ERROR = 'MINOR'
          END CASE

          IF FTP.ERROR THEN
             ERROR = FTP.ERROR
             IF FTP.ERROR = 'NO ITEMS' THEN
                * delete the file as nothing is in it.
                UT.OPEN.FILE LOCAL.PATH,FTP.FILE,ERR.MSG
                DELETE FTP.FILE,CSV.NAME
             END
          END ELSE
             GOSUB SEND.FILE
          END

          RETURN
*-------------------------------------------------------------------------*
INIT:
          BEGIN CASE
             CASE BATCH.TYPE = 'STMT'
                FTP.REC = 'BATCH.STMT.FTP.INFO'
                FILE.INDEX = 1
             CASE BATCH.TYPE = 'BATCH.INV'
                FTP.REC = 'BATCH.INV.FTP.INFO'
                FILE.INDEX = 2
             CASE OTHERWISE
                ERROR = 'MINOR'
          END CASE

          READ FTP.INFO FROM CTRLFILE,FTP.REC ELSE
             FTP.INFO = ''
          END

          FTP.PARTY    = FTP.INFO<1>
          REMOTE.IP    = FTP.INFO<2>
          REMOTE.USER  = FTP.INFO<3>
          REMOTE.PWD   = FTP.INFO<4>
          REMOTE.PATH  = FTP.INFO<5>
          ARCHIVE.PATH = FTP.INFO<6>
          LOCAL.PATH   = FTP.INFO<7>
          CSV.NAME     = FILE<FILE.INDEX,1>:'.csv'
          ZIP.NAME     = FILE<FILE.INDEX,1>:'.txt'
          BT.NAME      = FILE<FILE.INDEX,2>:'.txt'
          FTP.ERROR    = ''

          RETURN
*-------------------------------------------------------------------------*
SEND.FILE:

          * zip the file first
          * 'zip -m /eclipse/ftp_temp/name.zip /eclipse/ftp_temp/*
         * EXE  = 'zip -m ':LOCAL.PATH:'/':ZIP.NAME
         * EXE := ' ':LOCAL.PATH:'/*'
         * IF OS.TYPE$ = 'NT' THEN CONVERT '/' TO '\' IN EXE
         * EXECUTE.OS.COMMAND ZIP.MSG,EXE
         * ZIP.MSG = RAISE(ZIP.MSG)

          * it is possible the above command can fail due to too many
          * signatures being added to the zip. As such, try a different
          * way of zipping, it is much slower but works.
         * FINDSTR '0403-027' IN ZIP.MSG SETTING POS1,POS2,POS3 THEN
         *    EXE  = 'ls ':LOCAL.PATH:' | xargs -t -I {} '
         *    EXE := 'zip -m -j ':LOCAL.PATH:'/':ZIP.NAME
         *    EXE := ' ':LOCAL.PATH:'/{}'
         *    IF OS.TYPE$ = 'NT' THEN CONVERT '/' TO '\' IN EXE
         *    EXECUTE.OS.COMMAND NULL,EXE
         * END

         * EXE = 'zip -T ':LOCAL.PATH:'/':ZIP.NAME
         * IF OS.TYPE$ = 'NT' THEN CONVERT '/' TO '\' IN EXE
         * EXECUTE.OS.COMMAND ZIP.MSG,EXE


          *FINDSTR 'OK' IN ZIP.MSG SETTING POS1,POS2,POS3 THEN

             * ftp the file
             FTP.SEND REMOTE.IP,REMOTE.USER,REMOTE.PWD,LOCAL.PATH,ZIP.NAME,REMOTE.PATH,BT.NAME,NO,'*',RESULTS,TSTATUS,FTP.OK

       *      IF NOT(FTP.OK) THEN
       *         STAT.MSG = 'A problem occurred while attempting to FTP '
       *         STAT.MSG := ZIP.NAME:' to ':FTP.PARTY:'. The following '
       *         STAT.MSG := 'results were returned: '
       *         RESULTS = STAT.MSG:AM:RESULTS
       *         BATCH.LOG.MSG.SET BATCH.TYPE,'STATUS',RESULTS
       *         ERROR = 'MINOR'
       *      END
       *   END ELSE
       *      STAT.MSG = 'A problem occurred while attempting to ZIP '
       *      STAT.MSG := ZIP.NAME:' prior to sending to ':FTP.PARTY
       *      STAT.MSG := ' The following result was returned: '
       *      BATCH.LOG.MSG.SET BATCH.TYPE,'STATUS',ZIP.MSG
       *      ERROR = 'FATAL'
       *   END

          OPEN ARCHIVE.PATH TO ARCH.FILE ELSE
             MOD = 101
             SEP = 1
             TYP = 19
             CMD  = "CREATE-FILE ":ARCHIVE.PATH:' 1 ':MOD:',':SEP:',':TYP
             EXECUTE CMD CAPTURING MSG
          END

          * move the file to the archive directory
          UT.MOVE.FILE LOCAL.PATH,ZIP.NAME,ARCHIVE.PATH,ZIP.NAME

          RETURN
*-------------------------------------------------------------------------*
!RYANB~11/03/05~11:44

!SMITJR~05/29/11~22:48
