Running a Java Concurrent Program in Oracle Apps
Oracle provides an interface with a method called runProgram(CpContext), which is
where you need to embed your code. This method is called from a main thread after
program start and initialization. The CpContext passed as a parameter to this
method and hence to your code provides access to many of the variables needed
to complete your solution, like .log and .out files and a JDBC connection to the
database where this program will be run.
To be able to run your program, you need to define a Concurrent Executable and
Concurrent Program and provide some indication of where your code resides.
Assuming you already know how to define a Program and Executable, I will cover the
registration process for the path to your program.
Write the below Code in your favourite Editor
package oracle.apps.tech; //You will get the class file in the specified location
import oracle.apps.fnd.common.Context;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.cp.request.CpContext;
import oracle.apps.fnd.cp.request.*;
import oracle.apps.fnd.util.*;
import java.sql.*;
public class TestJCP implements JavaConcurrentProgram {
OutFile out;
LogFile log;
public void runProgram(CpContext ctx) {
Connection conn = null;
try {
out = ctx.getOutFile();
log = ctx.getLogFile();
ParameterList parms = ctx.getParameterList();
conn = ctx.getJDBCConnection();
int userId = ctx.getReqDetails().getUserInfo().getUserId();
// insert your code here
log.write("Hello World", 0); //WRITES IN LOG
out.write("Hello World"); //GIVES THE OUTPUT
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "Completed.");
} catch (Exception e) {
out.writeln("Exception during PPS Reconciliation...\n" + e.getMessage());
ctx.getReqCompletion().setCompletion(ReqCompletion.ERROR, "Completed.");
} finally {
try { conn.rollback(); } catch (SQLException e) {}
}
Now open the tool to connect with oracle Server
The Tool I use is Putty
Login and insert the following command to compile the program
javac d $JAVA_TOP TestJCP.java
The above command compiles and gives a class file to $JAVA_TOP
Now your output class will be in the available in the below path $JAVA_TOP/oracle/apps/tech
The above path name comes due to package path in the Java program
Now the Compiled program has to be executed.
We can execute the program by creating a executable in oracle apps
Go to Application Developer -> Concurrent -> Executable
Go to Application Developer -> Concurrent -> Program
Now go to your responsibility and create a request
Get Your request Group from the Responsibility and attach the concurrent program
Now go to your Responsibility and now Submit the Request
Now Click the View Log and View output.