Professional Documents
Culture Documents
Template Program:
}
}
==================End of Template.java===========================
program Logic
Implement the runProgram with your Java Concurrent Program business logic. runProgram() gets the
CpContext . CpContext is a subclass of AOL/J AppsContext which provides the request specific member
classes LogFile to write to request log file, OutFile to write to request output file and ReqCompletion to set
the completion status of the request.
Program Parameters
CpContext uses the AOL/J utility Parameter List to pass the parameters to the Java Concurrent Program.
Please refer AOL/J Parameter list to get the Parameter List name, value pairs. You will be referring
parameter list name as the parameter name and corresponding value as the parameter value in the Java
Concurrent Program. You have to register the parameter names as token name in the register concurrent
program form Parameter screen.
Database Operations
Use getJDBCConnection method to get the connection object for any JDBC operations within program and
release the connection to the AppsContext connection pool. Use CpContext's commit(), rollback() methods
to commit or rollback the transactions in the database. These methods will set the program proffered
rollback segments after commit or rollback segments for the rest of the database transaction in the Java
Concurrent Program.
Setting request Completion Status
Call setCompletion() method of the ReqCompletion object which is a member of CpContext before
returning from your Java Concurrent Program to set the completion status for the program and optional
completion text.
Register executable
Register your Java Concurrent Program class name as execution_file_name and package name in
execution_file_path in register concurrent executables form.
Register you Java Concurrent Program as concurrent program in the register concurrent program form.
Register all the parameters that you want to pass to the program in the parameter screen of this form.
Register the Parameter List names referred in the program as the token names in the parameter screen.
You can test your Java Concurrent Program from OS prompt by using the following syntax:
jre -Ddbcfile=<dbc filename with full path>
[ -Drequest.logfile=<logfile name> ]
[ -Drequest.requestid=<request id> ]
[ -Drequest.outfile=<output file name> ]
[ -Drequest.userid=<user id> ]
[ -Drequest.respapplid=<resp appl id> ]
[ -Drequest.respid=<resp id> ]
[ -Drequest.secgrpid=<sec grp id> ]
[ -Drequest.enabletrace=<Y/N> ]
oracle.apps.fnd.cp.request.Run <program/class name>
[<parameters>]
Example:
jre -Ddbcfile=/d2/fnd/secure/appsnode_appdb.dbc
-Dreqeust.requestid=23453 -Drequest.logfile=./myreq.log
oracle.apps.fnd.cp.request.Run oracle.apps.wip.program.MyProg
"TOKEN1=value1:TOKEN2=value2"
If you don't specify the 'request.logfile' with -D option then the all the log file information will be printed to
the standard output. Specify the 'request.requestid' to rerun already completed request. You can specify
the all the application user specific context values with -D to get the specific user context to the program
when run from the OS prompt. Pass all the parameters if any by using the AOL/J Parameter list syntax.
Sample Program
package oracle.apps.fnd.cp.request;
import java.io.*;
import java.sql.*;
import oracle.apps.fnd.util.*;
public class AvailableProg implements JavaConcurrentProgram
{
String applName;
public AvailableProg()
{
// if no parameter value is specified for
// APPLNAME then use FND as default value
applName = "FND";
}
public void runProgram(CpContext pCpContext)
{
// get the JDBC connection object
Connection mJConn = pCpContext.getJDBCConnection();
// get parameter list object from CpContext
ParameterList lPara = pCpContext.getParameterList();
// get ReqCompletion object from CpContext
ReqCompletion lRC = pCpContext.getReqCompletion();
String lQuery =
" select substr(user_concurrent_program_name,1,70) , " +
" decode(enabled_flag,'Y','Enabled','N','Disabled') " +
" from fnd_concurrent_programs_vl cp, fnd_application_vl a " +
" where cp.application_id
= a.application_id " +
" and a.application_short_name = ? " +
" order by 1 " ;
// check for the APPLNAME parameter token name and if it there get
// value and use it as the application short name in the query
while (lPara.hasMoreElements())
{
NameValueType aNVT = lPara.nextParameter();
if ( aNVT.getName().equals("APPLNAME") )
applName = aNVT.getValue();
}
try
{
" + lRs.getString(2) );
}
lLF.writeln("Generated Programs for Application : " + applName,
LogFile.STATEMENT);
lStmt.close();
lRC.setCompletion(ReqCompletion.NORMAL, "Request Completed Normal");
}
catch (SQLException e)
{
lRC.setCompletion(ReqCompletion.ERROR, e.toString());
}
finally
{
pCpContext.releaseJDBCConnection();
}
}
NOTE: If you're creating a BC4J Application Module in a concurrent program and are passing CpContext
object to it, you should NOT call releaseJDBCConnection() on CpContext while it is still in use by the BC4J
AM. You should clean up after the AM properly by calling am.remove().
Some Q & A