Friday, April 19, 2019

Oracle Shell Script to download Concurrent Program LDT


CUR_DIR=`pwd`
BKTIMESTAMP=`date +%d%h%Y_%H%M`
PRINTTIME=`date +%d-%h-%Y_%T`
APPS_LOGIN_ID="$1"
APPS_CONNECT="$1"
# *******************************************************************         
#  Function to Check the validity of DB Login                   
# ******************************************************************* 
CHKLOGIN(){
    if sqlplus -s /nolog <<! >/dev/null 2>&1
         WHENEVER SQLERROR EXIT 1;
         CONNECT $1 ;
         COLUMN tbl NEW_VALUE tbl_name NOPRINT;
          SELECT table_name tbl
             FROM user_tables
             WHERE table_name = '$2' ;
         EXIT;
!
     then
          echo OK
     else
          echo NOK
     fi
}

start_ldt_download()
{
echo " "
echo " "
echo "Hi Current time is  : $PRINTTIME"
echo "###########################################################################"
echo "                  Development Backup & Migration Tool                      "
echo "###########################################################################"
echo "   "
echo "   Select the desired Option from the list below..."
echo "  "
echo "  1. Concurrent Program"
read userAction
if [ "$userAction" = "1" ];then               
          concurrentLDT                                                     
        fi                               
}
read_apps_pwd()
{
while [ "$APPS_LOGIN_ID" = "" -o `CHKLOGIN "$APPS_LOGIN_ID" "DUAL"` = "NOK" ] 
do
                                                                         
    if [ "$APPS_LOGIN_ID" = "" ];then                                         
        echo "Enter APPS Password : "            
        read pass
         APPS_LOGIN_ID="APPS/$pass" 
        if [ "$APPS_LOGIN_ID" = "" ];then                                     
            APPS_LOGIN_ID="apps/apps"                                         
        fi                                                                    
    else                                                                      
        echo "APPS Userid/Passwd INCORRECT. Please Re-enter"                  
        APPS_LOGIN_ID=""                                                      
    fi                                                                        
done 
                                                                         
APPS_LOGIN=`echo $APPS_LOGIN_ID | cut -d"/" -f1`                              
APPS_PWD=`echo $APPS_LOGIN_ID | cut -d"/" -f2`

}
read_app_short_name()
{
echo "Getting Application Short Name "
APPS_SHORT_NAME=$(sqlplus -s $APPS_LOGIN_ID <<END
set heading off;
set echo off;
select fa.application_short_name
from  fnd_concurrent_programs fcp , fnd_application fa
where fcp.application_id = fa.application_id
and CONCURRENT_PROGRAM_NAME = '$cpShortName';
EXIT;
END)
while [ "$APPS_SHORT_NAME" = "" ]
do
echo "Enter Application Short Name : "
read APPS_SHORT_NAME
done
echo " Application Short Name is $APPS_SHORT_NAME"
}
read_cp_name()
{
echo "Please Enter the Concurrent Program Short Name :  "
read cpShortName
while [ "$cpShortName" = "" ]
do
echo "Please Enter the Concurrent Program Short Name :  "
read cpShortName
done
}
read_jdbc_connect()
{
 if [ "$APPS_CONNECT" = "" ]
then
  APPS_CONNECT="$AD_APPS_JDBC_URL"
fi
  if [ "$APPS_CONNECT" = "" ]
  then
    echo  "Enter APPS JDBC Connect String for RTF loader [host_ipaddr:port_no:sid]"
read APPS_CONNECT
while [ "$APPS_CONNECT" = "" ]                                  
do
   echo  "Enter APPS JDBC Connect String for RTF loader [host_ipaddr:port_no:sid]"
   read APPS_CONNECT
done
  fi
}
# +*******************************************************************+
#  Function to Copy the Files to the folder                              
# +*******************************************************************+
mcp()
{
 
#if [ -e "$2" ]
#  then
#cp $2 "$2.$BKTIMESTAMP" >> $LOG_FILE
#echo "Copied $2 to $2.$BKTIMESTAMP" >>$LOG_FILE
#  fi
 
  cp $1 $2
  if [ $? = 0 ]
  then
    echo "Copied $1 to $2" >>$LOG_FILE
  else
    echo "Copy of $1 failed!! Exiting.... " >>$LOG_FILE
    exit 2
  fi
}
concurrentLDT()
{                 
     read_apps_pwd          
     read_cp_name
     read_app_short_name
     read_jdbc_connect
     download_ldt
     mcp $XXINJ_TOP/reports/US/$cpShortName.rdf $CUR_DIR/$cpShortName.rdf
}
# *******************************************************************         
#  Check if APPS Login Id is entered else prompt to get it                    
# *******************************************************************         

download_ldt()
{
 echo "Downloading $cpShortName"

if [ "$APPS_LOGIN_ID" = "" ]
  then
    read_apps_pwd
fi

LCT_FILE="$FND_TOP/patch/115/import/afcpprog.lct"
LDT_FILE_NAME="$cpShortName.ldt"
LDT_FILE_TYPE="_CP.ldt" 
echo "Type : Concurrent Program. LDT Download Started ....."
if FNDLOAD $APPS_LOGIN_ID O Y DOWNLOAD $LCT_FILE $cpShortName$LDT_FILE_TYPE PROGRAM APPLICATION_SHORT_NAME=$APPS_SHORT_NAME CONCURRENT_PROGRAM_NAME=$cpShortName  >> $LOG_FILE
# CUSTOM_MODE=FORCE UPLOAD_MODE=REPLACE
then
   echo
   echo "Successfully loaded LDT : $2."       >> $LOG_FILE
   echo
else
   echo
   echo "Failed to load LDT."          >> $LOG_FILE
    exit 2
   echo
fi
echo "FNDLOAD $APPS_LOGIN_ID O Y DOWNLOAD $LCT_FILE $LDT_FILE_NAME PROGRAM APPLICATION_SHORT_NAME=$APPS_SHORT_NAME CONCURRENT_PROGRAM_NAME=$cpShortName"  >> $LOG_FILE

LCT_FILE="$XDO_TOP/patch/115/import/xdotmpl.lct"
LDT_FILE_NAME="$cpShortName.ldt"
LDT_FILE_TYPE="_DD.ldt" 
echo "Type : XML. LDT Download Started ....."
echo "FNDLOAD $APPS_LOGIN_ID O Y DOWNLOAD $LCT_FILE  $cpShortName$LDT_FILE_TYPE XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=$APPS_SHORT_NAME DATA_SOURCE_CODE=$cpShortName TMPL_APP_SHORT_NAME=$APPS_SHORT_NAME TEMPLATE_CODE=$cpShortName"
if FNDLOAD $APPS_LOGIN_ID O Y DOWNLOAD $LCT_FILE  $cpShortName$LDT_FILE_TYPE XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=$APPS_SHORT_NAME DATA_SOURCE_CODE=$cpShortName TMPL_APP_SHORT_NAME=$APPS_SHORT_NAME TEMPLATE_CODE=$cpShortName  >> $LOG_FILE
# CUSTOM_MODE=FORCE UPLOAD_MODE=REPLACE
then
   echo
   echo "Successfully loaded LDT : $2."       >> $LOG_FILE
   echo
else
   echo
   echo "Failed to load LDT."          >> $LOG_FILE
    exit 2
   echo
fi
echo "FNDLOAD $APPS_LOGIN_ID O Y DOWNLOAD LCT_FILE  $cpShortName$LDT_FILE_TYPE XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=$APPS_SHORT_NAME DATA_SOURCE_CODE=$cpShortName TMPL_APP_SHORT_NAME=$APPS_SHORT_NAME TEMPLATE_CODE=$cpShortName"  >> $LOG_FILE
LCT_FILE="$XDO_TOP/patch/115/import/xdotmpl.lct"
LDT_FILE_NAME="$cpShortName.ldt"
LDT_FILE_TYPE="_DD.ldt" 
echo "Downloading RTF file ....."
echo "java oracle.apps.xdo.oa.util.XDOLoader DOWNLOAD -DB_USERNAME $APPS_LOGIN -DB_PASSWORD $APPS_PWD -JDBC_CONNECTION "$APPS_CONNECT" -LOB_TYPE TEMPLATE -APPS_SHORT_NAME $APPS_SHORT_NAME -LOB_CODE $cpShortName -LANGUAGE en -TERRITORY 00 -lct_FILE $XDO_TOP/patch/115/import/xdotmpl.lct"
if java oracle.apps.xdo.oa.util.XDOLoader DOWNLOAD -DB_USERNAME $APPS_LOGIN -DB_PASSWORD $APPS_PWD -JDBC_CONNECTION "$APPS_CONNECT" -LOB_TYPE TEMPLATE -APPS_SHORT_NAME $APPS_SHORT_NAME -LOB_CODE $cpShortName -LANGUAGE en -TERRITORY 00 -lct_FILE $XDO_TOP/patch/115/import/xdotmpl.lct
# CUSTOM_MODE=FORCE UPLOAD_MODE=REPLACE
then
   echo
   echo "Successfully loaded LDT : $2."       >> $LOG_FILE
   echo
else
   echo
   echo "Failed to load LDT."          >> $LOG_FILE
    exit 2
   echo
fi
echo "FNDLOAD $APPS_LOGIN_ID O Y DOWNLOAD LCT_FILE  $cpShortName$LDT_FILE_TYPE XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=$APPS_SHORT_NAME DATA_SOURCE_CODE=$cpShortName TMPL_APP_SHORT_NAME=$APPS_SHORT_NAME TEMPLATE_CODE=$cpShortName"  >> $LOG_FILE

}
print_log()
{
echo "############ Log Messages during installation #####################"
cat $LOG_FILE
echo "############ End of Log Messages ##################################"
echo "-------------------------------------------------------------------"
echo "Script completed successfully."
echo "See $LOG_FILE for complete log information."
echo "-------------------------------------------------------------------"
}

#========================================================================================
# Actual instructions starts here.
#========================================================================================
#-------------MANDATORY & Default Parameters----------------------------------------
MRFNO="CP_Log_File"
export LOG_FILE=$CUR_DIR/$MRFNO.log
start_ldt_download
#-------------Print Log-------------------------------------------------------------
print_log

No comments:

Post a Comment