Goal
How to create a Java Concurrent Program?
Applied To
Oracle eBusiness Suite (EBS) R11/R12
Solution
Most of us write Concurrent Programs using the following Technologies:
- Oracle Reports
- PL/SQL Stored Procedure
- SQL*PLUS
- File handling (More efficient using Java instead of PL/SQL )
- Secure FTP of files between servers
- Networking
- Connecting to other non Oracle Databases
First of all let me assure you that writing a Java Concurrent Program is an easy task, just need some basic skills of Java Programming.
Oracle EBS provides many java classes to support Java Concurrent Programming.The most important and common classes are as follows:
- JavaConcurrentProgram.class
- CpContext.class
- LogFile.class
- OutFile.class
cd JAVA_TOP/oracle/apps
mkdir−pxxcust/cp/request</span></span><br><spanstyle="color:rgb(59,59,59);font−family:′OpenSans′,sans−serif;"><spanstyle="line−height:19.5px;"> cd xxcust/cp/request
pwd</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><strong>....../oracle/apps/xxcust/cp/request</strong></span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">And this is directory where you write your Java Class.</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"><br></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"><strong><em>Structure of your Java Class</em></strong></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Oracle EBS provides an interface Class "<strong>JavaConcurrentProgram</strong>" with abstract method <em>runProgram() </em>which passes the concurrent processing context "CpContext". And you will write you business logic in the runProgram() method. The CpContext will feed log and output file specific information to the runProgram method.The name of the custom class which will implement the JavaConcurrentProgram interface will be used in EBS to register it as a Java concurrent program Executable.</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">The basic structure of the Java Class (to be used as a concurrent program) is given below:</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">//**************Template.java****************************//</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">package oracle.apps.xxcust.cp.request;</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">import oracle.apps.fnd.cp.request.*;</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">public class Template implements JavaConcurrentProgram{</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"> public void runProgram(CpContext ctx){</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"><br></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"> // Write your Business Logic here</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"> </span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"> //This line will signal successful end of the program to the concurrent manager.</span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"> ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL, "Completed");</span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;"> </span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"> }</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">}</span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">//**************End of Template.java********************//</span><br><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><br></span></span><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;"><strong>Example</strong></span></span><br><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif; line-height: 19.5px;">Let us start writing a Java Concurrent program "<strong>Test.java</strong>" to do the following tasks:</span><br><br><ol><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Write text to Output File</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Write Test to Log File</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Get userName of the concurrent Program run requester and write to Output File</span></span></li><li style="padding: 0px; margin: 0px 0px 0.25em;"><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Send success message to the Concurrent Manager</span></span></li></ol><span style="color: rgb(59, 59, 59); font-family: 'Open Sans', sans-serif;"><span style="line-height: 19.5px;">Make sure you are inside " <em><strong>JAVA_TOP/oracle/apps/xxcust/cp/request ” location, and create the following Test.java file.
//********************Test.java***********************/
package oracle.apps.xxadfd.cp.request;
import oracle.apps.fnd.cp.request.;
public class Test implements JavaConcurrentProgram{
public void runProgram(CpContext ctx){
// get reference to Out and Log files
OutFile out = ctx.getOutFile();
LogFile log = ctx.getLogFile();
out.writeln(“This is my Output file ! “);
log.writeln(“This is my Log file”,LogFile.STATEMENT);
//get concurrent program Request Details
ReqDetails rDet = ctx.getReqDetails();
String userName = rDet.getUserInfo().getUserName();
// write username to the Out File
out.writeln(“User Name = “+userName);
// Success message to the Concurrent Manager
ctx.getReqCompletion().setCompletion(ReqCompletion.NORMAL, “Completed”);
}
}
//*******************End of Test.java***********************/
Compile the Java Program Test.java
Make sure you are inside “ JAVATOP/oracle/apps/xxcust/cp/request</strong></span><spanstyle="color:rgb(59,59,59);font−family:′OpenSans′,sans−serif;line−height:19.5px;">"location,andrunthefollowingcommand:</span><br><spanstyle="color:rgb(59,59,59);font−family:′OpenSans′,sans−serif;line−height:19.5px;"> java Test [without extension]
It will generate Test.class file in the current directory i.e. ” $JAVA_TOP/oracle/apps/xxcust/cp/request “.
Program Registration in EBS
Registration of Executable
Executable: TestJavaProg [Any Meaningful Name]
Short Name: T estJavaProg [Any Meaningful short Name]
Application: Application Name [Select (Custom or any other) Application Name]
Execution Method: Java Concurrent Program
Execution File Name: Test [Name of our Java Class Compiled above]
Execution File Patch: oracle.apps.xxadfd.cp.request [Our Java Class Package Name]
Registration of Program
Program: Test Java Prog
Short Name: TESTJAVAPROG
Application: Application Name [Select any Application name]
Executable: TestJavaProg [Name of the Executable registered above]