You are on page 1of 5

#!

/usr/bin/ksh

# set global variables


# . /opt/cpss/$gcsEnvName/scripts/set_dstage_global_vars.ksh

############################################################################
# Shell script name : CP##_SACMDE10.ksh
#
#
DESCRIPTION: Stages dental member information.
#
#
VERSION: 1.00
#
#
LANGUAGE: Kornshell Script
#
#--------------------------------------------------------------------------#
INSTALLATION: REGENCE
#
#
PROJECT: RWR 5349 Les Schwab: Process Outgoing Dental File
#
#
DATE WRITTEN: 2013-11-08
#
#--------------------------------------------------------------------------#
#
DETAIL DESCRIPTION: This script executes the Datastage sequenceY SACMDE1
0_SEQ.
#
Note that CP##_SACMDE10 also executes the same datas
tage
#
sequence, but the ksh wrapper for each use different
#
DataStage parameters.
#
#
SPECIAL CONSIDERATIONS/RESTRICTIONS: none
#
#===========================================================================
# MODIFICATION HISTORY
#
# Date
Chg ID Developer
Release Description of Change
#===========================================================================
# 2013-11-08 r626279 Sripal Reddy
1.0
Original Write
#
#############################################################################

date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'


typeset -i rc=0

###----------------------------------------------------------------### Set job use variables.


###----------------------------------------------------------------##
vendor code getting from control m

VendorCd=$1
### Set KshName to this script's name for use in log messaging ###
KshName=`echo $(basename $0) | cut -c 1-13`

### Set DataStage job name to be executed ###


DSJobName="SACMDE10_SEQ"

### Set DataStage project from script run path ###


gcsDSProj=`echo $0 | cut -f 5 -d /`

### Set Error Filename


ErrFile=$KshName.$$

###----------------------------------------------------------------echo "Set DataStage environment."


###-----------------------------------------------------------------

. /opt/apps/ds/dsenv_set -u 8.1.0

echo '*************************************************************'
echo "****** ${KshName} - START
******"
echo '*************************************************************'

DatFilePath=$gcsEnvHomeDat
DSProj=`echo $0|cut -f 5 -d /`

#############################################################################
# Look up Oracle server and credentials
#############################################################################

echo "******** Looking up items from Oracle ********"

echo "Getting oracle variables from parm files..."

oracleParmFile=/opt/apps/ds/$DSProj/parms/miniapps_oracle.parm
oracleSecureParmFile=/opt/apps/ds/$DSProj/parms/secure/shac_oracle_sec.parm

if [ ! -f $oracleParmFile ]
then
echo "***ERROR: oracle parm file $oracleParmFile does not exist."
exit 1
fi
. $oracleParmFile

if [ ! -f $oracleSecureParmFile ]
then
echo "***ERROR: oracle secure parm file $oracleSecureParmFile does not e
xist."
exit 1
fi
. $oracleSecureParmFile

echo "Server: $ORACLE_SERVER"


echo "UID: $ORACLE_UID"

#############################################################################
# Look up distinct Regence group ID's from import/export table
#############################################################################

rawGroupId=`sqlplus -s $ORACLE_UID/$ORACLE_PASSWORD@$ORACLE_SERVER << EOF


whenever sqlerror exit 2;
set heading off;
select DISTINCT SVG.RGNCE_GRP_ID \
from E2E.SHAC_VENDR SV \
inner join E2E.SHAC_VENDR_GRP SVG \
on SV.SHAC_VENDR_ID = SVG.SHAC_VENDR_ID \
inner join E2E.SHAC_VENDR_GRP_DNTL SVGD \
on SVG.SHAC_VENDR_GRP_ID = SVGD.SHAC_VENDR_GRP_ID \
where SV.VENDR_CD ='$VendorCd';

exit;
EOF`
if [ $? -ne 0 ]
then
echo "Error retrieving vendor group IDs from Oracle:"
echo "******************"
echo "$rawGroupId"
echo "******************"
echo "Exiting with status 1."
exit 1
fi
while read v
do
value=`echo $v | tr -d ' \n'`
if [[ $value == '' ]]
then
continue
fi
if [ -z "$groupId" ]
then
groupId="\\\\\\'$value\\\\\\'"
else
groupId="$groupId,\\\\\\'$value\\\\\\'"
fi
done <<END
$rawGroupId
END

groupIdParm="GROUP_ID=$groupId"
echo "$groupIdParm" > "/opt/apps/ds/$DSProj/parms/shac_sacmde10_misc.parm"
echo "VENDR_CD=\\\\\\'$VendorCd\\\\\\'" >> "/opt/apps/ds/$DSProj/parms/shac_sacm
de10_misc.parm"
echo "FILENAME=PROD_REG2$VendorCd_DENTAL">> "/opt/apps/ds/$DSProj/parms/shac_sac
mde10_misc.parm"
echo "shac_sacmde10_misc.parm reads:"
cat "/opt/apps/ds/$DSProj/parms/shac_sacmde10_misc.parm"

#############################################################################
# Call the Datastage job
#
#############################################################################

cd $DatFilePath

echo "******** Build Parm List for job $DSJobName ****************"

. parmlistbld.ksh miniapps_paths.parm miniapps_oracle.parm shac_oracle_sec.parm


miniapps_facets.parm miniapps_facets_sec.parm shac_sacmde10_misc.parm
rc=$rc+$?
if [ $rc -gt 0 ] ;then
echo "ERROR: ${KshName}- Parmameter list creation failed"
exit $rc
else
PARMLIST=$v_parms
echo "Msg: ${KshName}- Parameter list creation successful"
fi

echo "************ Start DataStage job $DSJobName **************"


dsjob_launch.ksh "$PARMLIST" $gcsDSProj $DSJobName
rc=$rc+$?
#rm $ErrFile

if [ $rc -ne
then
echo
exit
else
echo
fi

0 ]
"ERROR: ${KshName}- DataStage job $DSJobName failed: See Log"
$rc
"Msg: ${KshName}- DataStage job $DSJobName successful"

date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'

echo '*************************************************************'
echo "****** ${KshName} - END
******"
echo '*************************************************************'
exit $rc
#############################################################################
# End of CP##_SACMDE10.ksh
#
#############################################################################

You might also like