Saturday, 9 November 2019

Host file script to remove the files from server directory in Oracle apps r12: Oracle Script to remove the file from ftp location

Host file script to remove the files from server directory in Oracle apps r12: Oracle Script to remove the file from ftp location

In this post , We will be discuss about , how programmatically we can remove the files from any server directories in oracle apps r12. We can create the concurrent program as a type 'Host' to remove the files from server directories. We will try to write some unix commands to remove the file from the server directory. We can execute the Unix Commands as a program files in oracle application through register as a type 'Host' File. Here below I will share the script and the steps to remove the files from server directory in Oracle apps r12.
 

Step by Step to remove the files from server directory in Oracle apps r12 

Step1:- Here below is the Unix Script to remove the files from Oracle Server directory in Oracle apps r12. In this Script , We have created two Parameters
FILENAME :- 'Name of the file which we want to remove from server'
P_DIRECTORY :- 'Directory name or Path from that we want to remove the file.
 
This below script we need to store as a FILE_NAME.prog file.
 

Script Started Below :

 
echo "Checking for input parameters..."

# Get all the parameters.
 FILENAME=$5
 P_DIRECTORY=$6

echo "End of parameter list"

initialize_local()
{
 DATE=`date +%Y%m%d%H%M%S`
 echo $DATE
 echo "Initializing Local"

 if test -f $P_DIRECTORY/$FILENAME
 then
  echo 'File exists'
 else
    echo "No Data File exists to process."
    echo "==============================================="
    error_message="No Data file exists to process.\n"
    PROG_STATUS=2
    error_flag=1
    exit
 fi
 FILENAME=`ls -tr $P_DIRECTORY/$FILENAME|head -1`

 error_flag=0
 error_message=""
 PROG_STATUS=0 
 echo 'At the end of initialize_local'

}
 
remove_files()
{
 ### Removing the Files ###
 if test -f $FILENAME
 then
  ## cp -f $FILENAME $ARC_DIR/$FILENAME"."$EXTN   
  ## mv -f $FILENAME $ARC_DIR/$FILENAME"."$EXTN       ##"Processed_"$filename_withext
  rm -f $FILENAME
 else
   echo "No Files to Archive..."
 fi
 echo 'At the end of remove_files'
}

main()
{
 echo "Start of Data Import Program at: `date +%Y/%m/%d-%H:%M:%S`"
 echo ""
 echo $FILENAME
 echo $P_DIRECTORY

 initialize_local
 if [ $error_flag = 0 ]
  then
  remove_files
  fi

 ### Exit with Program Status ###  
      
 exit $PROG_STATUS
}
main
 

Script Ended

 
Step2:- Once we store this script as a PROG file , we need to put that file in the Custom Top for example XXAP_TOP/bin/  under bin directory.
 
 
Step3:- Create Concurrent Program as a Executable Type 'HOST.
 
In the Concurrent Program Definition , We need to create two Parameters , First for Entering the File Name and Second for entering the Server Directory Path as below.
 
In Process .......
 
 

2 comments:

12345 said...

Good blog thanks for sharing this informative article. It would be helpful full to all.
Oracle Fusion HCM Online Training

Anonymous said...

I like this article very much, if Anyone Reads Your Blog, Each And Every one will appreciate you.
Oracle Fusion Financials Online Training

Post a Comment

Contact us for any Collaboration, Project Support & On Job Support Work

Name

Email *

Message *