Java Concurrent Program in Oracle Apps R12
We will explore Java Concurrent Program in Oracle Apps R12.
We can do a lot of things with Java and lots of coding and sample scenarios are available on Google.
If we want to use those kinds of java programming, we can use OAF or we can use the Java Concurrent Program in Oracle Apps.
Let’s assume if you want to read the excel file(with multiple sheets) and store the data into Oracle custom tables.
In Java, we can achieve this functionality with a bit easy steps or by using predefined jar files.
In PLSQL also we can achieve but its a bit complicated.
We will discuss how to read/write from excel file using Java and register as a Java Concurrent Program in future posts.
Now we will create sample java program and we will deploy the program in Oracle Server and execute as concurrent program.
1. Create Java Program in jDeveloper.
2. Move the Java program to the Oracle Server
3. Compile the Java Program(Generate the class file)
4. Register as a Concurrent program
5. Execute the concurrent program and Verify the output
Create Java Program in jDeveloper
Install jDeveloper, have mentioned how to install and run sample OAF page in this blog.
Flow the below steps to Create Java class in jDeveloper.
Project Name: JavaConcurrentProgram
Directory Name: LocalDirectory
Default Package: Generally we store Java files into $JAVA_TOP path. Since its custom we have create our own custom path in $JAVA_TOP based on the application shot name.
Here we are using cus.oracle.apps.cus.javaconc (We will copy our Java files in this path in Oracle Server)
We have provide DBC file path, we can get this file from Oracle Server at $FND_SECURE path.
This is the database configuration file.
Now create new JavaClass.
Pakcage: We have to mention our path(Java file path)
package cus.oracle.apps.cus.javaconc; 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; -- We have to implement the JavaConcurrentProgram public class JavaConcurrentProg implements JavaConcurrentProgram{ public JavaConcurrentProg() { } OutFile out; -- Output file LogFile log; -- Log File -- We have to write our code in runProgram public void runProgram(CpContext cpContext) { out = cpContext.getOutFile(); log = cpContext.getLogFile(); log.writeln("This is the first program", 0); -- Writing messages in Log File. What ever we write it will display in log file. out.writeln("This is the first Java Concurrent Program"); -- Writing messages in output File. What ever we write it will display in output file. -- We have to either complete or error or warning the request. This is a mandatory step. cpContext.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "Completed."); // To make concurrent program Normal //cpContext.getReqCompletion().setCompletion(ReqCompletion.ERROR, "Completed."); -- To make concurrent program Error //cpContext.getReqCompletion().setCompletion(ReqCompletion.WARNING, "Completed."); -- To make concurrent program Warning } }
Move the Java program to the Oracle Server
Using WinSCP tool we can migrate the above java program into $JAVA_TOP/cus/oracle/apps/cus/javaconc path.
Compile the Java Program(Generate the class file)
We have to compile the java program in Oracle server. We can use the below command.
javac -cp .:/u01/data_app/apps/apps_st/comn/java/classes JavaConcurrentProg.java
We have to use the class path(cp) of $JAVA_TOP() in order to compile the Java program.
Register as a Concurrent program
Execution File Path: Where we placed the java file $JAVA_TOP
Execution Method: Java Concurrent Program
Options: -classpath /u01/data_app/apps/apps_st/comn/java/classes:/u01/data_app/apps/apps_st/comn/java/lib/appsborg.zip
Execute the concurrent program and Verify the output