20150730 Created By BaoXinjian

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_OAF一、摘要


并发程序调用Java类型的Concurrent Program

主要实现类

1. runProgram(CpContext cpContext):并发程序导入接口

2. cpcontext.getParameterList():获取参数Parameters Hashtable

3. cpContext.getReqCompletion(): 获取并程序运行状态设定

4. cpContext.getLogFile():输出日志

5. cpContext.getOutFile():输出报表


OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_java包_02二、实现分析


1. 开发Java ConcProg的实例应用

package bxj.oracle.apps.ap.java;

import java.util.Hashtable;

import oracle.apps.fnd.cp.request.CpContext;
import oracle.apps.fnd.cp.request.JavaConcurrentProgram;
import oracle.apps.fnd.cp.request.LogFile;
import oracle.apps.fnd.cp.request.OutFile;
import oracle.apps.fnd.cp.request.ReqCompletion;
import oracle.apps.fnd.cp.request.ReqDetails;
import oracle.apps.fnd.util.NameValueType;
import oracle.apps.fnd.util.ParameterList;

public class runEmpConcProg implements JavaConcurrentProgram{

private LogFile mLogFile;
private OutFile mOutFile;

// 主程序处理Employee信息
public void processEmpInform(CpContext cpContext) {

String strUserId;
String strLoginId;
String strRespId;
String strRespApplId;
String strOrgId;
String strBeginDate;
String p_employee_id;
String p_country;
ReqCompletion reqc;
ReqDetails reqd;

Hashtable hashtable = new Hashtable();
collectParameters(cpContext, hashtable);

ReqDetails mReqDetails = cpContext.getReqDetails();
int lp_requestID = mReqDetails.getRequestId();
try
{
collectParameters(cpContext, hashtable);
if ((hashtable.get("USERID") != null & ("".equals(hashtable.get("USERID")) ^ true)))
strUserId = (String)hashtable.get("USERID");
else {
strUserId = String.valueOf(cpContext.getUserId());
}

if ((hashtable.get("LOGINID") != null & ("".equals(hashtable.get("LOGINID")) ^ true)))
{
strLoginId = (String)hashtable.get("LOGINID");
}
else strLoginId = String.valueOf(cpContext.getLoginId());

if ((hashtable.get("RESPID") != null & ("".equals(hashtable.get("RESPID")) ^ true)))
strRespId = (String)hashtable.get("RESPID");
else {
strRespId = String.valueOf(cpContext.getRespId());
}
if ((hashtable.get("RESPAPPLID") != null & ("".equals(hashtable.get("RESPAPPLID")) ^ true)))
strRespApplId = (String)hashtable.get("RESPAPPLID");
else {
strRespApplId = String.valueOf(cpContext.getRespApplId());
}
strOrgId = (String)hashtable.get("ORGID");
strBeginDate = (String)hashtable.get("BEGINDATE");

if ((hashtable.get("EMPLOYEE_ID") != null & ("".equals(hashtable.get("EMPLOYEE_ID")) ^ true)))
p_employee_id = (String)hashtable.get("EMPLOYEE_ID");
else {
p_employee_id = null;
}

if ((hashtable.get("COUNTRY") != null & ("".equals(hashtable.get("COUNTRY")) ^ true)))
p_country = (String)hashtable.get("COUNTRY");
else {
p_country = null;
}

System.out.println("Parameters:" + strUserId + "/" + strLoginId + "/"
+ strRespId + "/" + strRespApplId + "/" + strOrgId + "/" + strBeginDate);
System.out.println("p_employee_id=" + p_employee_id );
System.out.println("p_country=" + p_country );

reqc = cpContext.getReqCompletion();
reqd = cpContext.getReqDetails();

cpContext.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "");
}
catch(Exception ex) {
cpContext.getLogFile().writeln("Concurent Program Exception: " + ex.getMessage(), 1);
cpContext.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "");
ex.printStackTrace();
}
}

//获取并发程序参数
private void collectParameters(CpContext cpcontext, Hashtable hashtable)
{
ParameterList parameterlist = cpcontext.getParameterList();
while (parameterlist.hasMoreElements()) {
NameValueType namevaluetype = parameterlist.nextParameter();
String s = namevaluetype.getName();
String s1 = namevaluetype.getValue();
this.mLogFile.writeln(s + ": " + s1, 3);
if ((s1 != null) && (s1.length() > 0))
hashtable.put(s, s1);
}
}

// 并发程式调用该Java包的接入程序RunProgram
public void runProgram(CpContext cpContext) {
mLogFile = cpContext.getLogFile();
mOutFile = cpContext.getOutFile();

mLogFile.writeln("Start runProgram", 0);

processEmpInform(cpContext);

mLogFile.writeln("END runProgram", 0);

mOutFile.writeln("gavin test outfile");
}

public runEmpConcProg() {
}

public static void main(String[] args) {
System.out.println("main(String[] args");
runEmpConcProg runEmpConcProg = new runEmpConcProg();
}

}



2. 将编译后的class包上传到应用服务器

 OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_OAF_03


3.1 注册可执行程序

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_java包_04

3.2 注册并发程序,并定义参数

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_java_05


OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_OAF_06三、运行测试


1. 调用并发程序,并输入参数

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_oracle_07


2. 查看并程序的Output和Log

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_OAF_08


3. 查看并程序的View Log

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_oracle_09


3. 查看并程序的View Output

OAF_开发系列26_实现OAF中Java类型并发程式开发oracle.apps.fnd.cp.request(案例)_java包_10


Thanks and Regards

参考: 豆丁文库 - http://www.docin.com/p-373932599.html



20150730 Created By BaoXinjian