ECHO OFF

rem Delete previous "junk" files
del %PRODPATH%\junk.file

rem *******************************************************************************
rem                                 W A R N I N G:                                *
rem                                 W A R N I N G:                                *
rem                                 W A R N I N G:                                *
rem ==============================================================================*
rem  DO NOT EXECUTE THIS FILE DIRECTLY FROM THE DOS COMMAND LINE.                 *
rem                                                                               *
rem  Instead, this bat file is meant to be executed by being called from another  *
rem  .bat file.                                                                   *
rem ==============================================================================*

IF .%SPLBILL_CALLED_SWITCH% == .Y                                  GOTO  CALLED-OKAY
ECHO *******************************************************************************
ECHO *                               W A R N I N G:                                *
ECHO *                               W A R N I N G:                                *
ECHO *                               W A R N I N G:                                *
ECHO *                               W A R N I N G:                                *
ECHO *=============================================================================*
ECHO * DO NOT EXECUTE THIS FILE DIRECTLY FROM THE COMMAND LINE.                    *
ECHO *                                                                             *
ECHO * Instead, this bat file is meant to be executed by being called from another *
ECHO * .bat file.                                                                  *
ECHO *                                                                             *
ECHO * On the Command Line, execute a Master Command File                          *
ECHO ==============================================================================*
PAUSE
SET    DOC1-BILL-RC=16
GOTO ENDRUN

:CALLED-OKAY
SET   SPLBILL_CALLED_SWITCH=N

rem *******************************************************************************
rem  Platform:      NT                                                            *
rem  Printstream:   PostScript / PDF                                              *
rem  Application:   SPL Bill Print                                                *
rem ==============================================================================*
rem  Command File called to execute integrated DOC1 / Code-1 / MailStream         *
rem  for SPL Bill Print                                                           *
rem ==============================================================================*
rem  This Command File should NOT be run from the command line; instead, a Master *
rem  Command file is run on the command line; the Master Command File will call   *
rem  this command file.  The following sample Master Command Files are available: *
rem      splbill_s5_v3_main_batch_postscript.bat                                  *
rem              - Will produce PostScript formatted documents                    *
rem      splbill_s5_v3_main_batch_pdf.bat                                         *
rem              - Will produce PDF formatted documents                           *
rem ==============================================================================*
rem  The Master Command File must set the following symbols prior to calling this *
rem  command file:                                                                *
rem                                                                               *
rem    G E N E R A L   S Y M B O L S                                              *
rem    =============================                                              *
rem      LOGFILE                                                                  *
rem              - Name of a log file to be created by this process               *
rem              - Previous version of file will be replaced                      *
rem              - File will be written to %PRODPATH% directory                   *
rem              - Sample coding:  LOGFILE=cis-bill.log                           *
rem      SPLBILL_CALLED_SWITCH                                                    *
rem              - Must be set to "Y"                                             *
rem              - This process will reset to "N"                                 *
rem              - Used by to insure that this process was invoked by a Master    *
rem                Command File                                                   *
rem      PRODPATH                                                                 *
rem              - Names directory for output files from Sort, DOC1, Code-1,      *
rem                and MailStream; there will be a few exceptions of files that   *
rem                both Code-1 and MailStream write to their own root directories *
rem                %G1C1P%\DATA and %G1MSP%\DATA                                  *
rem              - Sample coding: PRODPATH=C:\Doc1 Production Files               *
rem                                                                               *
rem    D O C 1   S Y M B O L S                                                    *
rem    =======================                                                    *
rem      D1HOST                                                                   *
rem              - Names root directory where the DOC1 Generate was installed     *
rem              - Typical value:                                                 *
rem                D1HOST=C:\Program Files\DOC1 Suite\Production Engines          *
rem      D1APPATH                                                                 *
rem              - Names directory containing HIP, OPS, INI, CTL, ETS             *
rem              - Sample coding:                                                 *
rem                D1APPATH=C:\Program Files\DOC1 Suite\Designer\resource\bill    *
rem      GEN_OPS                                                                  *
rem              - Names DOC1GEN Initialization file for Format Bills step        *
rem              - Sample value: EMFE-INI=splbill-v2-emfe.ini                     *
rem              - File must be present in the %D1APPATH% directory               *
rem      GEN_HIP                                                                  *
rem              - Filename ONLY of  DOC1GENE Application Rules                   *
rem              - Sample value: GEN_HIP=splbill_s5_v1_doc1gen.hip                *
rem              - File must be present in the %D1APPATH% directory               *
rem      GEN_ETS                                                                  *
rem              - Names Look-Up file converting Country codes to Country Names   *
rem              - Sample value: GEN_ETS=splbill_s5_v1_doc1gen.ets                *
rem              - File must be present in the %D1APPATH% directory               *
rem      GEN_CNTL                                                                 *
rem              - Names Look-Up file containing formatting control codes         *
rem              - Sample value: GEN_CNTL=splbill_s5_v3_doc1gen_control_pdf.ets   *
rem              - File must be present in the %D1APPATH% directory               *
rem      FRGN_PCE_INI                                                             *
rem              - Names DOC1PCE Initialization file for Foreign step             *
rem              - Sample value: FRGN_PCE_INI=splbill_s5_v1_frgnsplt_pce.ini      *
rem              - File must be present in the %D1APPATH% directory               *
rem      FRGN_PCE_CTL                                                             *
rem              - Names DOC1PCE Rules file for Foreign step                      *
rem              - Sample value: FRGN_PCE_CTL=splbill_s5_v1_frgnsplt_pce.ctl      *
rem              - File must be present in the %D1APPATH% directory               *
rem      CHADR_PCE_INI                                                            *
rem              - Name of the DOC1PCE Initialization File                        *
rem              - Sample value: CHADR_PCE_INI=splbill_s5_v1_code1chng_pce.ini    *
rem              - File must be present in the %D1APPATH% directory               *
rem      CHADR_PCE_CTL                                                            *
rem              - Name of the DOC1PCE Rules to changed address Journal records   *
rem              - Sample value: CHADR_PCE_CTL=splbill_s5_v1_code1chng_pce.ctl    *
rem              - File must be present in the %D1APPATH% directory               *
rem      SPCL_PCE_INI                                                             *
rem              - Names DOC1PCE Initialization file for Special Handling step    *
rem              - Sample value: SPCL_PCE_INI=splbill_s5_v1_spcsplt_pce.ini       *
rem              - File must be present in the %D1APPATH% directory               *
rem      SPCL_PCE_CTL                                                             *
rem              - Names DOC1PCE Rules file for Special Handling step             *
rem              - Sample value: SPCL_PCE_CTL=splbill_s5_v1_spcsplt_pce.ctl       *
rem              - File must be present in the %D1APPATH% directory               *
rem      LOGOXML                                                                  *
rem              - Names XML file that identifies the bitmap used for a company   *
rem                logo and contains sizing attributes of the bitmap              *
rem              - Sample value: LOGOXML=splbill_s5_v3_doc1gen_logo.xml           *
rem              - File must be present in the %D1APPATH% directory               *
rem      MAXAUTO                                                                  *
rem              - Identifies the maximum number of sheets that a Bill may        *
rem                contain and still be considered an Automated Bill; if a Bill   *
rem                has more sheets than the MAXAUTO value, the Bill will be       *
rem                classified as an Oversized Bill                                *
rem              - Sample value: MAXAUTO=6                                        *
rem      CPRT_PCE_INI                                                             *
rem              - Names DOC1PCE Initialization file for Post Process step        *
rem              - Sample value: CPRT_PCE_INI=splbill_s5_v1_createprt_pce.ini     *
rem              - File must be present in the %D1APPATH% directory               *
rem      CPRT_PCE_CTL                                                             *
rem              - Names DOC1PCE Rules file for Post Process step                 *
rem              - Sample value: CPRT_PCE_CTL=splbill_s5_v1_createprt_pce.ctl     *
rem              - File must be present in the %D1APPATH% directory               *
rem                                                                               *
rem    S P L   S Y M B O L S                                                      *
rem    =====================                                                      *
rem      XTRCTPTH                                                                 *
rem              - Names directory containing SPL Bill Print Extract              *
rem              - Sample coding: XTRCTPTH=C:\CIS\EXTRACT                         *
rem      SPL_UNSORTED_EXTRACT                                                     *
rem              - Names SPL Bill Print Extract                                   *
rem              - Typical coding SPL_UNSORTED_EXTRACT=bpxtr01.dat                *
rem                                                                               *
rem    P R I N T   S Y M B O L S                                                  *
rem    =========================                                                  *
rem      PADDR-BILLS-1UP                                                          *
rem              - Directory where DOC1 Formatted Print for 1-up printing will be *
rem                output; for AFP, this is a "hot folder"; for PostScript, this  *
rem                is a directory.                                                *
rem              - Sample: PADDR-BILLS-1UP=\\InfoPrintServer\hotfolders\4000-1up  *
rem      PADDR-BILLS-2UP                                                          *
rem              - Directory where DOC1 Formatted Print for 2-up printing will be *
rem                output; for AFP, this is a "hot folder"; for PostScript, this  *
rem                is a directory.                                                *
rem              - Sample: PADDR-BILLS-2UP=\\InfoPrintServer\hotfolders\4000-2up  *
rem      PADDR-REPORTS-PORT                                                       *
rem              - IP Address of printer where Code-1 reports will be output;     *
rem                for AFP, this is a "hot folder"; for PostScript, this is a     *
rem                directory.                                                     *
rem              - Sample coding: PADDR-REPORTS-PORT=z:\hotfolder\port            *
rem      PADDR-REPORTS-LAND                                                       *
rem              - IP Address of printer where MailStream reports will be output; *
rem                for AFP, this is a "hot folder"; for PostScript, this is a     *
rem                directory.                                                     *
rem              - Sample coding: PADDR-REPORTS-LAND=z:\hotfolder\land            *
rem      PRINTFILES                                                               *
rem              - May be:  Y or N                                                *
rem              - "N" prevents files from being sent to PADDR printer            *
rem      PSTREAM                                                                  *
rem              - May be AFPDS or PostScript                                     *
rem              - Controls type of print description language for output         *
rem                                                                               *
rem    D E L E T E   &   S A V E   S Y M B O L S                                  *
rem    =========================================                                  *
rem      DELETEFILES                                                              *
rem              - May be:  Y or N                                                *
rem              - "N" prevents work files from being deleted                     *
rem                                                                               *
rem    C O D E - 1 / M A I L S T R E A M   S Y M B O L S                          *
rem    =================================================                          *
rem      G1DB                                                                     *
rem              - Names directory containing Code-1 + MailStream databases       *
rem              - Code-1/MailStream installations set as an environment variable *
rem              - Typical value: G1DB=C:\Program Files\Group1\DB                 *
rem              - The following Code-1 files must be in the %G1DB% directory:    *
rem                  - CITYDB      - CITYNM      - COUNTY      - DTLDB            *
rem                  - LCLDB       - LTMASTR     - PTRDB       - ZIPIDX           *
rem                  - Z4CHNG      - G1C1AUX     - DPVLCD      - DPVMST           *
rem              - The following MailStream files must be in the %G1DB% directory:*
rem                  - PRFDLVCT    - PRFDSTNM    - PRFMXCTY    - PRFRTMAP         *
rem                  - PRFSQREF    - PRFZIPDR    - PRFZONES    - PRFPSTMT         *
rem      G1C1P                                                                    *
rem              - Names directory where Code-1 Plus was installed                *
rem              - Code-1 installation sets as an environment variable            *
rem              - Typical value: G1C1P=C:\Program Files\Group1\C1P               *
rem              - The following file must be in the %G1C1P%\DATA directory:      *
rem                  - G1LMLIC                                                    *
rem              - The following file must be in the %G1C1P%\DLL directory:       *
rem                  - C1BM00                                                     *
rem      C1PRM                                                                    *
rem              - Name of the Code-1 Parameter File                              *
rem              - Sample value: C1PRM=SPL-doc1.prm                               *
rem              - File must be present in the %G1C1P%\DATA directory             *
rem      CODE1                                                                    *
rem              - May be:  Y or N                                                *
rem              - "N" allows Code-1 Plus to be bypassed                          *
rem      G1MSP                                                                    *
rem              - Names directory where MailStream Plus was installed            *
rem              - MailStream installation sets as an environment variable        *
rem              - Typical value: G1MSP=C:\Program Files\Group1\MSP               *
rem              - The following file must be in the %G1MSP%\CMDS directory:      *
rem                  - MSPRUN.VBS                                                 *
rem      MSTREAM-JOB                                                              *
rem              - Name of the MailStream Parameter File                          *
rem              - Sample value: MSTREAM-JOB=SPL-doc1.                            *
rem              - File must be present in the %G1MSP%\DATA directory             *
rem      MSTREAM                                                                  *
rem              - May be:  Y or N                                                *
rem              - "N" allows MailStream Plus to be bypassed                      *
rem ==============================================================================*
rem    Step 01:  Sort SPL extract to re-arrange records within document           *
rem    Step 02:  Format Bills (DOC1EMFE) - for Hardcopy Output                    *
rem    Step 03:  Identify Foreign Addressed Bills (DOC1PCE)                       *
rem    Step 04:  Sort Foreign Address Journal Records                             *
rem    Step 05:  Address Correction (Code-1)                                      *
rem    Step 06:  Identify Corrected Addresses (DOC1PCE)                           *
rem    Step 07:  Identify Special Handling Bills (DOC1PCE)                        *
rem    Step 08:  Sort Special Handling Journal Records                            *
rem    Step 09:  Postal Pre-Sort (MailStream)                                     *
rem    Step 10:  Create Print Files (DOC1PCE)                                     *
rem    Step 11:  Copy Print Files to Printer                                      *
rem    Termination:  Delete Files                                                 *
rem    Termination:  Save Final Print and Audit Files                             *
rem *******************************************************************************

rem *******************************************************************************
rem ** Validate General Symbols (PRODPATH and LOGFILE) before anything can begin  *
rem *******************************************************************************

IF    NOT ".%PRODPATH%" == .                                       GOTO    SYMCHK_PRODPATH-CODED
ECHO No value set for the symbol PRODPATH - Job cannot be run
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:SYMCHK_PRODPATH-CODED

IF    EXIST "%PRODPATH%"                                           GOTO    SYMCHK_PRODPATH-PRESENT
ECHO Directory %PRODPATH% not found - Job cannot be run
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:SYMCHK_PRODPATH-PRESENT

IF    NOT ".%LOGFILE%" == .                                        GOTO    SYMCHK_LOGFILE-CODED
ECHO No value set for the symbol PRODPATH - Job cannot be run
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:SYMCHK_LOGFILE-CODED

IF    EXIST "%PRODPATH%\%LOGFILE%"                                 DEL     "%PRODPATH%\%LOGFILE%"

SET  "RUN-DATE=%DATE%"
SET  "RUN-TIME=%TIME%"

ECHO Begin Print Job for SPL Bill Print
ECHO Begin Print Job for SPL Bill Print                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO    Run Date = %RUN-DATE%                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO    Run Time = %RUN-TIME%                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 01:  Sort SPL extract to re-arrange records within document                            >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 02:  Format Bills (DOC1EMFE) - for Hardcopy Output                                     >> "%PRODPATH%\%LOGFILE%"
IF %RUN_TYPE% == ONLINE                                            GOTO   DOECHO-DONE
ECHO    Step 03:  Identify Foreign Addressed Bills (DOC1PCE)                                        >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 04:  Sort Foreign Address Journal Records                                              >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 05:  Address Correction (Code-1)                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 06:  Identify Corrected Addresses (DOC1PCE)                                            >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 07:  Identify Special Handling Bills (DOC1PCE)                                         >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 08:  Sort Special Handling Journal Records                                             >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 09:  Postal Pre-Sort (MailStream)                                                      >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 10:  Create Print Files (DOC1PCE)                                                      >> "%PRODPATH%\%LOGFILE%"
ECHO    Step 11:  Copy Print Files to Printer                                                       >> "%PRODPATH%\%LOGFILE%"
:DOECHO-DONE
ECHO "========================================================================="                    >> "%PRODPATH%\%LOGFILE%"

ECHO Begin Symbol Validation                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO      PRODPATH = %PRODPATH%                                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO      LOGFILE = %LOGFILE%                                                                       >> "%PRODPATH%\%LOGFILE%"

SET   FATALERR=N

rem *******************************************************************************
rem ** Validate DOC1 Symbols                                                      *
rem *******************************************************************************

ECHO      D1HOST = %D1HOST%                                                                         >> "%PRODPATH%\%LOGFILE%"

IF    NOT ".%D1HOST%" == .                                         GOTO    SYMCHK_D1HOST_CODED
ECHO No value set for the symbol D1HOST
ECHO No value set for the symbol D1HOST                                                             >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_D1HOST-DONE

:SYMCHK_D1HOST_CODED
IF    EXIST "%D1HOST%"                                             GOTO    SYMCHK_D1HOST_PRESENT
ECHO Doc1 Generate Directory "%D1HOST%" not found 
ECHO Doc1 Generate Directory "%D1HOST%" not found                                                   >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_D1HOST-DONE

:SYMCHK_D1HOST_PRESENT

:SYMCHK_D1HOST-DONE

ECHO      D1APPATH = %D1APPATH%                                                                     >> "%PRODPATH%\%LOGFILE%"

IF    NOT ".%D1APPATH%" == .                                       GOTO    SYMCHK_D1APPATH_CODED
ECHO No value set for the symbol D1APPATH
ECHO No value set for the symbol D1APPATH                                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_D1APPATH-DONE

:SYMCHK_D1APPATH_CODED
IF    EXIST "%D1APPATH%"                                           GOTO    SYMCHK_D1APPATH_PRESENT
ECHO Doc1 Application Directory "%D1APPATH%" not found 
ECHO Doc1 Application Directory "%D1APPATH%" not found                                              >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_D1APPATH-DONE

:SYMCHK_D1APPATH_PRESENT

ECHO Directory content of Doc1 Application Directory follows:                                       >> "%PRODPATH%\%LOGFILE%"
DIR "%D1APPATH%"                                                                                    >> "%PRODPATH%\%LOGFILE%"

ECHO      GEN_OPS = %GEN_OPS%                                                                       >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%GEN_OPS%"                                 GOTO   SYMCHK_GEN_OPS_PRESENT
ECHO DOC1GEN Initialization file "%D1APPATH%\%GEN_OPS%" not found 
ECHO DOC1GEN Initialization file "%D1APPATH%\%GEN_OPS%" not found                                   >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_GEN_OPS_PRESENT

ECHO      GEN_HIP = %GEN_HIP%                                                                       >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%GEN_HIP%"                                 GOTO   SYMCHK_GEN_HIP_PRESENT
ECHO DOC1GEN Application Rules file "%D1APPATH%\%GEN_HIP%" not found 
ECHO DOC1GEN Application Rules file "%D1APPATH%\%GEN_HIP%" not found                                >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_GEN_HIP_PRESENT

ECHO      GEN_ETS = %GEN_ETS%                                                                       >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%GEN_ETS%"                                 GOTO   SYMCHK_GEN_ETS_PRESENT
ECHO Extended Text Substitution file "%D1APPATH%\%GEN_ETS%" not found 
ECHO Extended Text Substitution file "%D1APPATH%\%GEN_ETS%" not found                               >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_GEN_ETS_PRESENT


ECHO      FRGN_PCE_INI = %FRGN_PCE_INI%                                                             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%FRGN_PCE_INI%"                            GOTO   SYMCHK_FRGN_PCE_INI_PRESENT
ECHO DOC1PCE Identify Foreign Bills Initialization file "%D1APPATH%\%FRGN_PCE_INI%" not found
ECHO DOC1PCE Identify Foreign Bills Initialization file "%D1APPATH%\%FRGN_PCE_INI%" not found       >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_FRGN_PCE_INI_PRESENT

ECHO      FRGN_PCE_CTL = %FRGN_PCE_CTL%                                                             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%FRGN_PCE_CTL%"                            GOTO   SYMCHK_FRGN_PCE_CTL_PRESENT
ECHO DOC1PCE Identify Foreign Bills Rules file "%D1APPATH%\%FRGN_PCE_CTL%" not found
ECHO DOC1PCE Identify Foreign Bills Rules file "%D1APPATH%\%FRGN_PCE_CTL%" not found                >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_FRGN_PCE_CTL_PRESENT

ECHO      SPCL_PCE_INI = %SPCL_PCE_INI%                                                             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%SPCL_PCE_INI%"                            GOTO   SYMCHK_SPCL_PCE_INI_PRESENT
ECHO DOC1PCE Identify Special Handling Initialization file "%D1APPATH%\%SPCL_PCE_INI%" not found
ECHO DOC1PCE Identify Special Handling Initialization file "%D1APPATH%\%SPCL_PCE_INI%" not found    >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_SPCL_PCE_INI_PRESENT

ECHO      SPCL_PCE_CTL = %SPCL_PCE_CTL%                                                             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%SPCL_PCE_CTL%"                            GOTO   SYMCHK_SPCL_PCE_CTL_PRESENT
ECHO DOC1PCE Identify Special Handling Rules file "%D1APPATH%\%SPCL_PCE_CTL%" not found
ECHO DOC1PCE Identify Special Handling Rules file "%D1APPATH%\%SPCL_PCE_CTL%" not found             >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_SPCL_PCE_CTL_PRESENT

ECHO      MAXAUTO = %MAXAUTO%                                                                       >> "%PRODPATH%\%LOGFILE%"

IF    NOT .%MAXAUTO% == .                                          GOTO    SYMCHK_MAXAUTO_CODED
ECHO No value set for the symbol MAXAUTO
ECHO No value set for the symbol MAXAUTO                                                            >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_MAXAUTO_CODED

ECHO      CPRT_PCE_INI = %CPRT_PCE_INI%                                                             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%CPRT_PCE_INI%"                            GOTO   SYMCHK_CPRT_PCE_INI_PRESENT
ECHO DOC1PCE Create Print Initialization file "%D1APPATH%\%CPRT_PCE_INI%" not found
ECHO DOC1PCE Create Print Initialization file "%D1APPATH%\%CPRT_PCE_INI%" not found                 >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_CPRT_PCE_INI_PRESENT

ECHO      CPRT_PCE_CTL = %CPRT_PCE_CTL%                                                             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%CPRT_PCE_CTL%"                            GOTO   SYMCHK_CPRT_PCE_CTL_PRESENT
ECHO DOC1PCE Post Process Rules file "%D1APPATH%\%CPRT_PCE_CTL%" not found
ECHO DOC1PCE Post Process Rules file "%D1APPATH%\%CPRT_PCE_CTL%" not found                          >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_CPRT_PCE_CTL_PRESENT

:SYMCHK_D1APPATH-DONE

rem *******************************************************************************
rem ** Validate SPL Symbols                                                       *
rem *******************************************************************************

ECHO      XTRCTPTH = %XTRCTPTH%                                                                     >> "%PRODPATH%\%LOGFILE%"

IF    NOT ".%XTRCTPTH%" == .                                       GOTO    SYMCHK_XTRCTPTH_CODED
ECHO No value set for the symbol XTRCTPTH
ECHO No value set for the symbol XTRCTPTH                                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SPL-DONE

:SYMCHK_XTRCTPTH_CODED
IF    EXIST "%XTRCTPTH%"                                           GOTO    SYMCHK_XTRCTPTH_PRESENT
ECHO SPL Extract Directory "%XTRCTPTH%" not found 
ECHO SPL Extract Directory "%XTRCTPTH%" not found                                                   >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SPL-DONE

:SYMCHK_XTRCTPTH_PRESENT

ECHO      SPL_UNSORTED_EXTRACT = %SPL_UNSORTED_EXTRACT%                                             >> "%PRODPATH%\%LOGFILE%"

IF    NOT ".%SPL_UNSORTED_EXTRACT%" == .                           GOTO    SYMCHK_SPL_UNSORTED_EXTRACT_CODED
ECHO No value set for the symbol SPL_UNSORTED_EXTRACT
ECHO No value set for the symbol SPL_UNSORTED_EXTRACT                                               >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SPL_UNSORTED_EXTRACT-DONE

:SYMCHK_SPL_UNSORTED_EXTRACT_CODED
IF    EXIST "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"                    GOTO    SYMCHK_SPL_UNSORTED_EXTRACT-DONE
ECHO SPL Extract file not found "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"
ECHO SPL Extract file not found "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"                                 >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_SPL_UNSORTED_EXTRACT-DONE

:SYMCHK_SPL-DONE

rem *******************************************************************************
rem ** Validate Print Symbols                                                     *
rem *******************************************************************************

IF    NOT .%PRINTFILES% == .                                       GOTO    SYMCHK_PRINTFILES_CODED
ECHO No value set for the symbol PRINTFILES
ECHO No value set for the symbol PRINTFILES                                                         >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-PRINT

:SYMCHK_PRINTFILES_CODED
IF    %PRINTFILES% == Y                                            GOTO    SYMCHK_PRINTFILES-DONE
IF    %PRINTFILES% == N                                            GOTO    SYMCHK_PRINTFILES-DONE

ECHO Invalid value set for PRINTFILES - Must be either Y or N
ECHO Invalid value set for PRINTFILES - Must be either Y or N                                       >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-PRINT

:SYMCHK_PRINTFILES-DONE

IF  .%RUN_TYPE% == .ONLINE                                         GOTO    SYMCHK_RUN_TYPE_ONLINE
SET PRINT=PS
SET PSTREAM=PostScript
GOTO  SYMCHK_RUN_TYPE_DONE

:SYMCHK_RUN_TYPE_ONLINE
SET PRINT=PDF 
SET PSTREAM=PDF 
GOTO  SYMCHK_RUN_TYPE_DONE

:SYMCHK_RUN_TYPE_DONE

rem If PRINTFILES=N coded, bypass checking for other Printing parameters

IF    %PRINTFILES% == N                                            GOTO    SYMCHK_SKIP-PRINT

IF    NOT .%PADDR-BILLS-1UP% == .                                  GOTO    SYMCHK_PADDR-BILLS-1UP_CODED
ECHO No value set for the symbol PADDR-BILLS-1UP
ECHO No value set for the symbol PADDR-BILLS-1UP                                                    >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PADDR-BILLS-1UP_CODED

IF    NOT .%PADDR-BILLS-2UP% == .                                  GOTO    SYMCHK_PADDR-BILLS-2UP_CODED
ECHO No value set for the symbol PADDR-BILLS-2UP
ECHO No value set for the symbol PADDR-BILLS-2UP                                                    >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PADDR-BILLS-2UP_CODED

IF    NOT .%PADDR-REPORTS-PORT% == .                               GOTO    SYMCHK_PADDR-REPORTS-PORT_CODED
ECHO No value set for the symbol PADDR-REPORTS-PORT
ECHO No value set for the symbol PADDR-REPORTS-PORT                                                 >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PADDR-REPORTS-PORT_CODED

IF    NOT .%PADDR-REPORTS-LAND% == .                               GOTO    SYMCHK_PADDR-REPORTS-LAND_CODED
ECHO No value set for the symbol PADDR-REPORTS-LAND
ECHO No value set for the symbol PADDR-REPORTS-LAND                                                 >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PADDR-REPORTS-LAND_CODED

:SYMCHK_SKIP-PRINT

rem *******************************************************************************
rem ** Validate Delete Symbols                                                    *
rem *******************************************************************************

IF    NOT .%DELETEFILES% == .                                      GOTO    SYMCHK_DELETEFILES_CODED
ECHO No value set for the symbol DELETEFILES
ECHO No value set for the symbol DELETEFILES                                                        >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-DELETE

:SYMCHK_DELETEFILES_CODED
IF    %DELETEFILES% == Y                                           GOTO    SYMCHK_DELETEFILES-DONE
IF    %DELETEFILES% == N                                           GOTO    SYMCHK_DELETEFILES-DONE

ECHO Invalid value set for DELETEFILES - Must be either Y or N
ECHO Invalid value set for DELETEFILES - Must be either Y or N                                      >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-DELETE

:SYMCHK_DELETEFILES-DONE

:SYMCHK_SKIP-DELETE

rem *******************************************************************************
rem ** Validate Code-1 and MailStream Symbols                                     *
rem *******************************************************************************

ECHO      CODE1 = %CODE1%                                                                           >> "%PRODPATH%\%LOGFILE%"

IF    NOT .%CODE1% == .                                            GOTO    SYMCHK_CODE1_CODED
ECHO No value set for the symbol CODE1
ECHO No value set for the symbol CODE1                                                              >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-CODE1

:SYMCHK_CODE1_CODED
IF    %CODE1% == Y                                                 GOTO    SYMCHK_CODE1-DONE
IF    %CODE1% == N                                                 GOTO    SYMCHK_CODE1-DONE

ECHO Invalid value set for CODE1 - Must be either Y or N
ECHO Invalid value set for CODE1 - Must be either Y or N                                            >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-CODE1

:SYMCHK_CODE1-DONE

rem If CODE1=N coded, bypass checking for other Code1 parameters and presence of required files

IF    %CODE1% == N                                                 GOTO    SYMCHK_SKIP-CODE1

IF   NOT '%G1C1P%' == '.'                                          GOTO    SYMCHK_G1C1P_CODED
ECHO The G1C1P environment variable is not set - Code1 may not be installed.
ECHO The G1C1P environment variable is not set - Code1 may not be installed.                        >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_CODE1-DONE

:SYMCHK_G1C1P_CODED

IF    EXIST "%G1C1P%"                                              GOTO    SYMCHK_G1C1P_PRESENT
ECHO Code-1 Directory %G1C1P% not found - Code1 may not be installed.
ECHO Code-1 Directory %G1C1P% not found - Code1 may not be installed.                               >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_CODE1-DONE

:SYMCHK_G1C1P_PRESENT

ECHO Directory content of Code-1 DATA follows:                                                      >> "%PRODPATH%\%LOGFILE%"
DIR %G1C1P%\DATA                                                                                    >> "%PRODPATH%\%LOGFILE%"

ECHO      C1PRM = %C1PRM%                                                                           >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%C1PRM%"                                   GOTO    SYMCHK_C1PRM_PRESENT
ECHO Code1 Parameter file "%D1APPATH%\%C1PRM%" not found 
ECHO Code1 Parameter file "%D1APPATH%\%C1PRM%" not found                                            >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_C1PRM_PRESENT

SET DD_G1LICEN=%G1C1P%\DATA\G1LMLIC
IF    EXIST "%DD_G1LICEN%"                                         GOTO    SYMCHK_DD_G1LICEN_PRESENT
ECHO Code-1 License File %DD_G1LICEN% not found
ECHO Code-1 License File %DD_G1LICEN% not found                                                     >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_G1LICEN_PRESENT

IF    EXIST "%G1C1P%\DLL\C1BM00.EXE"                               GOTO    SYMCHK_C1BM00.EXE_PRESENT
ECHO Code-1 Executable File "%G1C1P%\DLL\C1BM00.EXE" not found
ECHO Code-1 Executable File "%G1C1P%\DLL\C1BM00.EXE" not found                                      >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_C1BM00.EXE_PRESENT

:SYMCHK_CODE1-DONE

IF   NOT '%G1DB%' == '.'                                           GOTO    SYMCHK_G1DB_CODED
ECHO The G1DB environment variable is not set - Code1 may not be installed.
ECHO The G1DB environment variable is not set - Code1 may not be installed.                         >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_CODE1-G1DB-DONE

:SYMCHK_G1DB_CODED
IF    EXIST "%G1DB%"                                               GOTO    SYMCHK_G1DB_PRESENT
ECHO Code-1 Database Directory %G1DB% not found - Code1 may not be installed.
ECHO Code-1 Database Directory %G1DB% not found - Code1 may not be installed.                       >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_CODE1-G1DB-DONE

:SYMCHK_G1DB_PRESENT

SET DD_CITYDB=%G1DB%\CITYDB
IF    EXIST "%DD_CITYDB%"                                          GOTO    SYMCHK_DD_CITYDB_PRESENT
ECHO Code-1 Database File %DD_CITYDB% not found
ECHO Code-1 Database File %DD_CITYDB% not found                                                     >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_CITYDB_PRESENT

SET DD_CITYNM=%G1DB%\CITYNM
IF    EXIST "%DD_CITYNM%"                                          GOTO    SYMCHK_DD_CITYNM_PRESENT
ECHO Code-1 Database File %DD_CITYNM% not found
ECHO Code-1 Database File %DD_CITYNM% not found                                                     >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_CITYNM_PRESENT

SET DD_COUNTY=%G1DB%\COUNTY
IF    EXIST "%DD_COUNTY%"                                          GOTO    SYMCHK_DD_COUNTY_PRESENT
ECHO Code-1 Database File %DD_COUNTY% not found
ECHO Code-1 Database File %DD_COUNTY% not found                                                     >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_COUNTY_PRESENT

SET DD_DTLDB=%G1DB%\DTLDB
IF    EXIST "%DD_DTLDB%"                                           GOTO    SYMCHK_DD_DTLDB_PRESENT
ECHO Code-1 Database File %DD_DTLDB% not found
ECHO Code-1 Database File %DD_DTLDB% not found                                                      >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_DTLDB_PRESENT

SET DD_LCLDB=%G1DB%\LCLDB
IF    EXIST "%DD_LCLDB%"                                           GOTO    SYMCHK_DD_LCLDB_PRESENT
ECHO Code-1 Database File %DD_LCLDB% not found
ECHO Code-1 Database File %DD_LCLDB% not found                                                      >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_LCLDB_PRESENT

SET DD_LTMASTR=%G1DB%\LTMASTR
IF    EXIST "%DD_LTMASTR%"                                         GOTO    SYMCHK_DD_LTMASTR_PRESENT
ECHO Code-1 Database File %DD_LTMASTR% not found
ECHO Code-1 Database File %DD_LTMASTR% not found                                                    >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_LTMASTR_PRESENT

SET DD_PTRDB=%G1DB%\PTRDB
IF    EXIST "%DD_PTRDB%"                                           GOTO    SYMCHK_DD_PTRDB_PRESENT
ECHO Code-1 Database File %DD_PTRDB% not found
ECHO Code-1 Database File %DD_PTRDB% not found                                                      >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_PTRDB_PRESENT

SET DD_ZIPIDX=%G1DB%\ZIPIDX
IF    EXIST "%DD_ZIPIDX%"                                          GOTO    SYMCHK_DD_ZIPIDX_PRESENT
ECHO Code-1 Database File %DD_ZIPIDX% not found
ECHO Code-1 Database File %DD_ZIPIDX% not found                                                     >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_ZIPIDX_PRESENT

SET DD_Z4CMSTR=%G1DB%\Z4CHNG
IF    EXIST "%DD_Z4CMSTR%"                                         GOTO    SYMCHK_DD_Z4CMSTR_PRESENT
ECHO Code-1 Database File %DD_Z4CMSTR% not found
ECHO Code-1 Database File %DD_Z4CMSTR% not found                                                    >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_DD_Z4CMSTR_PRESENT

:SYMCHK_CODE1-G1DB-DONE

:SYMCHK_SKIP-CODE1

ECHO      MSTREAM = %MSTREAM%                                                                       >> "%PRODPATH%\%LOGFILE%"

IF    NOT .%MSTREAM% == .                                          GOTO    SYMCHK_MSTREAM_CODED
ECHO No value set for the symbol MSTREAM
ECHO No value set for the symbol MSTREAM                                                            >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-MSTREAM

:SYMCHK_MSTREAM_CODED
IF    %MSTREAM% == Y                                               GOTO    SYMCHK_MSTREAM-DONE
IF    %MSTREAM% == N                                               GOTO    SYMCHK_MSTREAM-DONE

ECHO Invalid value set for MSTREAM - Must be either Y or N
ECHO Invalid value set for MSTREAM - Must be either Y or N                                          >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_SKIP-MSTREAM

:SYMCHK_MSTREAM-DONE

rem If MSTREAM=N coded, bypass checking for other MailStream parameters and presence of required files

IF    %MSTREAM% == N                                               GOTO    SYMCHK_SKIP-MSTREAM

IF    NOT .%G1MSP% == .                                            GOTO    SYMCHK_G1MSP_CODED
ECHO The G1MSP environment variable is not defined - Mailstream may not be installed.
ECHO The G1MSP environment variable is not defined - Mailstream may not be installed.               >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_G1MSP_CODED

IF    EXIST "%G1MSP%"                                              GOTO    SYMCHK_G1MSP_PRESENT
ECHO MailStream Directory %G1MSP% not found - MailStream may not be installed.
ECHO MailStream Directory %G1MSP% not found - MailStream may not be installed.                      >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_G1MSP_PRESENT

ECHO Directory content of MailStream CMDS follows:                                                  >> "%PRODPATH%\%LOGFILE%"
DIR %G1MSP%\CMDS                                                                                    >> "%PRODPATH%\%LOGFILE%"

ECHO      MSTREAM-JOB = %MSTREAM-JOB%                                                               >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%D1APPATH%\%MSPRM%"                                   GOTO    SYMCHK_MSPRM_PRESENT
ECHO Mailstream Parameter file "%D1APPATH%\%MSPRM%" not found 
ECHO Mailstream Parameter file "%D1APPATH%\%MSPRM%" not found                                       >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_MSPRM_PRESENT

IF   NOT '%G1DB%' == '.'                                           GOTO    SYMCHK_G1DB-MSP_CODED
ECHO The G1DB environment variable is not set - MailStream may not be installed.
ECHO The G1DB environment variable is not set - MailStream may not be installed.                    >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_MSTREAM-G1DB-DONE

:SYMCHK_G1DB-MSP_CODED
IF    EXIST "%G1DB%"                                               GOTO    SYMCHK_G1DB-MSP_PRESENT
ECHO MailStream Database Directory %G1DB% not found - Code1 may not be installed.
ECHO MailStream Database Directory %G1DB% not found - Code1 may not be installed.                   >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y
GOTO  SYMCHK_MSTREAM-G1DB-DONE

:SYMCHK_G1DB-MSP_PRESENT

IF    EXIST "%G1DB%\PRFDLVCT"                                      GOTO    SYMCHK_PRFDLVCT_PRESENT
ECHO MailStream Database File "%G1DB%\PRFDLVCT" not found
ECHO MailStream Database File "%G1DB%\PRFDLVCT" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFDLVCT_PRESENT

IF    EXIST "%G1DB%\PRFDSTNM"                                      GOTO    SYMCHK_PRFDSTNM_PRESENT
ECHO MailStream Database File "%G1DB%\PRFDSTNM" not found
ECHO MailStream Database File "%G1DB%\PRFDSTNM" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFDSTNM_PRESENT

IF    EXIST "%G1DB%\PRFMXCTY"                                      GOTO    SYMCHK_PRFMXCTY_PRESENT
ECHO MailStream Database File "%G1DB%\PRFMXCTY" not found
ECHO MailStream Database File "%G1DB%\PRFMXCTY" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFMXCTY_PRESENT

IF    EXIST "%G1DB%\PRFRTMAP"                                      GOTO    SYMCHK_PRFRTMAP_PRESENT
ECHO MailStream Database File "%G1DB%\PRFRTMAP" not found
ECHO MailStream Database File "%G1DB%\PRFRTMAP" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFRTMAP_PRESENT

IF    EXIST "%G1DB%\PRFSQREF"                                      GOTO    SYMCHK_PRFSQREF_PRESENT
ECHO MailStream Database File "%G1DB%\PRFSQREF" not found
ECHO MailStream Database File "%G1DB%\PRFSQREF" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFSQREF_PRESENT

IF    EXIST "%G1DB%\PRFZIPDR"                                      GOTO    SYMCHK_PRFZIPDR_PRESENT
ECHO MailStream Database File "%G1DB%\PRFZIPDR" not found
ECHO MailStream Database File "%G1DB%\PRFZIPDR" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFZIPDR_PRESENT

IF    EXIST "%G1DB%\PRFZONES"                                      GOTO    SYMCHK_PRFZONES_PRESENT
ECHO MailStream Database File "%G1DB%\PRFZONES" not found
ECHO MailStream Database File "%G1DB%\PRFZONES" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFZONES_PRESENT

IF    EXIST "%G1DB%\PRFPSTMT"                                      GOTO    SYMCHK_PRFPSTMT_PRESENT
ECHO MailStream Database File "%G1DB%\PRFPSTMT" not found
ECHO MailStream Database File "%G1DB%\PRFPSTMT" not found                                           >> "%PRODPATH%\%LOGFILE%"
SET   FATALERR=Y

:SYMCHK_PRFPSTMT_PRESENT

:SYMCHK_MSTREAM-G1DB-DONE

:SYMCHK_SKIP-MSTREAM

IF    %FATALERR% == N                                              GOTO    SYMCHK_DONE

ECHO Fatal Symbol Error Encountered - Process Aborting
ECHO Fatal Symbol Error Encountered - Process Aborting                                              >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:SYMCHK_DONE
ECHO Symbol Validation Complete                                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 01:  Sort SPL extract to re-arrange records within document           *
rem ==============================================================================*
rem  The SPL Bill Print Extract must be sorted to re-arrange records within each  *
rem  Bill.  The sorting will re-arrange Service Agreements according to the print *
rem  priority assigned within SPL.   Additionally, different blocks of            *
rem  information are re-sequence within the data to match the sequence the        *
rem  information is to be printed on the Bill; for example, the message records   *
rem  are moved ahead of the Premise / Service Agreement data.                     *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      SPL_UNSORTED_EXTRACT                                                     *
rem              - Name of the Billing (or Letter) data extracted from SPL        *
rem              - This file must be in the XTRCTPTH directory prior to running   *
rem                this .BAT process                                              *
rem   Output Files                                                                *
rem      SPL_SORTED_EXTRACT                                                       *
rem              - Name of Sorted SPL Extract containing Bill (or Letter) data    *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem   Configuration Files                                                         *
rem      -- none --                                                               *
rem *******************************************************************************
SET   "SPL_SORTED_EXTRACT=%FNP%bill_sorted.svd"
SET   "STEP01-DATE=%DATE%"
SET   "STEP01-TIME=%TIME%"

ECHO Step 01:  Sort SPL Bill Print Extract
ECHO Step 01:  Sort SPL Bill Print Extract                                                          >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP01-DATE% at %STEP01-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              XTRCTPTH = %XTRCTPTH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              SPL_UNSORTED_EXTRACT = %SPL_UNSORTED_EXTRACT%                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              SPL_SORTED_EXTRACT = %SPL_SORTED_EXTRACT%                                         >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO               -- none --                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem Delete Step 01 Output File from previous run
IF    EXIST "%PRODPATH%\%SPL_SORTED_EXTRACT%"                      ECHO           Deleting Prior Sorted Extract "%PRODPATH%\%SPL_SORTED_EXTRACT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPL_SORTED_EXTRACT%"                      DEL     "%PRODPATH%\%SPL_SORTED_EXTRACT%"

ECHO SORT  /+5 "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"   /O "%PRODPATH%\%SPL_SORTED_EXTRACT%"           >> "%PRODPATH%\%LOGFILE%"
SORT  /+5 "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"   /O "%PRODPATH%\%SPL_SORTED_EXTRACT%"                >> "%PRODPATH%\%LOGFILE%"
rem ECHO COPY   "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"    "%PRODPATH%\%SPL_SORTED_EXTRACT%"                >> "%PRODPATH%\%LOGFILE%"
rem COPY   "%XTRCTPTH%\%SPL_UNSORTED_EXTRACT%"    "%PRODPATH%\%SPL_SORTED_EXTRACT%"                >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOSORT-SORT-OKAY
ECHO           Sort Error - Process Halting
ECHO           Sort Error - Process Halting                                                         >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO ENDRUN

:DOSORT-SORT-OKAY
ECHO Step 01:  DOS Sort Complete - SPL Extract Sorted                                               >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 02:  Format Bills (DOC1GEN) - for Hardcopy Output                     *
rem ==============================================================================*
rem  The DOC1 Generate module (DOC1GEN) applies the DOC1 Application Rules        *
rem  against the Sorted SPL Bill Print Extract (output from Step 01) to create an *
rem  Intermediate Print File of Bills.  The Intermediate Print File will later be *
rem  post-processed and divided into different print files according to           *
rem  operational processing requirements.                                         *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      SPL_SORTED_EXTRACT                                                       *
rem              - Name of Sorted SPL Extract containing Bill data                *
rem              - This file was output into the PRODPATH directory by Step 01    *
rem   Configuration Files                                                         *
rem      GEN_OPS                                                                  *
rem              - Name of the DOC1GEN Initialization File                        *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      GEN_HIP                                                                  *    
rem              - Name of the DOC1GEN Host Rules (.HIP)                          *    
rem              - These files must be in the D1APPATH directory prior to running *    
rem                this .BAT process                                              *    
rem      GEN_ETS                                                                  *    
rem              - Name of the Look-Up File with Country Names                    *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      GEN_CNTL                                                                 *
rem              - Name of the Look-Up File with Controls (online vs. batch)      *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      LOGOXML                                                                  *
rem              - Name of XML file containing attributes of external images      *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem   Output Files                                                                *
rem      NAME_ADDRESS_JOURNAL                                                     *
rem              - Name of the Name-Address Journal file containing Address data  *
rem                and Output determination data triggers                         *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      INTERMEDIATE_PRINT                                                       *
rem              - Name of the file containing all formatted Bills (or Letters)   *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      GEN_LOG                                                                  *
rem              - Name of the file containing GEN messages                       *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem *******************************************************************************
SET   "NAME_ADDRESS_JOURNAL=%FNP%bill_name_address_journal.jrn"
SET   "INTERMEDIATE_PRINT=%FNP%bill_intermediate_print.%PRINT%"
SET   "DOC1GEN_DIJ=%FNP%bill_e2_journal.dij"
SET   "UV1=1"
SET   "UV2=0"
SET   "GEN_LOG=%FNP%bill_GEN_LOG.log"
SET   "STEP02-DATE=%DATE%"
SET   "STEP02-TIME=%TIME%"

ECHO Step 02:  Format Bills (DOC1GEN) 
ECHO Step 02:  Format Bills (DOC1GEN)                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP02-DATE% at %STEP02-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              D1HOST = %D1HOST%                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              D1APPATH = %D1APPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              SPL_SORTED_EXTRACT = %SPL_SORTED_EXTRACT%                                         >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              INTERMEDIATE_PRINT = %INTERMEDIATE_PRINT%                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              NAME_ADDRESS_JOURNAL = %NAME_ADDRESS_JOURNAL%                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              DOC1GEN_DIJ = %DOC1GEN_DIJ%                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              GEN_LOG = %GEN_LOG%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              GEN_OPS = %GEN_OPS%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              GEN_HIP = %GEN_HIP%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              GEN_ETS = %GEN_ETS%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              GEN_CNTL = %GEN_CNTL%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              LOGOXML = %LOGOXML%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           Printer Settings:                                                                    >> "%PRODPATH%\%LOGFILE%"
ECHO              PSTREAM = %PSTREAM%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           Control Settings:                                                                    >> "%PRODPATH%\%LOGFILE%"
ECHO              UV1 = %UV1%                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              UV2 = %UV2%                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 02 Output Files from previous run
IF    EXIST "%PRODPATH%\%INTERMEDIATE_PRINT%"                      ECHO           Deleting prior Intermediate Print "%PRODPATH%\%INTERMEDIATE_PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%INTERMEDIATE_PRINT%"                      DEL     "%PRODPATH%\%INTERMEDIATE_PRINT%"
IF    EXIST "%PRODPATH%\%NAME_ADDRESS_JOURNAL%"                    ECHO           Deleting prior Name-Address Journal "%PRODPATH%\%NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%NAME_ADDRESS_JOURNAL%"                    DEL     "%PRODPATH%\%NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%DOC1GEN_DIJ%"                             ECHO           Deleting prior Name-Address Journal "%PRODPATH%\%DOC1GEN_DIJ%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%DOC1GEN_DIJ%"                             DEL     "%PRODPATH%\%DOC1GEN_DIJ%"
IF    EXIST "%PRODPATH%\%GEN_LOG%"                                 ECHO           Deleting prior GEN Log "%PRODPATH%\%GEN_LOG%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%GEN_LOG%"                                 DEL     "%PRODPATH%\%GEN_LOG%"

IF %RUN_TYPE% == BATCH                                             GOTO   DOFORMAT-GEN
COPY "%D1APPATH%\SPL.BMP" .                                                                            > "%PRODPATH%\junk.file"

:DOFORMAT-GEN

ECHO "%D1HOST%\DOC1GEN" "%D1APPATH%\%GEN_HIP%" ops="%D1APPATH%\%GEN_OPS%" indata="%PRODPATH%\%SPL_SORTED_EXTRACT%" GENDIJ="%PRODPATH%\%DOC1GEN_DIJ%" GENPRT="%PRODPATH%\%INTERMEDIATE_PRINT%" GENJRN="%PRODPATH%\%NAME_ADDRESS_JOURNAL%" d1appath="%D1APPATH%" d1host="%D1HOST%" gen_ets="%D1APPATH%\%GEN_ETS%" gen_cntl="%D1APPATH%\%GEN_CNTL%" logoxml=%LOGOXML% UV1=%UV1% UV2=%UV2% >> "%PRODPATH%\%LOGFILE%"
"%D1HOST%\DOC1GEN" "%D1APPATH%\%GEN_HIP%" ops="%D1APPATH%\%GEN_OPS%" indata="%PRODPATH%\%SPL_SORTED_EXTRACT%" GENDIJ="%PRODPATH%\%DOC1GEN_DIJ%" GENPRT="%PRODPATH%\%INTERMEDIATE_PRINT%" GENJRN="%PRODPATH%\%NAME_ADDRESS_JOURNAL%" d1appath="%D1APPATH%" d1host="%D1HOST%" gen_ets="%D1APPATH%\%GEN_ETS%" gen_cntl="%D1APPATH%\%GEN_CNTL%" logoxml=%LOGOXML% UV1=%UV1% UV2=%UV2% >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOFORMAT-GEN-OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%GEN_LOG%" "%PRODPATH%\%LOGFILE%"                          > "%PRODPATH%\junk.file"
ECHO           DOC1GEN Error (Format Bills) - Process Halting
ECHO           DOC1GEN Error (Format Bills) - Process Halting                                       >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOFORMAT-GEN-OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%GEN_LOG%" "%PRODPATH%\%LOGFILE%"                          > "%PRODPATH%\junk.file"
ECHO Step 02:  DOC1GEN Complete - Bills Formatted                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

IF %RUN_TYPE% == ONLINE                                            GOTO   DOFORMAT-PDF-COPY
GOTO  DOFORMAT-DONE

:DOFORMAT-PDF-COPY
echo "-------- Copying PDF %PRODPATH%\%INTERMEDIATE_PRINT% to %outputpath% %outputbasename%.pdf"     >> "%PRODPATH%\%LOGFILE%"
COPY "%PRODPATH%\%INTERMEDIATE_PRINT%" "%outputpath%%outputbasename%.pdf"                            > "%PRODPATH%\junk.file"
echo COPY "%PRODPATH%\%INTERMEDIATE_PRINT%" "%outputpath%%OUTPUTBASENAME%.pdf"                      >> "%PRODPATH%\%LOGFILE%"
DEL spl.bmp
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"
GOTO  DODELETE-CHECK

:DOFORMAT-DONE

rem *******************************************************************************
rem    Step 03:  Identify Foreign Addressed Bills (DOC1PCE)                       *
rem ==============================================================================*
rem  Bills being mailed to a non-USA address are identified and removed from the  *
rem  Code-1 input to prevent Code-1 from marking those addresses as invalid.      *
rem  This PCE application will read the Name / Address Journal (created in Step   *
rem  02) and create two output journals - one with USA addresses and the other    *
rem  containing all other addresses.                                              *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      NAME_ADDRESS_JOURNAL                                                     *
rem              - Name of the Name-Address Journal file containing Address data  *
rem                and Output determination data triggers                         *
rem              - This file was output into the PRODPATH directory by Step 02    *
rem   Configuration Files                                                         *
rem      FRGN_PCE_INI                                                             *
rem              - Name of the DOC1PCE Initialization File                        *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      FRGN_PCE_CTL                                                             *
rem              - Name of the DOC1PCE Rules to separate Foreign Addressed Bills  *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem   Output Files                                                                *
rem      USA_NAME_ADDRESS_JOURNAL                                                 *
rem              - Name of the Name-Address Journal file containing USA addressed *
rem                Bills (or Letters) and Output determination data triggers      *
rem              - This file will be a subset of the NAME_ADDRESS_JOURNAL input   *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      FRGN_NAME_ADDRESS_JOURNAL                                                *
rem              - Name of the Name-Address Journal containing foreign addressed  *
rem                Bills (or Letters) and Output determination data triggers      *
rem              - This file will be a subset of the NAME_ADDRESS_JOURNAL input   *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      FRGN_SPLIT_LOGFILE                                                       *
rem              - Name of the file containing messages from the PCE process      *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem *******************************************************************************
SET   "USA_NAME_ADDRESS_JOURNAL=%FNP%bill_usa_name_address_journal.jrn"
SET   "FRGN_NAME_ADDRESS_JOURNAL=%FNP%bill_frgn_name_address_journal.jrn"
SET   "FRGN_SPLIT_LOGFILE=%FNP%bill_frgn_split_logfile.log"
SET   "STEP03-DATE=%DATE%"
SET   "STEP03-TIME=%TIME%"

ECHO Step 03:  Identify Foreign Addressed Bills (DOC1PCE) 
ECHO Step 03:  Identify Foreign Addressed Bills (DOC1PCE)                                           >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP03-DATE% at %STEP03-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              D1HOST = %D1HOST%                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              D1APPATH = %D1APPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              NAME_ADDRESS_JOURNAL = %NAME_ADDRESS_JOURNAL%                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              USA_NAME_ADDRESS_JOURNAL = %USA_NAME_ADDRESS_JOURNAL%                             >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_NAME_ADDRESS_JOURNAL = %FRGN_NAME_ADDRESS_JOURNAL%                     >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_SPLIT_LOGFILE = %FRGN_SPLIT_LOGFILE%                                   >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_PCE_INI = %FRGN_PCE_INI%                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_PCE_CTL = %FRGN_PCE_CTL%                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 03 Output Files from previous run
IF    EXIST "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"                ECHO           Deleting prior USA Name-Address Journal "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"                DEL     "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%"               ECHO           Deleting prior Foreign Name-Address Journal "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%"               DEL     "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%FRGN_SPLIT_LOGFILE%"                      ECHO           Deleting prior Foreign Split Logfile "%PRODPATH%\%FRGN_SPLIT_LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FRGN_SPLIT_LOGFILE%"                      DEL     "%PRODPATH%\%FRGN_SPLIT_LOGFILE%"

:DOFRGN-DOPCE

ECHO "%D1HOST%\doc1pce" ini="%D1APPATH%\%FRGN_PCE_INI%" injrn="%PRODPATH%\%NAME_ADDRESS_JOURNAL%" usajrn="%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" frgnjrn="%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" logfile="%PRODPATH%\%FRGN_SPLIT_LOGFILE%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%FRGN_PCE_CTL%"  >> "%PRODPATH%\%LOGFILE%"
"%D1HOST%\doc1pce" ini="%D1APPATH%\%FRGN_PCE_INI%" injrn="%PRODPATH%\%NAME_ADDRESS_JOURNAL%" usajrn="%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" frgnjrn="%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" logfile="%PRODPATH%\%FRGN_SPLIT_LOGFILE%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%FRGN_PCE_CTL%"  >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOFRGN_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%FRGN_SPLIT_LOGFILE%" "%PRODPATH%\%LOGFILE%"            > "%PRODPATH%\junk.file"
ECHO           DOC1PCE Error (Separate Foreign Bills) - Process Halting
ECHO           DOC1PCE Error (Separate Foreign Bills) - Process Halting                             >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOFRGN_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%FRGN_SPLIT_LOGFILE%" "%PRODPATH%\%LOGFILE%"            > "%PRODPATH%\junk.file"
ECHO Step 03:  DOC1PCE Complete - Foreign Bills Separated                                           >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 04:  Sort Foreign Address Journal Records                             *
rem ==============================================================================*
rem  The Foreign Address Journal output in Step 03 is sorted by Country Code so   *
rem  that these Bills, when printed, will be printed in Country Code order.       *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      FRGN_NAME_ADDRESS_JOURNAL                                                *
rem              - Name of the Name-Address Journal containing foreign addressed  *
rem                Bills and Output determination data triggers                   *
rem   Output Files                                                                *
rem      FRGN_SORTED_NAME_ADDRESS_JOURNAL                                         *
rem              - Name of the Name-Address Journal now sorted by Country Code    *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem   Configuration Files                                                         *
rem      -- none --                                                               *
rem *******************************************************************************
SET   "FRGN_SORTED_NAME_ADDRESS_JOURNAL=%FNP%bill_frgn_sorted_name_address_journal.jrn"
SET   "STEP04-DATE=%DATE%"
SET   "STEP04-TIME=%TIME%"

ECHO Step 04:  Sort Foreign Address Journal Records 
ECHO Step 04:  Sort Foreign Address Journal Records                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP04-DATE% at %STEP04-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_NAME_ADDRESS_JOURNAL = %FRGN_NAME_ADDRESS_JOURNAL%                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_SORTED_NAME_ADDRESS_JOURNAL = %FRGN_SORTED_NAME_ADDRESS_JOURNAL%       >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO               -- none --                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 04 Output Files from previous run
IF    EXIST "%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%"     ECHO           Deleting prior Foreign Sorted Name-Address Journal "%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%"     DEL     "%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%"

:DOFRGN-DOSORT

ECHO SORT  /+443 "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" /O "%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%"  >> "%PRODPATH%\%LOGFILE%"
SORT  /+443 "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" /O "%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%"  >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOFRGN_SORT_OKAY
ECHO           Sort Error (Sort Foreign Bill Journal) - Process Halting
ECHO           Sort Error (Sort Foreign Bill Journal) - Process Halting                             >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOFRGN_SORT_OKAY
ECHO Step 04:  Sort Complete - Foreign Bill Journal Sorted                                          >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 05:  Address Correction (Code-1)                                      *
rem ==============================================================================*
rem  Code-1 Plus is the Group1 product that performs the address correction,      *
rem  formatting, and validation required by the USPS to qualify for Postal        *
rem  Discounts.   In  the output journal, Code-1 will add address directionals    *
rem  N - North, S - South, etc.), street suffixes (LN, DR, ST, etc.), assign a    *
rem  Zip+4 Zip Code, identify the Carrier Route, and determine the content of the *
rem  Delivery Point Bar Code.  The Step 10 PCE application will place the Code-1  *
rem  formatted address and Delivery Point Bar Code on the Bill Remittance Coupon. *
rem  Code-1 Plus also produces a USPS CASS report.                                *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      USA_NAME_ADDRESS_JOURNAL (aka DD_C1BMNAM)                                *
rem              - Name of the Name-Address Journal file containing USA addressed *
rem                Bills and Output determination data triggers                   *
rem              - This file was output into the PRODPATH directory by Step 03    *
rem   Configuration Files                                                         *
rem      DD_C1BMPRM                                                               *
rem              - Name of the Code-1 Parameter File                              *
rem              - This file must be in the DATA sub-directory within the %G1C1P% *
rem                directory prior to running this .BAT process                   *
rem      DD_G1LICEN                                                               *
rem              - Name of the Code-1 License Management File                     *
rem              - This file must be in the DATA sub-directory within the %G1C1P% *
rem                directory prior to running this .BAT process                   *
rem   Code-1 Database Files                                                       *
rem      DD_CITYDB                                                                *
rem      DD_CITYNM                                                                *
rem      DD_COUNTY                                                                *
rem      DD_DTLDB                                                                 *
rem      DD_LCLDB                                                                 *
rem      DD_LTMASTR                                                               *
rem      DD_PTRDB                                                                 *
rem      DD_ZIPIDX                                                                *
rem      DD_Z4CMSTR                                                               *
rem              - All of these files must be in the %G1DB% directory prior to    *
rem                running this .BAT process                                      *
rem              - Note that all of these files must be updated regularly; these  *
rem                files contain time sensitive data with an expiration date;     *
rem                once the data expires, Code-1 will cease to produce the        *
rem                desired results.                                               *
rem   Output Files                                                                *
rem      CORRECTED_NAME_ADDRESS_JOURNAL (aka DD_C1BMCOK)                          *
rem              - Name of the USA Name-Address Journal file containing USA       *
rem                addressed records where the address has been corrected (if     *
rem                needed), formatted per USPS requirements, a Carrier Route has  *
rem                been identified, a 12-byte Delivery Point Bar Code (DPBC) has  *
rem                been identified, and Output determination data triggers        *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      REJECTED_NAME_ADDRESS_JOURNAL (aka DD_C1BMNCO)                           *
rem              - Name of the USA Name-Address Journal file containing USA       *
rem                addressed records where the address has been rejected because  *
rem                it could not be identified                                     *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      DD_PRNTCAS                                                               *
rem              - Name of the Code-1 USPS 3553 CASS Report                       *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      DD_PRNTRPT                                                               *
rem              - Name of the Code-1 Statistics Report                           *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      DD_PRNTXLG                                                               *
rem              - Name of the Code-1 Execution Log                               *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      DD_CBLOUT                                                                *
rem              - Contains messages that would be displayed on the terminal      *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem ==============================================================================*
rem  NOTE:  This step may be bypassed by coding CODE1=N in the master .BAT file   *
rem         When coded, this BAT will simply make a COPY of the input file to     *
rem         the output file name.                                                 *
rem *******************************************************************************
SET   "REJECTED_NAME_ADDRESS_JOURNAL=%FNP%bill_rejected_name_address_journal.jrn"
SET   "DD_C1BMNCO=%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"
SET   "CORRECTED_NAME_ADDRESS_JOURNAL=%FNP%bill_corrected_name_address_journal.jrn"
SET   "DD_C1BMCOK=%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"
SET   "DD_C1BMPRM=%D1APPATH%\%C1PRM%"
SET   "DD_C1BMNAM=%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" 
SET   "CASS-REPORT=%FNP%bill_USPS_3553_CASS.cas"
SET   "DD_PRNTCAS=%PRODPATH%\%CASS-REPORT%"
SET   "DD_PRNTRPT=%PRODPATH%\%FNP%bill_code1_stats.rpt"
SET   "DD_PRNTXLG=%PRODPATH%\%FNP%bill_code1_execution_log.xlg"
SET   "DD_C1BMIZP=%PRODPATH%\%FNP%bill_code1.izp" 
SET   "DD_C1BMZP4=%PRODPATH%\%FNP%bill_code1.zp4"
SET   "DD_CBLOUT=%PRODPATH%\%FNP%bill_code1_terminal_messages.log"
SET   "STEP05-DATE=%DATE%"
SET   "STEP05-TIME=%TIME%"

IF    %CODE1% == Y                                                 GOTO    DOADDRESS-DOCODE1
ECHO Step 05:  Code1 bypassed - COPY substituted
ECHO Step 05:  Code1 bypassed - COPY substituted                                                    >> "%PRODPATH%\%LOGFILE%"

rem delete Step 05 Output Files from previous run
IF    EXIST "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"           ECHO           Deleting prior Rejected Name-Address Journal "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"           DEL     "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"          ECHO           Deleting prior Corrected Name-Address Journal "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"          DEL     "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%DD_PRNTCAS%"                                         ECHO           Deleting prior CASS Report "%DD_PRNTCAS%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTCAS%"                                         DEL     "%DD_PRNTCAS%"
IF    EXIST "%DD_PRNTRPT%"                                         ECHO           Deleting prior Statistics Report "%DD_PRNTRPT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTRPT%"                                         DEL     "%DD_PRNTRPT%"
IF    EXIST "%DD_PRNTXLG%"                                         ECHO           Deleting prior Execution Log "%DD_PRNTXLG%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTXLG%"                                         DEL     "%DD_PRNTXLG%"
IF    EXIST "%DD_CBLOUT%"                                          ECHO           Deleting prior Terminal Messages "%DD_CBLOUT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_CBLOUT%"                                          DEL     "%DD_CBLOUT%"

ECHO  COPY "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" "%DD_C1BMCOK%"                                   >> "%PRODPATH%\%LOGFILE%"
COPY  "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"    "%DD_C1BMCOK%"                                     >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%DD_C1BMCOK%"                                         GOTO    DOADDRESS-DOCOPY-OKAY
ECHO           Failed to Create "%DD_C1BMCOK%" - aborting
ECHO           Failed to Create "%DD_C1BMCOK%" - aborting                                           >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO ENDRUN

:DOADDRESS-DOCOPY-OKAY
ECHO Step 05:  "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" copied to "%DD_C1BMCOK%"                     >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"
GOTO  DOADDRESS-DONE

:DOADDRESS-DOCODE1

ECHO Step 05:  Address Correction (Code-1)
ECHO Step 05:  Address Correction (Code-1)                                                          >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP05-DATE% at %STEP05-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              G1C1P = %G1C1P%                                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              G1DB = %G1DB%                                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_C1BMNAM = "%DD_C1BMNAM%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_PRNTCAS = "%DD_PRNTCAS%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_PRNTRPT = "%DD_PRNTRPT%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_PRNTXLG = "%DD_PRNTXLG%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_C1BMCOK = "%DD_C1BMCOK%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_C1BMNCO = "%DD_C1BMNCO%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_C1BMIZP = "%DD_C1BMIZP%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_C1BMZP4 = "%DD_C1BMZP4%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_CBLOUT = "%DD_CBLOUT%"                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_C1BMPRM = %D1APPATH%\%C1PRM%                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_G1LICEN = %G1C1P%\DATA\G1LMLIC                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO           Code-1 Database Files:                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_CITYDB = %G1DB%\CITYDB                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_CITYNM = %G1DB%\CITYNM                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_COUNTY = %G1DB%\COUNTY                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_DTLDB = %G1DB%\DTLDB                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_LCLDB = %G1DB%\LCLDB                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_LTMASTR = %G1DB%\LTMASTR                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_PTRDB = %G1DB%\PTRDB                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_ZIPIDX = %G1DB%\ZIPIDX                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_Z4CMSTR = %G1DB%\Z4CHNG                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 05 Output Files from previous run
IF    EXIST "%DD_PRNTCAS%"                                         ECHO           Deleting prior USPS CASS Report "%DD_PRNTCAS%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTCAS%"                                         DEL     "%DD_PRNTCAS%"
IF    EXIST "%DD_PRNTRPT%"                                         ECHO           Deleting prior Code-1 Statistics Report "%DD_PRNTRPT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTRPT%"                                         DEL     "%DD_PRNTRPT%"
IF    EXIST "%DD_PRNTXLG%"                                         ECHO           Deleting prior Code-1 Execution Log "%DD_PRNTXLG%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTXLG%"                                         DEL     "%DD_PRNTXLG%"
IF    EXIST "%DD_C1BMCOK%"                                         ECHO           Deleting prior Corrected Journal "%DD_C1BMCOK%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_C1BMCOK%"                                         DEL     "%DD_C1BMCOK%"
IF    EXIST "%DD_C1BMNCO%"                                         ECHO           Deleting prior Not Coded Journal "%DD_C1BMNCO%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_C1BMNCO%"                                         DEL     "%DD_C1BMNCO%"
IF    EXIST "%DD_C1BMIZP%"                                         ECHO           Deleting prior IZP "%DD_C1BMIZP%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_C1BMIZP%"                                         DEL     "%DD_C1BMIZP%"
IF    EXIST "%DD_C1BMZP4%"                                         ECHO           Deleting prior ZP4 "%DD_C1BMZP4%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_C1BMZP4%"                                         DEL     "%DD_C1BMZP4%"
IF    EXIST "%DD_CBLOUT%"                                          ECHO           Deleting prior Terminal Messages "%DD_CBLOUT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_CBLOUT%"                                          DEL     "%DD_CBLOUT%"

ECHO %G1C1P%\DLL\C1BM00                                                                             >> "%PRODPATH%\%LOGFILE%"
%G1C1P%\DLL\C1BM00                                                                                  >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0 GOTO DOADDRESS-DOCODE1-OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%DD_CBLOUT%"   "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"
COPY "%PRODPATH%\%LOGFILE%" + "%DD_PRNTXLG%"  "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"
COPY "%PRODPATH%\%LOGFILE%" + "%DD_PRNTRPT%"  "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"
ECHO           Code1 Error - Process Halting
ECHO           Code1 Error - Process Halting                                                        >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOADDRESS-DOCODE1-OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%DD_CBLOUT%"   "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"
COPY "%PRODPATH%\%LOGFILE%" + "%DD_PRNTXLG%"  "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"
COPY "%PRODPATH%\%LOGFILE%" + "%DD_PRNTRPT%"  "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"
COPY "%PRODPATH%\%LOGFILE%" + "%DD_PRNTCAS%"  "%PRODPATH%\%LOGFILE%"                                 > "%PRODPATH%\junk.file"

ECHO Step 05:  Address Cleansing complete                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 06:  Identify Corrected Addresses (DOC1PCE)                           *
rem ==============================================================================*
rem  Name Address Journal records whose addresses were modified by Code-1 are     *
rem  identified and copied into a new journal file that will be fed back into     *
rem  the SPL database.                                                            *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      CORRECTED_NAME_ADDRESS_JOURNAL (aka DD_C1BMCOK)                          *
rem              - Name of the USA Name-Address Journal file containing USA       *
rem                addressed records where the address has been corrected (if     *
rem                needed), formatted per USPS requirements, a Carrier Route has  *
rem                been identified, a 12-byte Delivery Point Bar Code (DPBC) has  *
rem                been identified, and Output determination data triggers        *
rem              - This file was output into the PRODPATH directory by Step 05    *
rem   Configuration Files                                                         *
rem      CHADR_PCE_INI                                                            *
rem              - Name of the DOC1PCE Initialization File                        *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      CHADR_PCE_CTL                                                            *
rem              - Name of the DOC1PCE Rules to changed address Journal records   *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem   Output Files                                                                *
rem      CHNGADDR_NAME_ADDRESS_JOURNAL                                            *
rem              - Name of the Name-Address Journal containing updated addresses  *
rem              - This file will be a subset of the                              *
rem                CORRECTED_NAME_ADDRESS_JOURNAL input                           *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      CHNGADDR_SPLIT_LOGFILE                                                   *
rem              - Name of the file containing messages from the PCE process      *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem *******************************************************************************
SET   "CHNGADDR_NAME_ADDRESS_JOURNAL=%FNP%bill_changedaddress_journal.jrn"
SET   "CHNGADDR_SPLIT_LOGFILE=%FNP%bill_changedaddress_logfile.log"
SET   "STEP06-DATE=%DATE%"
SET   "STEP06-TIME=%TIME%"

ECHO Step 06:  Identify Corrected Addresses (DOC1PCE)
ECHO Step 06:  Identify Corrected Addresses (DOC1PCE)                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP06-DATE% at %STEP06-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              D1HOST = %D1HOST%                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              D1APPATH = %D1APPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              CORRECTED_NAME_ADDRESS_JOURNAL = %CORRECTED_NAME_ADDRESS_JOURNAL%                 >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              CHNGADDR_NAME_ADDRESS_JOURNAL = %CHNGADDR_NAME_ADDRESS_JOURNAL%                   >> "%PRODPATH%\%LOGFILE%"
ECHO              CHNGADDR_SPLIT_LOGFILE = %CHNGADDR_SPLIT_LOGFILE%                                 >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              CHADR_PCE_INI = %CHADR_PCE_INI%                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              CHADR_PCE_CTL = %CHADR_PCE_CTL%                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 06 Output Files from previous run
IF    EXIST "%PRODPATH%\%CHNGADDR_NAME_ADDRESS_JOURNAL%"           ECHO           Deleting prior Updated Name-Address Journal "%PRODPATH%\%CHNGADDR_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%CHNGADDR_NAME_ADDRESS_JOURNAL%"           DEL     "%PRODPATH%\%CHNGADDR_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%"                  ECHO           Deleting prior Changed Address Logfile "%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%"                  DEL     "%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%"

:DOCHNG-DOPCE

ECHO "%D1HOST%\doc1pce" ini="%D1APPATH%\%CHADR_PCE_INI%" injrn="%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%" chngjrn="%PRODPATH%\%CHNGADDR_NAME_ADDRESS_JOURNAL%" logfile="%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%CHADR_PCE_CTL%"  >> "%PRODPATH%\%LOGFILE%"
"%D1HOST%\doc1pce" ini="%D1APPATH%\%CHADR_PCE_INI%" injrn="%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%" chngjrn="%PRODPATH%\%CHNGADDR_NAME_ADDRESS_JOURNAL%" logfile="%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%CHADR_PCE_CTL%"  >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOCHNG_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%" "%PRODPATH%\%LOGFILE%"           > "%PRODPATH%\junk.file"
ECHO           DOC1PCE Error (Identify Updated Addresses) - Process Halting
ECHO           DOC1PCE Error (Identify Updated Addresses) - Process Halting                         >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOCHNG_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%CHNGADDR_SPLIT_LOGFILE%" "%PRODPATH%\%LOGFILE%"           > "%PRODPATH%\junk.file"
ECHO Step 06:  DOC1PCE Complete - Corrected Addresses Identified                                    >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

:DOADDRESS-DONE

rem *******************************************************************************
rem    Step 07:  Identify Special Handling Bills (DOC1PCE)                        *
rem ==============================================================================*
rem  There are two possible types of special handling Bills:  Oversized Bills and *
rem  "Intercepted" Bills.  Oversized bills contain more pages than the inserter   *
rem  can fit into an envelope and must be manually handled.  The SPL marks a Bill *
rem  for review because of some event that has occurred with the account - the    *
rem  Intercepted Bill is to be reviewed by a Customer Service Representative      *
rem  prior to mailing.  Because these two types of special handling bills are not *
rem  included with the automated mailing, they must be excluded from the input to *
rem  MailStream; otherwise, MailStream postage calculations would not accurately  *
rem  reflect the mailing.  A PCE application will read the Corrected USA          *
rem  Name/Address Journal (created in Step 04) and create two output journals -   *
rem  one for special handling and the other containing all automated bills.       *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      CORRECTED_NAME_ADDRESS_JOURNAL                                           *
rem              - Name of the USA Name-Address Journal file containing USA       *
rem                addressed records where the address has been corrected (if     *
rem                needed), formatted per USPS requirements, a Carrier Route has  *
rem                been identified, a 12-byte Delivery Point Bar Code (DPBC) has  *
rem                been identified, and Output determination data triggers        *
rem              - This file was output into the PRODPATH directory by Step 04    *
rem   Configuration Files                                                         *
rem      SPCL_PCE_INI                                                             *
rem              - Name of the DOC1PCE Initialization File                        *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      SPCL_PCE_CTL                                                             *
rem              - Name of the DOC1PCE Rules to separate Special Handling Bills   *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem   Output Files                                                                *
rem      AUTOMATED_NAME_ADDRESS_JOURNAL                                           *
rem              - Name of the Name-Address Journal file containing USA addressed *
rem                Bills that require no special handling;                        *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      SPCLHNDL_NAME_ADDRESS_JOURNAL                                            *
rem              - Name of the Name-Address Journal containing Special Handling   *
rem                Billsand Output determination data triggers                    *
rem              - This file will be a subset of the NAME_ADDRESS_JOURNAL input   *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      SPCLHNDL_SPLIT_LOGFILE                                                   *
rem              - Name of the file containing messages from the PCE process      *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem *******************************************************************************
SET   "AUTOMATED_NAME_ADDRESS_JOURNAL=%FNP%bill_automated_name_address_journal.jrn"
SET   "SPCLHNDL_NAME_ADDRESS_JOURNAL=%FNP%bill_special_handle_name_address_journal.jrn"
SET   "SPCLHNDL_SPLIT_LOGFILE=%FNP%bill_special_handle_split_logfile.log"
SET   "STEP07-DATE=%DATE%"
SET   "STEP07-TIME=%TIME%"

ECHO Step 07:  Identify Special Handling Bills (DOC1PCE) 
ECHO Step 07:  Identify Special Handling Bills (DOC1PCE)                                            >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP07-DATE% at %STEP07-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              D1HOST = %D1HOST%                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              D1APPATH = %D1APPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              CORRECTED_NAME_ADDRESS_JOURNAL = %CORRECTED_NAME_ADDRESS_JOURNAL%                 >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              AUTOMATED_NAME_ADDRESS_JOURNAL = %AUTOMATED_NAME_ADDRESS_JOURNAL%                 >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCLHNDL_NAME_ADDRESS_JOURNAL = %SPCLHNDL_NAME_ADDRESS_JOURNAL%                   >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCLHNDL_SPLIT_LOGFILE = %SPCLHNDL_SPLIT_LOGFILE%                                 >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCL_PCE_INI = %SPCL_PCE_INI%                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCL_PCE_CTL = %SPCL_PCE_CTL%                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Control Settings:                                                                    >> "%PRODPATH%\%LOGFILE%"
ECHO              MAXAUTO = %MAXAUTO%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 07 Output Files from previous run
IF    EXIST "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"          ECHO           Deleting prior Automated Name-Address Journal "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"          DEL     "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%"           ECHO           Deleting prior Special Handle Name-Address Journal "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%"           DEL     "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%"                  ECHO           Deleting prior Special Handle Split Logfile "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%"                  DEL     "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%"

:DOSPCL-DOPCE

ECHO "%D1HOST%\doc1pce" ini="%D1APPATH%\%SPCL_PCE_INI%" maxauto=%MAXAUTO% injrn="%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%" autojrn="%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%" spcljrn="%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%" logfile="%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%SPCL_PCE_CTL%"  >> "%PRODPATH%\%LOGFILE%"
"%D1HOST%\doc1pce" ini="%D1APPATH%\%SPCL_PCE_INI%" maxauto=%MAXAUTO% injrn="%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%" autojrn="%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%" spcljrn="%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%" logfile="%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%SPCL_PCE_CTL%"  >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOSPCL_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%" "%PRODPATH%\%LOGFILE%"     > "%PRODPATH%\junk.file"
ECHO           DOC1PCE Error (Separate Special Handle Bills) - Process Halting
ECHO           DOC1PCE Error (Separate Special Handle Bills) - Process Halting                      >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOSPCL_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%" "%PRODPATH%\%LOGFILE%"     > "%PRODPATH%\junk.file"
ECHO Step 07:  DOC1PCE Complete - Special Handle Bills Separated                                    >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 08:  Sort Special Handling Journal Records                            *
rem ==============================================================================*
rem  The Special Handling Journal output in Step 07 is sorted by Country Code so  *
rem  that these Bills, when printed, will be printed in Country Code order.       *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      SPCLHNDL_NAME_ADDRESS_JOURNAL                                            *
rem              - Name of the Name-Address Journal containing Special Handling   *
rem                Bills and Output determination data triggers                   *
rem   Output Files                                                                *
rem      SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL                                     *
rem              - Name of the Name-Address Journal now sorted by Country Code    *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem   Configuration Files                                                         *
rem      -- none --                                                               *
rem *******************************************************************************
SET   "SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL=%FNP%bill_specialhandle_sorted_name_address_journal.jrn"
SET   "STEP08-DATE=%DATE%"
SET   "STEP08-TIME=%TIME%"

ECHO Step 08:  Sort Special Handling Journal Records
ECHO Step 08:  Sort Special Handling Journal Records                                                >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP08-DATE% at %STEP08-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCLHNDL_NAME_ADDRESS_JOURNAL = %SPCLHNDL_NAME_ADDRESS_JOURNAL%                   >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL = %SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%     >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO               -- none --                                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 08 Output Files from previous run
IF    EXIST "%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%"     ECHO           Deleting prior Special Handling Sorted Name-Address Journal "%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%"     DEL     "%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%"

:DOSPCL-DOSORT

ECHO SORT  /+443 "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%" /O "%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%"  >> "%PRODPATH%\%LOGFILE%"
SORT  /+443 "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%" /O "%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%"  >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOSPCL_SORT_OKAY
ECHO           Sort Error (Sort Special Handling Journal) - Process Halting
ECHO           Sort Error (Sort Special Handling Journal) - Process Halting                         >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOSPCL_SORT_OKAY
ECHO Step 08:  Sort Complete - Special Handling Bill Journal Sorted                                 >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 09:  Postal Pre-Sort (MailStream)                                     *
rem ==============================================================================*
rem  MailStream Plus is the Group1 product that determines USPS Pre-Sorting and   *
rem  calculates postage.  MailStream also adds the USPS Manifest data to its      *
rem  output journal.  The Step 10 PCE application will use the MailStream         *
rem  produced journal to place the Manifest data on the bills and produce an      *
rem  automated print file in the Pre-Sort sequence.  The USPS Postage Report is   *
rem  produced by MailStream.                                                      *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      AUTOMATED_NAME_ADDRESS_JOURNAL                                           *
rem              - Name of the Name-Address Journal file containing USA addressed *
rem                Bills that require no special handling;                        *
rem              - This file was output into the PRODPATH directory by Step 05    *
rem   Configuration Files                                                         *
rem      MSPRM                                                                    *
rem              - Name of the MailStream Parameter File                          *
rem              - This file must be in the D1APPATH                              *
rem                directory prior to running this .BAT process                   *
rem   Output Files                                                                *
rem      PRESORTED_JOURNAL                                                        *
rem              - Name of the USA Name-Address Journal file containing USA       *
rem                addressed records where the address has been corrected and     *
rem                Pre-Sorted to qualify for USPS discounted postage              *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      MSRSM                                                                    *
rem              - Name of the MailStream USPS Postage 3600 Report                *
rem              - This file will be written to the G1MSP/DATA/ directory         *
rem              - This .BAT process will delete previous versions of this file   *
rem      MSTREAM_STATISTICS                                                       *
rem              - Name of the MailStream Statistics Report                       *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      MSTREAM_RLG                                                              *
rem              - Name of the MailStream Log                                     *
rem              - This file will be written to the G1MSP/DATA/ directory         *
rem              - This .BAT process will delete previous versions of this file   *
rem ==============================================================================*
rem  NOTE:  This step may be bypassed by coding MSTREAM=N in the master .BAT file *
rem         When coded, this BAT will simply make a COPY of the input file to     *
rem         the output file name.                                                 *
rem *******************************************************************************

SET   "G1JOB=%FNP%bill"
SET   "PRESORTED_JOURNAL=%FNP%bill_presorted_usa_name_address_journal.jrn"
SET   "MSRSM=%G1MSP%\DATA\%G1JOB%.RSM"
SET   "USPS-POSTAGE-REPORT=%FNP%bill_USPS_3600_postage_report.rsm"
SET   "MSTREAM_STATISTICS=%FNP%bill_mstream_stats.rna"
SET   "MSTREAM_RLG=%G1MSP%\DATA\%G1JOB%.rlg"
SET   "STEP09-DATE=%DATE%"
SET   "STEP09-TIME=%TIME%"

SET   MSTREAM-XLG=bill_mailstream_log.xlg
SET   MSTREAM-MANIFEST=%FNP%bill_mstream_manifest.rrp


:: Report Files
rem SET DD_MSRPFAC=%G1MSP%\DATA\%G1JOB%.RFS
rem SET DD_MSRPPLT=%G1MSP%\DATA\%G1JOB%.PLT
SET DD_MSRPFAC=%PRODPATH%\%G1JOB%.RFS
SET DD_MSRPPLT=%PRODPATH%\%G1JOB%.PLT
SET DD_MSRPRPT=%PRODPATH%\%MSTREAM_STATISTICS%
SET DD_MSRPSTM=%PRODPATH%\%USPS-POSTAGE-REPORT%
rem SET DD_MSRPTAG=%G1MSP%\DATA\%G1JOB%.RBT
SET DD_MSRPTAG=%PRODPATH%\%G1JOB%.RBT

:: Alternate Print files
rem SET DD_AUDITTRL=%G1MSP%\DATA\%G1JOB%-AUDITTRL.RPT
rem SET DD_CONFIRM=%G1MSP%\DATA\%G1JOB%-CONFIRM.RPT
rem SET DD_CRRTWALK=%G1MSP%\DATA\%G1JOB%-CRRTWALK.RPT
rem SET DD_DETAIL=%G1MSP%\DATA\%G1JOB%-DETAIL.RPT
rem SET DD_MAILDAT=%G1MSP%\DATA\%G1JOB%-MAILDAT.RPT
rem SET DD_PALSUMM=%G1MSP%\DATA\%G1JOB%-PALSUMM.RPT
rem SET DD_RUNSTATS=%G1MSP%\DATA\%G1JOB%-RUNSTATS.RPT
rem SET DD_SUMMARY=%G1MSP%\DATA\%G1JOB%-SUMMARY.RPT
rem SET DD_ZONESUMM=%G1MSP%\DATA\%G1JOB%-ZONESUMM.RPT
rem SET DD_ZSDETAIL=%G1MSP%\DATA\%G1JOB%-ZSDETAIL.RPT

SET DD_AUDITTRL=%PRODPATH%\%G1JOB%-AUDITTRL.RPT
SET DD_CONFIRM=%PRODPATH%\%G1JOB%-CONFIRM.RPT
SET DD_CRRTWALK=%PRODPATH%\%G1JOB%-CRRTWALK.RPT
SET DD_DETAIL=%PRODPATH%\%G1JOB%-DETAIL.RPT
SET DD_MAILDAT=%PRODPATH%\%G1JOB%-MAILDAT.RPT
SET DD_PALSUMM=%PRODPATH%\%G1JOB%-PALSUMM.RPT
SET DD_RUNSTATS=%PRODPATH%\%G1JOB%-RUNSTATS.RPT
SET DD_SUMMARY=%PRODPATH%\%G1JOB%-SUMMARY.RPT
SET DD_ZONESUMM=%PRODPATH%\%G1JOB%-ZONESUMM.RPT
SET DD_ZSDETAIL=%PRODPATH%\%G1JOB%-ZSDETAIL.RPT
 
SET  "DD_MSSTIN=%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"
SET  "DD_MSNAON=%PRODPATH%\%PRESORTED_JOURNAL%"
SET  "DD_MSRPXLG=%PRODPATH%\%MSTREAM-XLG%"
SET  "DD_MANIFEST=%PRODPATH%\%MSTREAM-MANIFEST%"
SET  "DD_USPSQUAL=%PRODPATH%\%MSTREAM_STATISTICS%"
SET  "DD_USPSSTMT=%PRODPATH%\%USPS-POSTAGE-REPORT%"
SET  "DD_G1LICEN=%G1MSP%\DATA\G1LMLIC"

:: Note: The following 2 lines are used to create the Mail.dat file names
SET G1MDPC=AAAA
SET G1MDFS=0001

:: Postal Reference Files
SET DD_MSRFDC=%G1DB%\PRFDLVCT
SET DD_MSRFDI=%G1DB%\PRFDSTNM
SET DD_MSRFMP=%G1DB%\PRFRTMAP
SET DD_MSRFPS=%G1DB%\PRFPSTMT
SET DD_MSRFSQ=%G1DB%\PRFSQREF
SET DD_MSRFZD=%G1DB%\PRFZIPDR
SET DD_MSRFZM=%G1DB%\PRFZONES
SET DD_MSRFGH=%G1DB%\PRFGRAY.TXT

:: Parm File
SET DD_MSPRICP=%D1APPATH%\%MSPRM%

:: Large File Support
SET EXTFH=%G1MSP%\DLL\EXTFH.CFG

:: Generated Files
rem SET DD_MSSTON=%G1MSP%\DATA\%G1JOB%.SON
rem SET DD_MSSTOR=%G1MSP%\DATA\%G1JOB%.SOR
rem SET DD_MSWKCF=%G1MSP%\DATA\%G1JOB%.CTL
rem SET DD_MSWKCM=%G1MSP%\DATA\%G1JOB%.RSF
rem SET DD_MSWKNRC=%G1MSP%\DATA\%G1JOB%.NRC
rem SET DD_MSWKMS=%G1MSP%\DATA\%G1JOB%.MDT
rem SET DD_MSWKSS=%G1MSP%\DATA\%G1JOB%.SOS
rem SET DD_MSRDBAG=%G1MSP%\DATA\%G1JOB%.BAR
rem SET DD_MSRDPLT=%G1MSP%\DATA\%G1JOB%.LAB
rem SET DD_MSRDTRA=%G1MSP%\DATA\%G1JOB%.TRA
SET DD_MSSTON=%PRODPATH%\%G1JOB%.SON
SET DD_MSSTOR=%PRODPATH%\%G1JOB%.SOR
SET DD_MSWKCF=%PRODPATH%\%G1JOB%.CTL
SET DD_MSWKCM=%PRODPATH%\%G1JOB%.RSF
SET DD_MSWKNRC=%PRODPATH%\%G1JOB%.NRC
SET DD_MSWKMS=%PRODPATH%\%G1JOB%.MDT
SET DD_MSWKSS=\%G1JOB%.SOS
SET DD_MSRDBAG=%PRODPATH%\%G1JOB%.BAR
SET DD_MSRDPLT=%PRODPATH%\%G1JOB%.LAB
SET DD_MSRDTRA=%PRODPATH%\%G1JOB%.TRA

:: Mail.dat Files
SET DD_MSMDCLR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.CLR
SET DD_MSMDCPT=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.CPT
SET DD_MSMDCQT=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.CQT
SET DD_MSMDCSM=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.CSM
SET DD_MSMDHDR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.HDR
SET DD_MSMDMCR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.MCR
SET DD_MSMDMIR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.MIR
SET DD_MSMDMPU=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.MPU
SET DD_MSMDPLR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.PLR
SET DD_MSMDPQT=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.PQT
SET DD_MSMDSEG=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.SEG
SET DD_MSMDSNR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.SNR
SET DD_MSMDSPR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.SPR
SET DD_MSMDWSR=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.WSR
SET DD_MSRDCF=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.DCF
SET DD_MSRDEM=%G1MSP%\DATA\%G1MDPC%%G1MDFS%.EMD

:: Temporary Files
SET DD_MSWKDT=%G1TMP%\%G1JOB%.PDT
SET DD_MSWKNS=%G1TMP%\%G1JOB%.NNS
SET DD_MSWKQS=%G1TMP%\%G1JOB%.QSO
SET DD_MSWKZS=%G1TMP%\%G1JOB%.RZS
SET DD_MSWKS1=%G1TMP%\%G1JOB%.WS1
SET DD_MSWKS2=%G1TMP%\%G1JOB%.WS2
SET DD_MSWKS3=%G1TMP%\%G1JOB%.WS3
SET DD_MSWKTMP=%G1TMP%\%G1JOB%.TMP
SET DD_MSWKZ1=%G1TMP%\%G1JOB%.WZ1
SET DD_MSWKZ2=%G1TMP%\%G1JOB%.WZ2
SET DD_MSWKWK=%G1TMP%\%G1JOB%.TBL

IF    %MSTREAM% == Y                                               GOTO    DOPRESORT-DOMSTREAM
ECHO Step 09:  Mailstream bypassed - COPY substituted
ECHO Step 09:  Mailstream bypassed - COPY substituted                                               >> "%PRODPATH%\%LOGFILE%"

rem delete Step 09 Output Files from previous run
IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       ECHO           Deleting prior Pre-Sorted Name-Address Journal "%PRODPATH%\%PRESORTED_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       DEL     "%PRODPATH%\%PRESORTED_JOURNAL%"

ECHO  COPY "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"    "%PRODPATH%\%PRESORTED_JOURNAL%"        >> "%PRODPATH%\%LOGFILE%"
COPY  "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"    "%PRODPATH%\%PRESORTED_JOURNAL%"             >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       GOTO    DOPRESORT-DOCOPY-OKAY
ECHO           Failed to Create "%PRODPATH%\%PRESORTED_JOURNAL%" - aborting
ECHO           Failed to Create "%PRODPATH%\%PRESORTED_JOURNAL%" - aborting                         >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO ENDRUN

:DOPRESORT-DOCOPY-OKAY

ECHO Step 09:  "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%" copied "%PRODPATH%\%PRESORTED_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"
GOTO  DOPRESORT-DONE

:DOPRESORT-DOMSTREAM

ECHO Step 09:  Postal Pre-Sort (MailStream)
ECHO Step 09:  Postal Pre-Sort (MailStream)                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP09-DATE% at %STEP09-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              G1MSP = %G1MSP%                                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              G1DB = %G1DB%                                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              AUTOMATED_NAME_ADDRESS_JOURNAL = "%AUTOMATED_NAME_ADDRESS_JOURNAL%"               >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              PRESORTED_JOURNAL = "%PRESORTED_JOURNAL%"                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              USPS_POSTAGE_REPORT = "%MSRSM%"                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              MSTREAM_STATISTICS = "%MSTREAM_STATISTICS%"                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              MSTREAM_RLG = "%MSTREAM_RLG%"                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           MailStream Parameter File:                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO              MSPRM = %D1APPATH%\%MSPRM%                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 09 Output Files from previous run
IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       ECHO           Deleting prior Pre-Sorted Name-Address Journal "%PRODPATH%\%PRESORTED_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       DEL     "%PRODPATH%\%PRESORTED_JOURNAL%"
IF    EXIST "%PRODPATH%\%MSTREAM_STATISTICS%"                      ECHO           Deleting prior MailStream Statistics Report "%PRODPATH%\%MSTREAM_STATISTICS%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%MSTREAM_STATISTICS%"                      DEL     "%PRODPATH%\%MSTREAM_STATISTICS%"
IF    EXIST "%MSRSM%"                                              ECHO           Deleting prior MailStream 3600 Postage Report "%MSRSM%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%MSRSM%"                                              DEL     "%MSRSM%"

ECHO Executing MSDR00                                                                               >> "%PRODPATH%\%LOGFILE%"
%G1MSP%\DLL\MSDR00                                                                                  >> "%PRODPATH%\%LOGFILE%"
IF %ERRORLEVEL% == 0                                               GOTO DOPRESORT-DOMSTREAM-OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%DD_MSRPXLG%" "%PRODPATH%\%LOGFILE%"                                  > "%PRODPATH%\junk.file"
ECHO           MailStream Error - Process Halting
ECHO           MailStream Error - Process Halting                                                   >> "%PRODPATH%\%LOGFILE%"
GOTO  ENDRUN

:DOPRESORT-DOMSTREAM-OKAY

COPY "%PRODPATH%\%LOGFILE%" + "%DD_MSRPXLG%" "%PRODPATH%\%LOGFILE%"                                  > "%PRODPATH%\junk.file"

IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       GOTO    DOPRESORT-DOMSTREAM-OKAY
ECHO           Failed to Create "%PRODPATH%\%PRESORTED_JOURNAL%" - aborting
ECHO           Failed to Create "%PRODPATH%\%PRESORTED_JOURNAL%" - aborting                         >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO ENDRUN

:DOPRESORT-DOMSTREAM-OKAY

COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%MSTREAM_STATISTICS%"  "%PRODPATH%\%LOGFILE%"              > "%PRODPATH%\junk.file"
COPY "%MSRSM%" "%PRODPATH%\%USPS-POSTAGE-REPORT%"                                                    > "%PRODPATH%\junk.file"
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%USPS-POSTAGE-REPORT%" "%PRODPATH%\%LOGFILE%"              > "%PRODPATH%\junk.file"
ECHO Step 09:  USPS Pre-Sort complete                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 10:  Create Print Files (DOC1PCE)                                     *
rem ==============================================================================*
rem  This PCE application creates the final print files.  The Automated Bills     *
rem  will be printed in USPS Pre-Sort sequence and will have OMR Marks for the    *
rem  inserter.  The Foreign Address Bills, Intercepted Bills, and Oversized Bills *
rem  will not contain OMR Marks and will be printed in their original sequence    *
rem  into DOC1GEN.                                                               *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      INTERMEDIATE_PRINT                                                       *
rem              - Name of the file containing all formatted Bills (or Letters)   *
rem              - This file was output into the PRODPATH directory by Step 02    *
rem      FRGN_SORTED_NAME_ADDRESS_JOURNAL                                      *
rem              - Name of the Name-Address Journal now sorted by Country Code    *
rem              - This file was output into the PRODPATH directory by Step 04    *
rem      SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL                                     *
rem              - Name of the Name-Address Journal now sorted by Country Code    *
rem              - This file was output into the PRODPATH directory by Step 08    *
rem      PRESORTED_JOURNAL                                                        *
rem              - Name of the USA Name-Address Journal file containing USA       *
rem                addressed records where the address has been corrected and     *
rem                Pre-Sorted to qualify for USPS discounted postage              *
rem              - This file was output into the PRODPATH directory by Step 09    *
rem   Configuration Files                                                         *
rem      CPRT_PCE_INI                                                             *
rem              - Name of the DOC1PCE Initialization File                        *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      CPRT_PCE_CTL                                                             *
rem              - Name of the DOC1PCE Rules to create Print Files                *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem      GEN_HIP                                                                  *
rem              - Name of the HIP file containing font metric info               *
rem              - This file must be in the D1APPATH directory prior to running   *
rem                this .BAT process                                              *
rem   Output Files                                                                *
rem      AUTOMATED-BILLS-PRINT                                                    *
rem              - Name of the formatted Print file containing Automated Bills    *
rem                that require no special handling;                              *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      REJECTED-BILLS-PRINT                                                     *
rem              - Name of the formatted Print file containing Rejected Address   *
rem                Bills that require manual intervention                         *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      FOREIGN-BILLS-PRINT                                                      *
rem              - Name of the formatted Print file containing Foreign Addressed  *
rem                Bills that do require special handling;                        *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      INTERCEPTED-BILLS-PRINT                                                  *
rem              - Name of the formatted Print file containing Intercepted Bills  *
rem                that do require special handling;                              *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      OVERSIZED-BILLS-PRINT                                                    *
rem              - Name of the formatted Print file containing Oversized Bills    *
rem                that do require special handling;                              *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      FINALCB-BILLS-PRINT                                                      *
rem              - Name of the formatted Print file containing Final Bills with a *
rem                Credit Balance that do require special handling;               *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      AUDIT-FILE                                                               *
rem              - Name of the file containing messages from the PCE process      *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem      POST-PROCESS-LOGFILE                                                     *
rem              - Name of the file containing messages from the PCE process      *
rem              - This file will be written to the PRODPATH directory            *
rem              - This .BAT process will delete previous versions of this file   *
rem *******************************************************************************
SET   "AUTOMATED-BILLS-PRINT=%FNP%bill_automated_print.%PRINT%"
SET   "REJECTED-BILLS-PRINT=%FNP%bill_rejected_print.%PRINT%"
SET   "INTERCEPTED-BILLS-PRINT=%FNP%bill_intercepted_print.%PRINT%"
SET   "FOREIGN-BILLS-PRINT=%FNP%bill_frgn_print.%PRINT%"
SET   "OVERSIZED-BILLS-PRINT=%FNP%bill_oversized_print.%PRINT%"
SET   "FINALCB-BILLS-PRINT=%FNP%bill_finalcb_print.%PRINT%"
SET   "AUDIT-FILE=%FNP%bill_create_print_audit.adt"
SET   "POST-PROCESS-LOGFILE=%FNP%bill_create_print_logfile.log"
SET   "STEP10-DATE=%DATE%"
SET   "STEP10-TIME=%TIME%"

ECHO Step 10:  Create Print Files (DOC1PCE) 
ECHO Step 10:  Create Print Files (DOC1PCE)                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP10-DATE% at %STEP10-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              D1HOST = %D1HOST%                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              D1APPATH = %D1APPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              INTERMEDIATE_PRINT = %INTERMEDIATE_PRINT%                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              FRGN_SORTED_NAME_ADDRESS_JOURNAL = %FRGN_SORTED_NAME_ADDRESS_JOURNAL%       >> "%PRODPATH%\%LOGFILE%"
ECHO              SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL = %SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%     >> "%PRODPATH%\%LOGFILE%"
ECHO              REJECTED-ADDRESS-JOURNAL = %DD_C1BMNCO%                                           >> "%PRODPATH%\%LOGFILE%
ECHO              PRESORTED_JOURNAL = %PRESORTED_JOURNAL%                                           >> "%PRODPATH%\%LOGFILE%"
ECHO           Output Files:                                                                        >> "%PRODPATH%\%LOGFILE%"
ECHO              AUTOMATED-BILLS-PRINT = %AUTOMATED-BILLS-PRINT%                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              FOREIGN-BILLS-PRINT = %FOREIGN-BILLS-PRINT%                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              INTERCEPTED-BILLS-PRINT = %INTERCEPTED-BILLS-PRINT%                               >> "%PRODPATH%\%LOGFILE%"
ECHO              OVERSIZED-BILLS-PRINT = %OVERSIZED-BILLS-PRINT%                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              FINALCB-BILLS-PRINT = %FINALCB-BILLS-PRINT%                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              REJECTED-BILLS-PRINT = %REJECTED-BILLS-PRINT%                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              AUDIT-FILE = %AUDIT-FILE%                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              POST-PROCESS-LOGFILE = %POST-PROCESS-LOGFILE%                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Configuration Files:                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              CPRT_PCE_INI = %CPRT_PCE_INI%                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              CPRT_PCE_CTL = %CPRT_PCE_CTL%                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Printer Settings:                                                                    >> "%PRODPATH%\%LOGFILE%"
ECHO              PSTREAM = %PSTREAM%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              XLATE = %XLATE%                                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              PRES = %PRES%                                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              PRINT = %PRINT%                                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO           Control Settings:                                                                    >> "%PRODPATH%\%LOGFILE%"
ECHO              MAXAUTO = %MAXAUTO%                                                               >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

rem delete Step 10 Output Files from previous run
IF    EXIST "%PRODPATH%\%AUTOMATED-BILLS-PRINT%"                   ECHO           Deleting prior Automated Bills Print file "%PRODPATH%\%AUTOMATED-BILLS-PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%AUTOMATED-BILLS-PRINT%"                   DEL     "%PRODPATH%\%AUTOMATED-BILLS-PRINT%"
IF    EXIST "%PRODPATH%\%REJECTED-BILLS-PRINT%"                    ECHO           Deleting prior Rejected Bills Print file "%PRODPATH%\%REJECTED-BILLS-PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%REJECTED-BILLS-PRINT%"                    DEL     "%PRODPATH%\%REJECTED-BILLS-PRINT%"
IF    EXIST "%PRODPATH%\%FOREIGN-BILLS-PRINT%"                     ECHO           Deleting prior Foreign Bills Print file "%PRODPATH%\%FOREIGN-BILLS-PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FOREIGN-BILLS-PRINT%"                     DEL     "%PRODPATH%\%FOREIGN-BILLS-PRINT%"
IF    EXIST "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%"                 ECHO           Deleting prior Intercepted Bills Print file "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%"                 DEL     "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%"
IF    EXIST "%PRODPATH%\%OVERSIZED-BILLS-PRINT%"                   ECHO           Deleting prior Oversized Bills Print file "%PRODPATH%\%OVERSIZED-BILLS-PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%OVERSIZED-BILLS-PRINT%"                   DEL     "%PRODPATH%\%OVERSIZED-BILLS-PRINT%"
IF    EXIST "%PRODPATH%\%FINALCB-BILLS-PRINT%"                     ECHO           Deleting prior Final Bills w/ Credit Balance Print file "%PRODPATH%\%FINALCB-BILLS-PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FINALCB-BILLS-PRINT%"                     DEL     "%PRODPATH%\%FINALCB-BILLS-PRINT%"
IF    EXIST "%PRODPATH%\%AUDIT-FILE%"                              ECHO           Deleting prior Audit File "%PRODPATH%\%AUDIT-FILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%AUDIT-FILE%"                              DEL     "%PRODPATH%\%AUDIT-FILE%"
IF    EXIST "%PRODPATH%\%POST-PROCESS-LOGFILE%"                    ECHO           Deleting prior Special Handle Split Logfile "%PRODPATH%\%POST-PROCESS-LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%POST-PROCESS-LOGFILE%"                    DEL     "%PRODPATH%\%POST-PROCESS-LOGFILE%"

:DOPOST-DOPCE

ECHO "%D1HOST%\doc1pce" ini="%D1APPATH%\%CPRT_PCE_INI%"  maxauto=%MAXAUTO% frgnprt="%PRODPATH%\%FOREIGN-BILLS-PRINT%" autoprt="%PRODPATH%\%AUTOMATED-BILLS-PRINT%" autoprt-jrn="%PRODPATH%\%AUTOMATED-BILLS-PRINT-JRN%" intcprt="%PRODPATH%\%INTERCEPTED-BILLS-PRINT%" intcprt-jrn="%PRODPATH%\%INTERCEPTED-BILLS-PRINT-JRN%" ovszprt="%PRODPATH%\%OVERSIZED-BILLS-PRINT%" rjctprt="%PRODPATH%\%REJECTED-BILLS-PRINT%" GENprt="%PRODPATH%\%INTERMEDIATE_PRINT%" frgnjrn="%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" autojrn="%PRODPATH%\%PRESORTED_JOURNAL%" spcljrn="%PRODPATH%\%SORTED-SPCLHNDL_NAME_ADDRESS_JOURNAL%" rjctjrn="%DD_C1BMNCO%" logfile="%PRODPATH%\%POST-PROCESS-LOGFILE%" audit="%PRODPATH%\%AUDIT-FILE%" auditinp="%PRODPATH%\%NAME_ADDRESS_JOURNAL%" prodpath="%PRODPATH%" d1appath="%D1APPATH%" d1host="%D1HOST%" rpk="%GEN-RPK%" ctlname="%CPRT_PCE_CTL%" PSTREAM=%PSTREAM% PRES=%PRES% XLATE=%XLATE% PRINT=%PRINT%  >> "%PRODPATH%\%LOGFILE%"
"%D1HOST%\doc1pce" ini="%D1APPATH%\%CPRT_PCE_INI%"  genprt="%PRODPATH%\%INTERMEDIATE_PRINT%" autojrn="%PRODPATH%\%PRESORTED_JOURNAL%" frgnjrn="%PRODPATH%\%FRGN_SORTED_NAME_ADDRESS_JOURNAL%" spcljrn="%PRODPATH%\%SPCLHNDL_SORTED_NAME_ADDRESS_JOURNAL%" autoprt="%PRODPATH%\%AUTOMATED-BILLS-PRINT%" intcprt="%PRODPATH%\%INTERCEPTED-BILLS-PRINT%" finalcb="%PRODPATH%\%FINALCB-BILLS-PRINT%" maxauto=%MAXAUTO% frgnprt="%PRODPATH%\%FOREIGN-BILLS-PRINT%" ovszprt="%PRODPATH%\%OVERSIZED-BILLS-PRINT%" rjctprt="%PRODPATH%\%REJECTED-BILLS-PRINT%" rjctjrn="%DD_C1BMNCO%" logfile="%PRODPATH%\%POST-PROCESS-LOGFILE%" audit="%PRODPATH%\%AUDIT-FILE%" d1appath="%D1APPATH%" d1host="%D1HOST%" ctlname="%CPRT_PCE_CTL%" pstream=%PSTREAM% pres=%PRES% >> "%PRODPATH%\%LOGFILE%"

IF %ERRORLEVEL% == 0                                               GOTO    DOCPRT_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%POST-PROCESS-LOGFILE%" "%PRODPATH%\%LOGFILE%"             > "%PRODPATH%\junk.file"
ECHO           DOC1PCE Error (Create Print Files) - Process Halting
ECHO           DOC1PCE Error (Create Print Files) - Process Halting                                 >> "%PRODPATH%\%LOGFILE%"
SET    DOC1-BILL-RC=16
GOTO  ENDRUN

:DOCPRT_PCE_OKAY
COPY "%PRODPATH%\%LOGFILE%" + "%PRODPATH%\%POST-PROCESS-LOGFILE%" "%PRODPATH%\%LOGFILE%"             > "%PRODPATH%\junk.file"
ECHO Step 10:  Print Files Created                                                                  >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

rem *******************************************************************************
rem    Step 09:  Copy Print Files to Printer                                      *
rem ==============================================================================*
rem  This step sends the Bill Print files, USPS 3600, and USPS 3553 reports to    *
rem  print.                                                                       *
rem ==============================================================================*
rem   Input Files                                                                 *
rem      DD_PRNTCAS                                                               *
rem              - Name of the Code-1 USPS 3553 CASS Report                       *
rem              - This file was output into the PRODPATH directory by Step 04    *
rem      MSRSM                                                                    *
rem              - Name of the MailStream USPS Postage 3600 Report                *
rem              - This file was output into the G1MSP/DATA directory by Step 06  *
rem      FOREIGN-BILLS-PRINT                                                      *
rem              - Name of the formatted Print file containing Foreign Addressed  *
rem                Bills (or Letters) that do require special handling;           *
rem              - This file was output into the PRODPATH directory by Step 10    *
rem      INTERCEPTED-BILLS-PRINT                                                  *
rem              - Name of the formatted Print file containing Intercepted Bills  *
rem                (or Letters) that do require special handling;                 *
rem              - This file was output into the PRODPATH directory by Step 10    *
rem      OVERSIZED-BILLS-PRINT                                                    *
rem              - Name of the formatted Print file containing Oversized Bills    *
rem                (or Letters) that do require special handling;                 *
rem              - This file was output into the PRODPATH directory by Step 10    *
rem      REJECTED-BILLS-PRINT                                                     *
rem              - Name of the formatted Print file containing Rejected Address   *
rem                Bills (or Letters) that do require special handling;            *
rem              - This file was output into the PRODPATH directory by Step 10    *
rem      AUTOMATED-BILLS-PRINT                                                    *
rem              - Name of the formatted Print file containing Automated Bills    *
rem                (or Letters) that require no special handling;                 *
rem              - This file was output into the PRODPATH directory by Step 10    *
rem ==============================================================================*
rem  NOTE:  This step may be bypassed by coding PRINTFILES=N in the master .BAT   *
rem         file.                                                                 *
rem *******************************************************************************
SET   "STEP09-DATE=%DATE%"
SET   "STEP09-TIME=%TIME%"

IF    %PRINTFILES% == Y GOTO DOPRINT-PRINT
ECHO *******   PRINTFILES=N coded - Step 09 Send print files to printer bypassed
ECHO *******   PRINTFILES=N coded - Step 09 Send print files to printer bypassed                    >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"
GOTO  DOPRINT-DONE

:DOPRINT-PRINT
ECHO Step 09:  Copy Print Files to Printer
ECHO Step 09:  Copy Print Files to Printer                                                          >> "%PRODPATH%\%LOGFILE%"
ECHO           Start on %STEP09-DATE% at %STEP09-TIME%                                              >> "%PRODPATH%\%LOGFILE%"
ECHO           Directories:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              PRODPATH = %PRODPATH%                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO           Input Files:                                                                         >> "%PRODPATH%\%LOGFILE%"
ECHO              AUTOMATED-BILLS-PRINT = %AUTOMATED-BILLS-PRINT%                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              FOREIGN-BILLS-PRINT = %FOREIGN-BILLS-PRINT%                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              INTERCEPTED-BILLS-PRINT = %INTERCEPTED-BILLS-PRINT%                               >> "%PRODPATH%\%LOGFILE%"
ECHO              OVERSIZED-BILLS-PRINT = %OVERSIZED-BILLS-PRINT%                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              DD_PRNTCAS = "%DD_PRNTCAS%"                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO              USPS-POSTAGE-REPORT = "%USPS-POSTAGE-REPORT%"                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           Sequence of Printed Files:                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO              USPS 3553 CASS Report                                                             >> "%PRODPATH%\%LOGFILE%"
ECHO              USPS 3600 Postage Report                                                          >> "%PRODPATH%\%LOGFILE%"
ECHO              Intercepted Bills                                                                 >> "%PRODPATH%\%LOGFILE%"
ECHO              Foreign Addressed Bills                                                           >> "%PRODPATH%\%LOGFILE%"
ECHO              Oversized Bills                                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO              Automated Bills                                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO           Printer Address:                                                                     >> "%PRODPATH%\%LOGFILE%"
ECHO              PADDR-BILLS-2UP = %PADDR-BILLS-2UP%                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              PADDR-BILLS-1UP = %PADDR-BILLS-1UP%                                               >> "%PRODPATH%\%LOGFILE%"
ECHO              PADDR-REPORTS = %PADDR-REPORTS%                                                   >> "%PRODPATH%\%LOGFILE%"
ECHO           ------------------------------------------------------------------------------------ >> "%PRODPATH%\%LOGFILE%"

IF    %CODE1% == Y                                                 GOTO    DOPRINT-PRINT-CASS-3553
ECHO           CODE1=N Coded - USPS 3553 CASS Report NOT Produced                                   >> "%PRODPATH%\%LOGFILE%"
GOTO  DOPRINT-PRINT-CASS-3553-DONE

:DOPRINT-PRINT-CASS-3553

ECHO           Code1 Produced USPS 3553 CASS Report sent to %PADDR-REPORTS-PORT% printer
ECHO           Code1 Produced USPS 3553 CASS Report sent to %PADDR-REPORTS-PORT% printer            >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%DD_PRNTCAS%"                              %PADDR-REPORTS-PORT%             >> "%PRODPATH%\%LOGFILE%"
COPY /b "%DD_PRNTCAS%"                                             %PADDR-REPORTS-PORT%             >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-CASS-3553-DONE

IF    %MSTREAM% == Y                                               GOTO    DOPRINT-PRINT-POSTAGE-3600
ECHO           MSTREAM=N Coded - USPS 3600 Postage Report NOT Produced                              >> "%PRODPATH%\%LOGFILE%"
GOTO  DOPRINT-PRINT-POSTAGE-3600-DONE

:DOPRINT-PRINT-POSTAGE-3600

ECHO           MailStream Produced USPS 3600 Postage Report sent to %PADDR-REPORTS-LAND% printer
ECHO           MailStream Produced USPS 3600 Postage Report sent to %PADDR-REPORTS-LAND% printer    >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%USPS-POSTAGE-REPORT%"          %PADDR-REPORTS-LAND%             >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%USPS-POSTAGE-REPORT%"                         %PADDR-REPORTS-LAND%             >> "%PRODPATH%\%LOGFILE%"

ECHO           MailStream Produced MMRPMR00 Manifest Report sent to %PADDR-REPORTS-LAND% printer
ECHO           MailStream Produced MMRPMR00 Manifest Report sent to %PADDR-REPORTS-LAND% printer    >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%MSTREAM-MANIFEST%"             %PADDR-REPORTS-LAND%             >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%MSTREAM-MANIFEST%"                            %PADDR-REPORTS-LAND%             >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-POSTAGE-3600-DONE

IF    EXIST "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%"                 GOTO    DOPRINT-PRINT-INTERCEPTED-BILLS
ECHO           No Intercepted Bills to Print                                                        >> "%PRODPATH%\%LOGFILE%"
GOTO DOPRINT-PRINT-INTERCEPTED-BILLS-DONE

:DOPRINT-PRINT-INTERCEPTED-BILLS

ECHO           Intercepted Bills sent to %PADDR-BILLS-2UP% printer
ECHO           Intercepted Bills sent to %PADDR-BILLS-2UP% printer                                  >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%"      %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%INTERCEPTED-BILLS-PRINT%"                     %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-INTERCEPTED-BILLS-DONE

IF    EXIST "%PRODPATH%\%FOREIGN-BILLS-PRINT%"                     GOTO    DOPRINT-PRINT-FOREIGN-BILLS
ECHO           No Foreign Bills to Print                                                            >> "%PRODPATH%\%LOGFILE%"
GOTO DOPRINT-PRINT-FOREIGN-BILLS-DONE

:DOPRINT-PRINT-FOREIGN-BILLS

ECHO           Foreign Bills sent to %PADDR-BILLS-2UP% printer
ECHO           Foreign Bills sent to %PADDR-BILLS-2UP% printer                                      >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%FOREIGN-BILLS-PRINT%"          %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%FOREIGN-BILLS-PRINT%"                         %PADDR-BILLS-2UP%                    >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-FOREIGN-BILLS-DONE

IF    EXIST "%PRODPATH%\%OVERSIZED-BILLS-PRINT%"                   GOTO    DOPRINT-PRINT-OVERSIZED-BILLS
ECHO           No Oversized Bills to Print                                                          >> "%PRODPATH%\%LOGFILE%"
GOTO DOPRINT-PRINT-OVERSIZED-BILLS-DONE

:DOPRINT-PRINT-OVERSIZED-BILLS

ECHO           Oversized Bills sent to %PADDR-BILLS-1UP% printer
ECHO           Oversized Bills sent to %PADDR-BILLS-1UP% printer                                    >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%OVERSIZED-BILLS-PRINT%"        %PADDR-BILLS-1UP%                >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%OVERSIZED-BILLS-PRINT%"                       %PADDR-BILLS-1UP%                >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-OVERSIZED-BILLS-DONE

IF    EXIST "%PRODPATH%\%REJECTED-BILLS-PRINT%"                    GOTO    DOPRINT-PRINT-REJECTED-BILLS
ECHO           No Rejected Bills to Print                                                           >> "%PRODPATH%\%LOGFILE%"
GOTO DOPRINT-PRINT-REJECTED-BILLS-DONE

:DOPRINT-PRINT-REJECTED-BILLS

ECHO           Rejected Bills sent to %PADDR-BILLS-2UP% printer
ECHO           Rejected Bills sent to %PADDR-BILLS-2UP% printer                                     >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%REJECTED-BILLS-PRINT%"         %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%REJECTED-BILLS-PRINT%"                        %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-REJECTED-BILLS-DONE

IF    EXIST "%PRODPATH%\%AUTOMATED-BILLS-PRINT%"                   GOTO    DOPRINT-PRINT-AUTOMATED-BILLS
ECHO           No Automated Bills to Print                                                          >> "%PRODPATH%\%LOGFILE%"
GOTO DOPRINT-PRINT-AUTOMATED-BILLS-DONE

:DOPRINT-PRINT-AUTOMATED-BILLS

ECHO           Automated Bills sent to %PADDR-BILLS-2UP% printer
ECHO           Automated Bills sent to %PADDR-BILLS-2UP% printer                                    >> "%PRODPATH%\%LOGFILE%"
ECHO           COPY /b "%PRODPATH%\%AUTOMATED-BILLS-PRINT%"        %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"
COPY /b "%PRODPATH%\%AUTOMATED-BILLS-PRINT%"                       %PADDR-BILLS-2UP%                >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-PRINT-AUTOMATED-BILLS-DONE

ECHO Step 09:  Output files copied to printer                                                       >> "%PRODPATH%\%LOGFILE%"
ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"

:DOPRINT-DONE
rem *******************************************************************************
rem    Termination: Delete Work Files                                             *
rem ==============================================================================*
rem  This optional step deletes intermediate work files.  This step may be        *
rem  bypassed by setting "DELETEFILES=N" in the Master Command File               *
rem ==============================================================================*
rem   Step  01 Files                                                              *
rem      SPL_SORTED_EXTRACT                                                       *
rem                                                                               *
rem   Step  02 Files                                                              *
rem      NAME_ADDRESS_JOURNAL                                                     *
rem      INTERMEDIATE_PRINT                                                       *
rem                                                                               *
rem   Step  03 Files                                                              *
rem      USA_NAME_ADDRESS_JOURNAL                                                 *
rem      FRGN_NAME_ADDRESS_JOURNAL                                             *
rem      FRGN_SPLIT_LOGFILE                                                    *
rem                                                                               *
rem   Step  04 Files                                                              *
rem      REJECTED_NAME_ADDRESS_JOURNAL (aka DD_C1BMNCO)                           *
rem      CORRECTED_NAME_ADDRESS_JOURNAL (aka DD_C1BMCOK)                          *
rem      DD_PRNTRPT                                                               *
rem      DD_PRNTXLG                                                               *
rem      DD_CBLOUT                                                                *
rem                                                                               *
rem   Step  05 Files                                                              *
rem      AUTOMATED_NAME_ADDRESS_JOURNAL                                           *
rem      SPCLHNDL_NAME_ADDRESS_JOURNAL                                      *
rem      SPCLHNDL_SPLIT_LOGFILE                                             *
rem                                                                               *
rem   Step  06 Files                                                              *
rem      PRESORTED_JOURNAL                                                        *
rem      MSTREAM_STATISTICS                                                       *
rem      MSTREAM_RLG                                                              *
rem                                                                               *
rem   Step  07 Files                                                              *
rem      SORTED-NCO-JOURNAL                                                       *
rem                                                                               *
rem   Step  09 Files                                                              *
rem      SORTED-AUDIT-INPUT-JOURNAL                                               *
rem                                                                               *
rem   Step  10 Files                                                              *
rem      POST-PROCESS-LOGFILE                                                     *
rem                                                                               *
rem   Step  11 Files                                                              *
rem      -- none --                                                               *
rem ==============================================================================*
rem   Files NOT Deleted:                                                          *
rem                                                                               *
rem   Step  04 Files                                                              *
rem      DD_PRNTCAS                                                               *
rem                                                                               *
rem   Step  06 Files                                                              *
rem      USPS-POSTAGE-REPORT                                                      *
rem                                                                               *
rem   Step  10 Files                                                              *
rem      AUTOMATED-BILLS-PRINT                                                    *
rem      FOREIGN-BILLS-PRINT                                                      *
rem      INTERCEPTED-BILLS-PRINT                                                  *
rem      OVERSIZED-BILLS-PRINT                                                    *
rem      REJECTED-BILLS-PRINT                                                     *
rem      AUDIT-FILE                                                               *
rem *******************************************************************************

:DODELETE-CHECK

IF %DELETEFILES% == Y                                              GOTO  DODELETE
ECHO *******   DELETEFILES=N coded - File Deletion bypassed
ECHO *******   DELETEFILES=N coded - File Deletion bypassed                                         >> "%PRODPATH%\%LOGFILE%"
GOTO DODELETE-DONE

:DODELETE

ECHO Termination: Delete Work Files
ECHO Termination: Delete Work Files                                                                 >> "%PRODPATH%\%LOGFILE%"

rem Delete Step 01 Files
IF    EXIST "%PRODPATH%\%SPL_SORTED_EXTRACT%"                      ECHO           Deleting Step 01 Sorted Extract "%PRODPATH%\%SPL_SORTED_EXTRACT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPL_SORTED_EXTRACT%"                      DEL     "%PRODPATH%\%SPL_SORTED_EXTRACT%"

rem Delete Step 02 Files
IF    EXIST "%PRODPATH%\%INTERMEDIATE_PRINT%"                      ECHO           Deleting Step 02 Intermediate Print "%PRODPATH%\%INTERMEDIATE_PRINT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%INTERMEDIATE_PRINT%"                      DEL     "%PRODPATH%\%INTERMEDIATE_PRINT%"
IF    EXIST "%PRODPATH%\%NAME_ADDRESS_JOURNAL%"                    ECHO           Deleting Step 02 Name-Address Journal "%PRODPATH%\%NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%NAME_ADDRESS_JOURNAL%"                    DEL     "%PRODPATH%\%NAME_ADDRESS_JOURNAL%"

IF %RUN_TYPE% == ONLINE                                            GOTO   DODELETE-DONE

rem Delete Step 03 Files
IF    EXIST "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"                ECHO           Deleting Step 03 USA Name-Address Journal "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"                DEL     "%PRODPATH%\%USA_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%"            ECHO           Deleting Step 03 Foreign Name-Address Journal "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%"            DEL     "%PRODPATH%\%FRGN_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%FRGN_SPLIT_LOGFILE%"                   ECHO           Deleting Step 03 Foreign Split Logfile "%PRODPATH%\%FRGN_SPLIT_LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%FRGN_SPLIT_LOGFILE%"                   DEL     "%PRODPATH%\%FRGN_SPLIT_LOGFILE%"

rem Delete Step 04 Files
IF    EXIST "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"           ECHO           Deleting Step 04 Rejected Name-Address Journal "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"           DEL     "%PRODPATH%\%REJECTED_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"          ECHO           Deleting Step 04 Corrected Name-Address Journal "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"          DEL     "%PRODPATH%\%CORRECTED_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%DD_PRNTRPT%"                                         ECHO           Deleting Step 04 Statistics Report "%DD_PRNTRPT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTRPT%"                                         DEL     "%DD_PRNTRPT%"
IF    EXIST "%DD_PRNTXLG%"                                         ECHO           Deleting Step 04 Execution Log "%DD_PRNTXLG%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_PRNTXLG%"                                         DEL     "%DD_PRNTXLG%"
IF    EXIST "%DD_CBLOUT%"                                          ECHO           Deleting Step 04 Terminal Messages "%DD_CBLOUT%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%DD_CBLOUT%"                                          DEL     "%DD_CBLOUT%"

rem Delete Step 05 Files
IF    EXIST "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"          ECHO           Deleting Step 05 Automated Name-Address Journal "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"          DEL     "%PRODPATH%\%AUTOMATED_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%"     ECHO           Deleting Step 05 Special Handle Name-Address Journal "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%"     DEL     "%PRODPATH%\%SPCLHNDL_NAME_ADDRESS_JOURNAL%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%"            ECHO           Deleting Step 05 Special Handle Split Logfile "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%"            DEL     "%PRODPATH%\%SPCLHNDL_SPLIT_LOGFILE%"

rem Delete Step 06 Files
IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       ECHO           Deleting Step 06 Pre-Sorted Name-Address Journal "%PRODPATH%\%PRESORTED_JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%PRESORTED_JOURNAL%"                       DEL     "%PRODPATH%\%PRESORTED_JOURNAL%"
IF    EXIST "%PRODPATH%\%MSTREAM_STATISTICS%"                      ECHO           Deleting Step 06 MailStream Statistics Report "%PRODPATH%\%MSTREAM_STATISTICS%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%MSTREAM_STATISTICS%"                      DEL     "%PRODPATH%\%MSTREAM_STATISTICS%"
IF    EXIST "%PRODPATH%\%MSTREAM_RLG%"                             ECHO           Deleting Step 06 MailStream Log "%PRODPATH%\%MSTREAM_RLG%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%MSTREAM_RLG%"                             DEL     "%PRODPATH%\%MSTREAM_RLG%"

rem Delete Step 07 Files
IF    EXIST "%PRODPATH%\%SORTED-NCO-JOURNAL%"                      ECHO           Deleting Step 07 Sorted NCO Journal "%PRODPATH%\%SORTED-NCO-JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SORTED-NCO-JOURNAL%"                      DEL     "%PRODPATH%\%SORTED-NCO-JOURNAL%"

rem Delete Step 09 Files
IF    EXIST "%PRODPATH%\%SORTED-AUDIT-INPUT-JOURNAL%"              ECHO           Deleting Step 09 Sorted Äudit Journal "%PRODPATH%\%SORTED-AUDIT-INPUT-JOURNAL%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%SORTED-AUDIT-INPUT-JOURNAL%"              DEL     "%PRODPATH%\%SORTED-AUDIT-INPUT-JOURNAL%"

rem Delete Step 10 Files
IF    EXIST "%PRODPATH%\%POST-PROCESS-LOGFILE%"                    ECHO           Deleting Step 10 Special Handle Split Logfile "%PRODPATH%\%POST-PROCESS-LOGFILE%" >> "%PRODPATH%\%LOGFILE%"
IF    EXIST "%PRODPATH%\%POST-PROCESS-LOGFILE%"                    DEL     "%PRODPATH%\%POST-PROCESS-LOGFILE%"

rem Delete Step 11 Files
rem  -- no files to delete --

:DODELETE-DONE

SET    DOC1-BILL-RC=0

:ENDRUN
SET   "END-DATE=%DATE%"
SET   "END-TIME=%TIME%"

ECHO "=============================================================================="               >> "%PRODPATH%\%LOGFILE%"
ECHO Process Ended on %END-DATE% at %END-TIME%                                                      >> "%PRODPATH%\%LOGFILE%"
ECHO Process Ended on %END-DATE% at %END-TIME%
ECHO Process Ended with Completion Code %DOC1-BILL-RC%
ECHO Process Ended with Completion Code %DOC1-BILL-RC%                                              >> "%PRODPATH%\%LOGFILE%"

IF    EXIST "%PRODPATH%\junk.file"                                 DEL     "%PRODPATH%\junk.file"
