Financial Accounting (FI) Management Accounting (CO) Financial supply chain Management (FSCM) module will cover the following business processes:
- Master Data Maintenance in Accounting.
- General Ledger Accounting.
- Accounts Payable.
- Accounts Receivable / Collection Management /Credit management.
- Bank Accounting /Cash Management.
- Asset Accounting.
- Closing Procedures.
- Financial Information System in FI.
- Cost Center Accounting.
- Profit Center Accounting.
- Internal Order.
- Profitability accounting.
TABLE_NAME=$1
ODATE=$2
SDATE=$3
SF_CONNECTION_NAME=”bank_prod”
SCRIPT_PATH=”/snowflake/snowflake1/scripts/sourcecode”
if [ $# -le 1 ]
then
echo “ERROR : Insufficient paramters”
echo “Please pass the below parameters…”
echo ” 1.Table Name”
echo ” 2.End Date”
echo ” 3.Start date”
exit 1
fi
if [ “$SDATE” == “” ]
then
SDATE=$ODATE
fi
TBL_EXST_SQL=”SELECT NVL(MAX(1),0) FROM PBKWSTG.BNK.SF_HIST_MIGRATION_CTRL_TBL WHERE SRC_TBL_NM=’${TABLE_NAME}’ AND PORTFOLIO_CTGY_CD=’CTP'”
TBL_EXST_IND=`snowsql -c “${SF_CONNECTION_NAME}” -o friendly=false -o header=false -o timing=false -o output_format=csv -o exit_on_error=true -q “${TBL_EXST_SQL}” | tr -d ‘” \n’`
if [ $? != 0 ]
then
echo “ERROR : Snowsql failure”
exit 3
fi
if [ ${TBL_EXST_IND} = 0 ]
then
echo “ERROR : Table entry does not exists in Control Table.”
exit 2
fi
if [ “$ODATE” != “1900-01-01” ]
then
PREV_RUN_CHECK_SQL=”SELECT NVL(MAX(1),0) FROM PBKWSTG.BNK.SF_HIST_MIGRATION_CTRL_TBL WHERE SRC_TBL_NM=’${TABLE_NAME}’ AND SRC_HIST_END_DT < '${ODATE}' AND HIST_CONV_COMPLETE_IND='N' AND PORTFOLIO_CTGY_CD='CTP'"
CHECK_IND=`snowsql -c "${SF_CONNECTION_NAME}" -o friendly=false -o header=false -o timing=false -o output_format=csv -o exit_on_error=true -q "${PREV_RUN_CHECK_SQL}" | tr -d '" \n'`
if [ $? != 0 ]
then
echo "ERROR : Snowsql failure"
exit 3
fi
if [ ${CHECK_IND} != 0 ]
then
echo "ERROR : Previous runs have not completed successfully."
exit 4
fi
fi
if [ "$ODATE" == "1900-01-01" ]
then
UPD_STMT="UPDATE PBKWSTG.BNK.SF_HIST_MIGRATION_CTRL_TBL SET SRC_TBL_EXT_DT_COL_NM='''1900-01-01''',SRC_HIST_STRT_DT='${ODATE}', SRC_HIST_END_DT='${ODATE}', SRC_HIST_LAST_INCR_DT=NULL, HIST_CONV_COMPLETE_IND='N',TBL_TYPE='FC' WHERE SRC_TBL_NM='${TABLE_NAME}' AND PORTFOLIO_CTGY_CD='CTP'"
else
UPD_STMT="UPDATE PBKWSTG.BNK.SF_HIST_MIGRATION_CTRL_TBL SET SRC_HIST_STRT_DT='${SDATE}', SRC_HIST_END_DT='${ODATE}', SRC_HIST_LAST_INCR_DT=NULL, HIST_CONV_COMPLETE_IND='N' WHERE SRC_TBL_NM='${TABLE_NAME}' AND PORTFOLIO_CTGY_CD='CTP'"
fi
snowsql -c "${SF_CONNECTION_NAME}" -o friendly=false -o header=false -o timing=false -o output_format=csv -o exit_on_error=true -q "${UPD_STMT}"
if [ $? != 0 ]
then
echo "ERROR : Snowsql failure – Updating the control table failed"
exit 3
fi
##Deleting existing entries for rerun
DEL_LD_CNTL="delete from SF_MIGRATION_SF_LD_CTRL_TBL where SF_HIST_CTRL_TBL_SK =(select SF_HIST_CTRL_TBL_SK from PBKWSTG.BNK.SF_HIST_MIGRATION_CTRL_TBL where SRC_TBL_NM ='${TABLE_NAME}' and PORTFOLIO_CTGY_CD='CTP') and ((SRC_HIST_RUN_STRT_DT = ‘${SDATE}’) or (SRC_HIST_RUN_STRT_DT = ‘${ODATE}’) or (SRC_HIST_RUN_STRT_DT > ‘${SDATE}’ and SRC_HIST_RUN_END_DT < '${ODATE}'))"
snowsql -c "${SF_CONNECTION_NAME}" -o friendly=false -o header=false -o timing=false -o output_format=csv -o exit_on_error=true -q "${DEL_LD_CNTL}"
if [ $? != 0 ]
then
echo "ERROR : Snowsql failure – Deleting the load control table failed"
exit 3
fi
export PATH="/opt/anaconda/miniconda3/bin:$PATH"
cd /opt/anaconda/miniconda3/bin
source activate bankra_sf_py37
#export PATH="/opt/anaconda/miniconda3/bin:$PATH"
#/opt/anaconda/miniconda3/bin/conda activate bankra_sf_py37
python ${SCRIPT_PATH}/run_history_nz_migration_cyberark.py "CTP" "${TABLE_NAME}"
if [ $? != 0 ]
then
echo "ERROR : Netezza extract failed"
exit 5
fi
python ${SCRIPT_PATH}/run_history_sf_migration.py "CTP" "${TABLE_NAME}"
if [ $? != 0 ]
then
echo "ERROR : Snowflake load failed"
exit 6
fi
exit 0