Hi,
Can anybody explain me the following code. Can you tell me how i need to modify this code to incorporate my scenario.
START OF CODE
umask 000
#
# Source in the home profile
#
if [ -f $HOME/.profile ]
then
. $HOME/.profile
else
echo "ERROR: Error sourcing $HOME/.profile !" >> $EBPP_DATAFEED_LOGFILE
exit 10
fi
TMP_OUTPUT_FILE="temp_log.tmp"
TMPBATCHPROC="temp_batch.tmp"
export CURRENT_FEED=`date +%Y-%m-%d`
#
# Source in the environment variables (if possible)
#
if [ -f ./eBPPDataFeed_env.rc ]
then
. ./eBPPDataFeed_env.rc
fi
#
# Set the error codes
#
. ./errorcodes.ksh
#
# Obtain the secure username and password (if it exists)
#
if [ -f "$BATCH_USER_DIR/batch_user.ksh" ]
then
TMPPWD=`pwd` # v1.1
cd $BATCH_USER_DIR # v1.1
. ./batch_user.ksh # v1.1
RTNCD=$? # v1.1
cd $TMPPWD # v1.1
if [ $RTNCD = 0 ]
then
export SIEBEL_USERNAME=$USERID
export SIEBEL_PASSWORD=$PASSWORD
else
exit $EXIT_BATCHUSER_FAILED
fi
else
echo "ERROR: batch_user.ksh does not exist, unable to source in variables" >> $EBPP_DATAFEED_LOGFILE
exit $EXIT_BATCHUSER_DOESNOTEXIST
fi
#
# Check if the Environment Variables are set, if not, exit -1
#
for i in SIEBEL_USERNAME SIEBEL_PASSWORD \
EBPP_DATAFEED_ROOT EBPP_DATAFEED_DATA EBPP_DATAFEED_SCRIPTS EBPP_DATAFEED_LOGS \
SIEBEL_DB_USERNAME SIEBEL_DB_PASSWORD SIEBEL_DB_ORACLESID SIEBEL_DB_TABLE_OWNER \
SIEBEL_ROOT EXIT_SUCCESS EXIT_ENV_MISSING EXIT_ENV_NOVALUE \
EXIT_SQLPLUSERROR EXIT_BATCHUSER_FAILED EXIT_BATCHUSER_DOESNOTEXIST MINERRORLEVEL
do
IS_SETF1=`env | grep "^$i=" | cut -d= -f1`
if [[ -z $IS_SETF1 ]]
then
echo "FATAL: Environment Variable $i is not set, terminating process" >> $EBPP_DATAFEED_LOGFILE
exit $EXIT_ENV_MISSING
fi
IS_SETF2=`env | grep "^$i=" | cut -d= -f2`
if [[ -z $IS_SETF2 ]]
then
echo "FATAL: Environment Variable $i has no value, terminating process" >> $EBPP_DATAFEED_LOGFILE
exit $EXIT_ENV_NOVALUE
fi
done
#
echo "main> INFO: Running eBPP Profile Data Feed Process with Table Owner $SIEBEL_DB_TABLE_OWNER @ `date`" >> $EBPP_DATAFEED_LOGFILE
# Let us know what we are doing
# Get the last feed date from system preferences and store in variable#
LAST_FEED=`sqlplus -S $SIEBEL_DB_USERNAME/$SIEBEL_DB_PASSWORD@$SIEBEL_DB_ORACLESID <<!
SET HEAD OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SET LINESIZE 900
SELECT VAL FROM $SIEBEL_DB_TABLE_OWNER.S_SYS_PREF where SYS_PREF_CD = 'ALLTEL - EBPP Profile Feed';
QUIT;
!`
RTNCD=$?
if [[ ! 0 = $RTNCD ]]
then
echo "ERROR: SQLPLUS Failed when searching for system preferences" >> $EBPP_DATAFEED_LOGFILE
cat $EBPP_DATAFEED_LOGFILE
exit $EXIT_SQLPLUSERROR
fi
echo "main> INFO: Last eBPP Data Feed Date" $LAST_FEED >>$EBPP_DATAFEED_LOGFILE
echo "main> INFO: Current eBPP Data Feed Date" $CURRENT_FEED >> $EBPP_DATAFEED_LOGFILE
echo "main> INFO: Start Extracting eBPP Data Feed file `date`" >> $EBPP_DATAFEED_LOGFILE
# Extract data feed and make dat file and save in data directory
# exit -1
sqlplus -S $SIEBEL_DB_USERNAME/$SIEBEL_DB_PASSWORD@$SIEBEL_DB_ORACLESID > $EBPP_DATAFEED_DATAFILE <<!
SET HEAD OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SET LINESIZE 900
-- This part of the query will pick up any B2C profile changes.
SELECT ''||ORG.X_BILL_ACCT_NUM||'|'||CON.EMAIL_ADDR||'|'||PROF.X_PAPER_BILL_FLG||''
FROM $SIEBEL_DB_TABLE_OWNER.S_CONTACT CON,
$SIEBEL_DB_TABLE_OWNER.S_ORG_EXT ORG,
$SIEBEL_DB_TABLE_OWNER.S_USER_PROF PROF
WHERE ORG.ROW_ID = CON.PR_DEPT_OU_ID
AND PROF.PAR_ROW_ID = CON.ROW_ID
AND PROF.LAST_UPD >= TO_DATE('$LAST_FEED','yyyy-mm-dd')
AND ORG.X_BILL_ACCT_NUM IS NOT NULL
AND ORG.X_B2B_ACCOUNT IS NULL
AND PROF.X_PAPER_BILL_FLG IS NOT NULL
UNION
-- This part of the query will pick up any B2B profile changes.
SELECT ''||ORG.X_BILL_ACCT_NUM||'|'||CON.EMAIL_ADDR||'|'||PROF.X_PAPER_BILL_FLG||''
FROM $SIEBEL_DB_TABLE_OWNER.S_CONTACT CON,
$SIEBEL_DB_TABLE_OWNER.S_ORG_EXT ORG,
$SIEBEL_DB_TABLE_OWNER.S_USER_PROF PROF
WHERE ORG.PR_CON_ID = CON.ROW_ID
AND PROF.PAR_ROW_ID = ORG.ROW_ID
AND PROF.LAST_UPD >= TO_DATE('$LAST_FEED','yyyy-mm-dd')
AND ORG.X_BILL_ACCT_NUM IS NOT NULL
AND ((ORG.X_B2B_ACCOUNT = 'Y') or (ORG.X_B2B_ACCOUNT ='N'))
AND PROF.X_PAPER_BILL_FLG IS NOT NULL;
QUIT;
!
RTNCD=$?
if [[ ! 0 = $RTNCD ]] || [[ ! 0 = `grep -c 'ORA-' $EBPP_DATAFEED_DATAFILE` ]]
then
echo "ERROR: There were errors during EBPP data load process. Please check the log file: $EBPP_DATAFEED_LOGFILE" >> $EBPP_DATAFEED_LOGFILE
cat $EBPP_DATAFEED_DATAFILE >> $EBPP_DATAFEED_LOGFILE
echo "Removing data file $EBPP_DATAFEED_DATAFILE"
rm $EBPP_DATAFEED_DATAFILE
RTNCD=1
exit $EXIT_SQLPLUSERROR
fi
echo "main> INFO: Total Records written to eBPP data file : `wc -l $EBPP_DATAFEED_DATAFILE | tr -s ' '| cut -d ' ' -f2`" >> $EBPP_DATAFEED_LOGFILE
echo "main> INFO: `date`" >> $EBPP_DATAFEED_LOGFILE
###added the below 2 lines HD 1597462
echo "main> INFO: Completed sql query ready to send data files to valicert server- Return Code :" $RTNCD >> $EBPP_DATAFEED_LOGFILE
if [[ 0 = $RTNCD ]]
then
# upload data file into valicert server.
# Verify that Valicert files exist in the data directory
echo "main> INFO: Connecting to VALICERT and uploading data file" >> $EBPP_DATAFEED_LOGFILE
# export VALICERT_NOTIFICATION_FILE=$EBPP_DATAFEED_SCRIPTS/valiNotificati.txt
#
# Read the files and process
#
#for FILE in `ls $EBPP_DATAFEED_DATAFILE 2> /dev/null`
for FILE in `ls $EBPP_DATAFEED_DATA/EBPP_Users_Feed*.dat 2> /dev/null`
do
if [ $FILE=$EBPP_DATAFEED_DATAFILE ]
then
echo "main> INFO: Valicert Files: Name $FILE is being uploaded" >> $EBPP_DATAFEED_LOGFILE
$VAL_ST_BIN/alltel-stc -f -g 5 -w 25 -u $FILE https://$VALICERT_CHECKFREE_USERNAME:$VALICERT_CHECKFREE_PASSWORD@$VALICERT_URL >> $EBPP_DATAFEED_LOGFILE
if [[ ! $? = 0 ]]
then
echo "FATAL: Error in uploading the file $FILE: `date` **" >> $EBPP_DATAFEED_LOGFILE
exit -1
else
print "main> INFO: Successfully Completed uploading $FILE `date '+%m-%d-%Y %H:%M:%S'`" >> $EBPP_DATAFEED_LOGFILE
tmpFN=$FILE.ctl
EBPP_DATAFEED_CONTROLFILE=$tmpFN
wc -l $FILE | tr -s " "| cut -d" " -f2 > $EBPP_DATAFEED_CONTROLFILE
$VAL_ST_BIN/alltel-stc -f -g 5 -w 25 -u $EBPP_DATAFEED_CONTROLFILE https://$VALICERT_CHECKFREE_USERNAME:$VALICERT_CHECKFREE_PASSWORD@$VALICERT_URL >> $EBPP_DATAFEED_LOGFILE
fi
fi
done
#Create csv file eBPP_Last_FeedInfo.csv file with current system date
echo "main> INFO: Create eBPP_Last_FeedInfo.csv current date $CURRENT_FEED for Data Writer" >> $EBPP_DATAFEED_LOGFILE
echo "BUSOBJ=System Preferences" > $EBPP_LAST_DATAFEED
echo "BUSCOMP=System Preferences" >> $EBPP_LAST_DATAFEED
echo "FIELD_PROPERTIES=key," >> $EBPP_LAST_DATAFEED
echo "FIELD_NAMES=Name,Value" >> $EBPP_LAST_DATAFEED
echo "BEGIN" >> $EBPP_LAST_DATAFEED
echo "ALLTEL - EBPP Profile Feed,$CURRENT_FEED" >>$EBPP_LAST_DATAFEED
echo "main> INFO: Moving files to processed directory" >> $EBPP_DATAFEED_LOGFILE
mv $EBPP_DATAFEED_DATA/EBPP_Users_Feed*.* $EBPP_DATAFEED_PROCESSED
echo "main> INFO: Update ALLTEL - eBPP Profile Feed System Preferences with current date $CURRENT_FEED, Java Beans" >> $EBPP_DATAFEED_LOGFILE
java -classpath $EBPP_DATAFEED_CLASSPATH \
com.alltel.siebel.datawriter.DataWriter $EBPP_LAST_DATAFEED >> $EBPP_DATAFEED_LOGFILE
RTNCD=$?
if [ $RTNCD != 0 ]
then
echo "ERROR: Running Java Programming failed (returned $RTNCD)! terminating process!" >> $EBPP_DATAFEED_LOGFILE
echo "Please check the log file and classpath" >> $EBPP_DATAFEED_LOGFILE
exit 40
fi
exit $EXIT_SUCCESS
##added next 2 line for HD 1597462
else
echo "Process Exited with Error " >> $EBPP_DATAFEED_LOGFILE
exit $MINERRORLEVEL
fi