Vous êtes sur la page 1sur 10

Creating a Java based Concurrent Program in Oracle Apps.

Steps to create a Java Concurrent Program Overview
Create a Java file containing the Business logic and Then compile it to
generate the class file through Jdeveloper.

Transfer this class file to a location in the server through WINSCP,

CoreFTP or generic file-transfer-protocols.

Now, Login to Oracle apps.

Go to Responsibility: Application Developer > Program > Executable

Create an Executable Program of Java Concurrent Program type and

provide the full path of where the Java Class has been placed in the
server, along with the File Name, .class extension is not required.

Now create a Concurrent Program invoking this Executable. Save.

Add this concurrent program to a responsibility.

Go to the specified responsibility > Requests and Run the concurrent

program that has just been created.

Step by Step Explaination: Creating the Java Class and its properties

Open Jdeveloper, Create a new Generic Application and specify your

custom folder/package
Under which the java class file would be stored, in this case, the package
is ktpl.oracle.apps.per.expense. Once the hierarchy is
created, right click on the latest folder, e.g., expense, and click on
New, goto Java tab and click on Java class.
This will create a new class with the name provided, and under that

Why Java Concurrent Program?

Now let us consider a scenario where we have to submit a report from
Oracle Apps. How will we achieve that?
Simple. We will create a concurrent program that will take an RDF, or
XML as source input. Create a Data definition with the same name of the
Conc. Program, then a template. And run the program.
Now consider, this report is the expense details of a particular
employee, in that case? Simple. We will pass the employee number and
we are done.
Now suppose, we have to do the same for all the employees, say 500
and mail the reports to the respective employees. Well have to run this
concurrent program 500 times, explicitly? Solution? Simple. Java
Concurrent Program comes into the picture. Where we would loop
through all the employees and generate the report 499 times more but
submitting the Java Concurrent Program through Oracle Apps just once.
Lets us get deeper into this on how to achieve this using a Java
Concurrent Program.
We would be concentrating on the structure of the Java class that would
call the Concurrent Program and assuming that we already have a report
in place which will be invoked and generated in turn.

Java Class Structure

Now the class is created. But it is a normal Java file.

To make this Java class file accessible and executable from Oracle apps,
you have to implement the JavaConcurrentProgram interface.
Add the code implements JavaConcurrentProgram to your class
definition. The complier would ask you to import the package:
oracle.apps.fnd.cp.request, press Alt+Enter, Jdev will take care of the
imports automatically.
JavaConcurrentProgram is an interface and as a result it has an abstract
method: void runProgram(oracle.apps.fnd.cp.request.CpContext p1), so
well have to override this particular method, i.e., we have to re-write
the method in our java class with our business logic while passing the
exact same parameters that are defined in the method, in this case, that
parameter is of type CpContext. CpContext can be compared to
something we know as ApplicationContext, from a laymans view it can
be said, The CpContext object gives you access a whole variety of useful
things, including the database connection, the Log and Output files and
all the parameter values from the Submit Request screen. However, the
some of the information about the Concurrent Program can be a little
awkward to access. Once this is done, save your file and Rebuild.

The APPLCSF and APPLOUT can be seen as environment variables so

the above line we are just setting the output directory for the
concurrent program.
As mentioned previously, we are overriding the the runProgram method
here. All our business logic will reside here or we can call methods from
other custom java classes where logic is implemented.

Here we are creating a connection object. This is necessary if you want

to execute any queries inside the java class.

The above shown query, we are executing a custom view to find out the
invoices which have no attachments.
The result set object returns the total no. of invoices (to be precise,
result set returns the total no. of rows) that satisfies the above criteria.
So if we are trying to submit a concurrent program for each invoice, we
have put the program call in a loop. This is where the resultSet object
comes into the picture.

This means as long as there are values in the resultSet object the loop
will continue.
In the following variables, shown above, we set the same variables
needed to publish an xml publisher report: Application name,
concurrent program short name, layout language, country code, output
format and country name, respectively.

A vector is nothing but a dynamic arrayList in a sense, and we are using a

vector type object to pass the invoice number. More than one params
can be passed but here we need only one.
Well this is the final part:

We are first adding the layout (template) by calling the method

addLayout from the ConcurrentRequest class.
And then, we are executing the concurrent program by invoking the
method submitRequest as seen. Both the methods call PL/PSQL
procedures in turn, which of course we do not need to worry.

Now as our java code is ready, we need to define this Java concurrent
program from Oracle Apps Assign to a responsibility and make sure it

In the executable, we provide the regular details like name, short name,
application name, the execution method: Java Cocurrent Program
The execution file name is the name of the class file we just created.
Execution File path, is the path where the file has been placed in the
server, to be specific, under $JAVA_TOP.

Based on the executable just created, create a concurrent program.

The most important part to be noted here is the Options where we are
putting something like: -classpath
This is nothing but we are telling the program to find all the libraries and jars in
the above. The location is custom, it can be anywhere in the server. Well, one
thing, the no. of characters to be filled in this box is limited. So, like always for
multiple, long and broad named jar files * works. Like in this case we have
kept our libraries and jars under /usr/tmp.
We wont be passing any params as we are deriving the
invoice_numbers programmatically inside our java class.

We attach this report to a responsibility and run the program:

So first the concurrent program gets submitted and which in turn submits
another report program and params being derive programmatically.