Technical‎ > ‎Concurrent Programs‎ > ‎

Copying Output of Concurrent Program to a given directory


Have you ever run into a situation where you want to copy the output of the concurrent program to a specific directory with a specific name.
The approach I used was to Create a Request Group with two programs. Lets call the first Program Generating Output and the second program Copying Output.
Now the Copying Output program would accept one parameter which is the Filename you would like to have. For the executable for the Copying Output program use the below shell script.
The below shell script assumes that the Generating Output program is generating the output in excel format.
#################################################################################
## File Name : XX_COPY_OUTPUT_TO_DIFF_DIR.prog
## Purpose : This Program is used for copying the excel file generated by
## concurrent program to a location on Middle Tier
##################################################################################

#***** Getting Login Details *****
v_db_login=$1

#***** Getting Request Id *****
v_req_id=$4
v_file_name=$5
#******Getting the request id for the concurrent program *
echo " The login is $1"
echo "Request Id:$2"
l_request_id=`sqlplus -s $FCP_LOGIN<<-EOF
SET PAGESIZE 0;
SELECT FRR1.REQUEST_ID FROM APPS.FND_RUN_REQUESTS FRR1,APPS.FND_RUN_REQUESTS FRR2 WHERE FRR1.PARENT_REQUEST_ID=FRR2.PARENT_REQUEST_ID AND FRR2.REQUEST_ID=${v_req_id} AND FRR1.REQUEST_ID <>FRR2.REQUEST_ID;
EXIT;
EOF`
if [ -z $l_request_id ]; then
echo "Error in fetching the request id of the concurrent program"
exit 2
fi
echo "The request id of the Excel file program is $l_request_id"
#********* Getting the output directory where the output file is lcoated ****************
l_output_dir=`sqlplus -s $FCP_LOGIN<<-EOF SET PAGESIZE 0;
select substr(outfile_name,1,instr(outfile_name,'/',-1,1)-1) from apps.FND_CONCURRENT_REQUESTS where request_id=to_number(${l_request_id}); EXIT;
EOF`
if [ -z l_output_dir ]; then
echo "No output directory. Error in fetching the output directory"
exit 2
fi
echo "The output directory is $l_output_dir"
#******** Removing leading and trailing spaces in the request id ********************
l_request_id=`echo $l_request_id sed 's/^[ \t]*//;s/[ \t]*$//'`
echo "The Request is $l_request_id"
#**********Getting the filename of the excel file *******************
l_filename=`ls $l_output_dirgrep .*$l_request_id.*EXCEL`
if [ -z $l_filename ]; then
echo "No excel file generated for the concurrent program "
exit 2 fi
echo "The filename is $l_filename"
#****** Filepath of the excel file *******
l_filepath=$l_output_dir"/"$l_filename
echo "The filepath is $l_filepath"
cp $l_filepath $DATA_DIR'/outbound/'$v_file_name
if [ $?=0 ]; then
echo "Successfully copied the file $v_file_name"
else
echo "Error in copying the file"
exit 2
fi

In case you face any issues do leave a comment and I will get back to you

Free Hit Counters
Comments