Oracle EBS 基于Host(主机文件)并发程序的开发

 

在EBS开发过程中,经常会遇到一些修改或开发基于Host的并发请求,比如Sqlloader导数、sendmailSVF报表等,现就以“将一个CSV格式文件中的数据导入到一张临时表中”的例子简单介绍下Host类型请求的开发方法:

 

1、在服务器上定义一个路径,并使用FTPCSV数据文件上传到该路径下:

 

--1、创建DIRECTORY

create directory test_dir as '/usr/tmp'; (注:此处'/usr/tmp'可以是任何路径,只要该路径在服务器上存在)

--2、授权

Grant read,write on directory test_dir to cux;

--3、查看目录及权限

SELECT privilege, directory_name, directory_path

  FROM user_tab_privs t, all_directories d

 WHERE t.table_name(+) = d.directory_name

 ORDER BY 2, 1;

  

2、定义一张临时表,命名为:cux_sqlloader_temp

3、创建sqlloader导入时的control文件,命名为:cux_sqlloader_control.ctl,并将该控制文件一并上传到前面定义好的路径下(注:该例子中为了简单起见,所以将所有文件均放在同一个目录下。在正式开发中需要根据情况分别定义各自的路径)

4编写Shell脚本文件,假如名为:cux_sqlloader_test.prog(注:后缀名为prog,是否必须为prog尚未作研究),伪代码如下:

#!/bin/ksh
#Default Parameters
export ORA_USER_PASS =$1
export ORA_USER_ID   =$2
export ORA_LOGIN_NAME=$3
export ORA_REQUEST_ID=$4

#User Defined Parameters
export P_FILE_NAME   =$5
export P_CONTROL_FILE=$6

  
# Initialize the environment variables by running the enviroment file
#*********************************************************************
# Initialize the environment variables by running the enviroment file*
#*********************************************************************

Initialize_Vars ()
{
   
   echo "Initializing"
      ### Initialize the environment variables by running the enviroment file
      . ${CUX_TOP}/bin/CUX_env      
      export SCRIPT_DIR="${CUX_TOP}/bin"
      export TEMP_DIR=`eval echo $test_dir`
      
}

#*********************************************
#    Check for the AP Directory              *
#*********************************************
check_temp_dir ()
{
     if [ ! "$TEMP_DIR" ];
          then
             echo " $TEMP_DIR irectory path is not specified in the environment file."
             echo "Check CUX_env"
             return 2
     fi

     if [ ! -d $TEMP_DIR ];
          then
             echo "Invalid Directory. "$TEMP_DIR" may not be existing."
             return 2
     fi

     return 0
}
#*************************************************
#    Check for the Script Directory              *
#*************************************************
check_script_dir ()
{
     #Check whether the scrip directory Exists or not
     if [ ! -d $SCRIPT_DIR ];
          then
             echo "Invalid Script Directory. "$SCRIPT_DIR" may not be existing."
             return 2
     fi     
     echo "Valid Script Directory. "$SCRIPT_DIR" exists."
     return 0
}

#Calling Main Program
#*********************************************
#                 Main Program               *
#*********************************************
main ()
{ 
   #Calling Initialize Variables to set the paths in Environment File

   Initialize_Vars
   exe_status=$?

   #Start of  First If statement
   if [ $exe_status -ne 0 ];
   then
     echo "Intialize variables failed so Exiting"
     exit  $exe_status
   fi
   #End of  First If statement

   #Calling check_script_dir to check 
   check_script_dir
   exe_status=$?

   #Start of  Second If statement
   if [ $exe_status -ne 0 ];
   then
   echo "check_script_dir failed. So Exiting"
   exit  $exe_status
   fi
   #End of  Second If statement   

   check_gl_dir
   exe_status=$?
   
   #Start of  Third If statement
   if [ $exe_status -ne 0 ];
   then
   echo "check_temp_dir failed. So Exiting"
   exit  $exe_status
   fi
   #End of  Third If statement

   echo "SQL_Loader program about to start for the file : " $P_FILE_NAME
   
   #Loading data using SQL Loader
   sqlldr $CUX_LOGIN silent=header silent=feedback control=$TEMP_DIR/$P_CONTROL_FILE data=$TEMP_DIR/$P_FILE_NAME log=$TEMP_DIR/$P_FILE_NAME"_"$ORA_REQID.log errors=10000 discardmax=10000
   l_num_ldr_status=$?
   
   echo $l_num_ldr_status
   
   if [ $l_num_ldr_status -eq 1 ] || [ $l_num_ldr_status -eq 3 ] ;
   then
     echo "SQL Loader Failed to Load data file"
     l_file_status=E
   else
     echo "SQL Loader Successfully Loaded the data file"
     l_file_status=N
   fi
  exit 0 
}
main

 

注意:前4个参数被系统接受,如果自己要添加参数,则从第五个开始

#Default Parameters

export ORA_USER_PASS =$1

export ORA_USER_ID   =$2

export ORA_LOGIN_NAME=$3

export ORA_REQUEST_ID=$4

 

 #User Defined Parameters

export P_FILE_NAME   =$5

export P_CONTROL_FILE=$6

$4以后是host并发程序传进去的参数。

 

5定义执行方法为:主机(HOST)的并发可执行

6、定义并发程序

7、上传cux_sqlloader_test.prog到$CUX_TOP/bin/目录

8、添加可执行权限 chmod 777 cux_sqlloader_test.prog

9创建连接 ln -s $FND_TOP/bin/fndcpesr $CUX_TOP/bin/cux_sqlloader_test这样cux_sqlloader_testt脚本就可以接受并发请求传进去的参数

10、到此开发完成,可以跑请求了!

你可能感兴趣的:(oracle)