#!/usr/bin/ksh

# ***********************************************************************************
#  Platform:      Unix - AIX                                                        *
#  Printstream:   PDF                                                               *
#  Application:    main batch driver                                                *
# ==================================================================================*
#  Master Command File called to execute integrated Sort, DOC1 Generate and PCE,    *
#  and Print Files for SPL Field Order Print                                        *
# ==================================================================================*
#  This command file may be launched in either of the two following manners:        *
#    BATCH:  The process will be invoked from the SPL process scheduler             *
#    ONLINE: The process will be invoked from a button on a screen                  *
#  To accomodate the different modes, the need arises to pass a parameter that      *
#  identifies the name of the input data:                                           *
#    Parameter 1:  fully pathed file name of the field order extract                *
#                  ignored for Batch - uses default of FOPXTR01.DAT                 *
# ***********************************************************************************


# ***********************************************************************************
#    Modify the following file paths for each installation environment              *
# ==================================================================================*
#      D1HOST                                                                       *
#              - Names root directory where the DOC1 Generate was installed         *
#              - Typical value:                                                     *
#                D1HOST=/group1/doc1/productionengines                              *
#      D1APPATH                                                                     *
#              - Names directory containing HIP, INI, CTL, OPS, ETS                 *
#              - Sample coding:                                                     *
#                D1APPATH=/group1/doc1/application/bill                             *
#      PRODPATH                                                                     *
#              - Names directory for output files from Sort and DOC1;               *
#              - Sample coding: PRODPATH=/prod/doc1/files                           *
#      XTRCTPTH                                                                     *
#              - Names directory containing SPL Bill Print Extract                  *
#              - Sample coding: XTRCTPTH=/spl/extract                               *
# ***********************************************************************************

export D1HOST=$4                                                       
export D1APPATH=$2                                                      
export PRODPATH=$SPLEBASE/splapp/billView                                                     
export XTRCTPTH=$5                                                                            
export ONLINE_PDF=$6/$3.$1.PDF



# ***********************************************************************************
#    The following switches which enable certain steps to be bypassed               *
# ==================================================================================*
#      PRINTFILES                                                                   *
#              - May be:  Y or N                                                    *
#              - "N" prevents files from being copied into InfoPrint Hotfolders     *
#      RUN_TYPE                                                                     *
#              - Indicates that this execution is for batch rather than online      *
#              - Acceptable values are BATCH and ONLINE; use BATCH for Batch Field  *
#                Orders (ONLINE is for SPL-invoked "Display Field Order" button)    *
#              - value of RUN_TYPE=BATCH enables all steps within the called Unix   *
#                shell script to be run                                             *
#      DELETEFILES                                                                  *
#              - May be:  Y or N                                                    *
#              - "N" prevents intermediate work files from being deleted            *
# ***********************************************************************************

PRINTFILES=Y;                                                                          export PRINTFILES
RUN_TYPE=ONLINE;                                                                       export RUN_TYPE
DELETEFILES=Y;                                                                         export DELETEFILES

# ***********************************************************************************
#    The following symbols are used for controls                                    *
# ==================================================================================*
#      PSTREAM                                                                      *
#              - Identifies the type of print description language for output       *
#              - Possible values are AFP, PDF or PostScript                         *
#      PRES                                                                         *
#              - Indicates the resolution for the printer                           *
#              - For PDF, this must be 72                                           *
# ***********************************************************************************

PSTREAM=PDF                                                                             export PSTREAM
PRES=72                                                                                 export PRES

# ***********************************************************************************
#    The symbols identify application resource files for DOC1.  These values of the *
#    file names should not be changed unless the files are renamed or replaced.     *
# ==================================================================================*
#   L O G F I L E                                                                   *
#   =============                                                                   *
#      LOGFILE                                                                      *
#              - Name of a log file to be created by this process                   *
#              - Previous version of file will be replaced                          *
#              - File will be written to $PRODPATH directory                        *
#              - Sample coding:  LOGFILE=cis-fop.log                                *
#                                                                                   *
#    D O C 1   R E S O U R C E   F I L E S                                          *
#    =====================================                                          *
#      GEN_OPS                                                                      *
#              - Names DOC1 Generate Initialization file for Format Field Orders    *
#              - Sample value: GEN_OPS=template\_s5_v3_doc1gen.ops                     *
#              - File must be present in the $D1APPATH directory                    *
#      GEN_HIP                                                                      *
#              - Name of DOC1 Generate Application Rules (.HIP)                     *
#              - Sample value: GEN_HIP=template\_s5_v3_doc1gen_pdf.hip                 *
#              - File must be present in the $D1APPATH directory                    *
#      GEN_ETS                                                                      *
#              - Names Look-Up file                                                 *
#              - Sample value: GEN_ETS=$template\_s5_v3_doc1gen.ets                     *
#              - File must be present in the $D1APPATH directory                    *
#      FOP_PCE_INI                                                                  *
#              - Names DOC1PCE Initialization file                                  *
#              - Sample value: FOP_PCE_INI=$template\_s5_v3_postp_pce.ini               *
#              - File must be present in the $D1APPATH directory                    *
#      FOP_PCE_CTL                                                                  *
#              - Names DOC1PCE Rules file for Post Process step                     *
#              - Sample value: POST_PCE_CTL=$template\_s5_v3_postp_pce.ctl              *
#              - File must be present in the $D1APPATH directory                    *
#                                                                                   *
#    S P L   F I E L D   O R D E R   P R I N T   F I L E                            *
#    ===================================================                            *
#      SPL_UNSORTED_EXTRACT                                                         *
#              - Names SPL Field Order Print Extract                                *
#              - Typical coding SPL_UNSORTED_EXTRACT=fopxtr01.dat                   *
# ***********************************************************************************

GEN_OPS=$template\_s5_v3_doc1gen.ops;                                                      export GEN_OPS
GEN_HIP=$template\_s5_v3_doc1gen_pdf.hip;                                                      export GEN_HIP
GEN_ETS=$template\_s5_v3_doc1gen.ets;                                                      export GEN_ETS
FOP_PCE_INI=$template\_s5_v3_postp_pce.ini;                                                export FOP_PCE_INI
FOP_PCE_CTL=$template\_s5_v3_postp_pce.ctl;                                                export FOP_PCE_CTL
LOGOXML=$template\_s5_v3_doc1gen_logo.xml;                                                 export LOGOXML
if [ $2 = O ]
   then
     SPL_UNSORTED_EXTRACT=$3.$1.DAT;                                                   export SPL_UNSORTED_EXTRACT
     LOGFILE=$3.$1.log;                                                                export LOGFILE
   else
     SPL_UNSORTED_EXTRACT=$3.$1.DAT;                                                   export SPL_UNSORTED_EXTRACT
     LOGFILE=$3.$1.log;                                                                export LOGFILE
fi

rm -f $PRODPATH/$LOGFILE

$D1APPATH/s5_v3_called_jobsteps.sh
