----Copy From One directory to another directory -----
Two method To Transfer :
Step 1: Utl_File.Frename
CREATE OR REPLACE DIRECTORY XXHRS_SOURCES_DIR AS '/u01/E-BIS/inst/apps/VISION/logs/appl/conc/out'
CREATE OR REPLACE DIRECTORY XXHRS_TARGET_DIR AS '/HOME/VIVEK'
CREATE OR REPLACE PROCEDURE APPS.XXORC_TRANSFER(ERRBUFF VARCHAR2,RETCODE NUMBER,P_REQUEST_ID NUMBER)
AS
L_FILE_NAME VARCHAR2(80);
l_format VARCHAR2(60);
BEGIN
SELECT (SUBSTR
(OUTFILE_NAME,
INSTR
(OUTFILE_NAME,
'/',
-1
)
+ 1
)) INTO L_FILE_NAME
FROM FND_CONCURRENT_REQUESTS WHERE REQUEST_ID=P_REQUEST_ID;
SELECT (SUBSTR(L_FILE_NAME,1,(INSTR(L_FILE_NAME,'.'))-1)||'.xls') into l_format FROM DUAL;
UTL_FILE.FRENAME ('SOURCES_OUT_DIR',
L_FILE_NAME,
'TARGET_DIR',
l_format,
TRUE);
END;
Step 2: Shell Script
Shell Script Code---Click Here to View Sample Code
#Shell Script Code Change Ur Code As Per Ur requiremnet
P_SOURCE_FILE="$5"
P_SOURCE_DIR="$6"
P_TARGET_FILE="$7"
P_TARGET_DIR="$8"
P_TRANSFER_MODE="$9"
SrcFilePath=$P_SOURCE_DIR/$P_SOURCE_FILE
TgtFilePath=$P_TARGET_DIR/$P_TARGET_FILE
#ensure the file exists
if [ ! -f $SrcFilePath ]; then
echo "ERROR: Source file does not exist: $SrcFilePath" >> $P_LOGFILE
exit 40
fi
#ensure the target direcotry exists
if [ ! -d $P_TARGET_DIR ]; then
echo "ERROR: Target directory does not exist: $P_TARGET_DIR" >> $P_LOGFILE
exit 50
fi
# copy and rename the file
if [ "$P_TRANSFER_MODE" = "COPY" ]; then
cp $SrcFilePath $TgtFilePath
elif [ "$P_TRANSFER_MODE" = "MOVE" ]; then
mv $SrcFilePath $TgtFilePath
else
echo "ERROR: Invalid transfer type specified: $P_TRANSFER_MODE" >> $P_LOGFILE
exit 60
fi
Any Queries Mail Me vivekexpertize@gmail.com
Two method To Transfer :
Step 1: Utl_File.Frename
CREATE OR REPLACE DIRECTORY XXHRS_SOURCES_DIR AS '/u01/E-BIS/inst/apps/VISION/logs/appl/conc/out'
CREATE OR REPLACE DIRECTORY XXHRS_TARGET_DIR AS '/HOME/VIVEK'
CREATE OR REPLACE PROCEDURE APPS.XXORC_TRANSFER(ERRBUFF VARCHAR2,RETCODE NUMBER,P_REQUEST_ID NUMBER)
AS
L_FILE_NAME VARCHAR2(80);
l_format VARCHAR2(60);
BEGIN
SELECT (SUBSTR
(OUTFILE_NAME,
INSTR
(OUTFILE_NAME,
'/',
-1
)
+ 1
)) INTO L_FILE_NAME
FROM FND_CONCURRENT_REQUESTS WHERE REQUEST_ID=P_REQUEST_ID;
SELECT (SUBSTR(L_FILE_NAME,1,(INSTR(L_FILE_NAME,'.'))-1)||'.xls') into l_format FROM DUAL;
UTL_FILE.FRENAME ('SOURCES_OUT_DIR',
L_FILE_NAME,
'TARGET_DIR',
l_format,
TRUE);
END;
Step 2: Shell Script
Shell Script Code---Click Here to View Sample Code
#Shell Script Code Change Ur Code As Per Ur requiremnet
P_SOURCE_FILE="$5"
P_SOURCE_DIR="$6"
P_TARGET_FILE="$7"
P_TARGET_DIR="$8"
P_TRANSFER_MODE="$9"
SrcFilePath=$P_SOURCE_DIR/$P_SOURCE_FILE
TgtFilePath=$P_TARGET_DIR/$P_TARGET_FILE
#ensure the file exists
if [ ! -f $SrcFilePath ]; then
echo "ERROR: Source file does not exist: $SrcFilePath" >> $P_LOGFILE
exit 40
fi
#ensure the target direcotry exists
if [ ! -d $P_TARGET_DIR ]; then
echo "ERROR: Target directory does not exist: $P_TARGET_DIR" >> $P_LOGFILE
exit 50
fi
# copy and rename the file
if [ "$P_TRANSFER_MODE" = "COPY" ]; then
cp $SrcFilePath $TgtFilePath
elif [ "$P_TRANSFER_MODE" = "MOVE" ]; then
mv $SrcFilePath $TgtFilePath
else
echo "ERROR: Invalid transfer type specified: $P_TRANSFER_MODE" >> $P_LOGFILE
exit 60
fi
Any Queries Mail Me vivekexpertize@gmail.com
No comments:
Post a Comment