Vous êtes sur la page 1sur 5

Application Module Extension in OAF

Like the Controller extension, AM extension is also not supported by Oracle. However for some
business needs we have to extend it sometimes.
Root AM Cant be extended where as we can extend Nested AMs only.
This AM can be found under below BC4J package
mahi.oracle.apps.fnd.Employee.server.CreateEmployeeAM

Why we are extending AM:-
This CreateEmployeeAM contains an apply method which subsequently commits the
transaction.
public void apply()
{
getTransaction().commit();
}
Our business need is to capture user name and user id at runtime and insert it into a custom
audit table for audit purpose

Here is Audit Table script --
CREATE TABLE test_tab1
( -- -------------------
-- Data Columns
-- --------------------
user_id VARCHAR(50),
user_name VARCHAR(50),
-- -------------------
-- Who Columns
-- -------------------
last_update_date DATE NOT NULL,
last_updated_by NUMBER NOT NULL,
creation_date DATE NOT NULL,
created_by NUMBER NOT NULL,
last_update_login NUMBER
);

Steps to Extend Application Module (AM)
1. Create a New Application Module (AM)
Right Click on Employee(is nothinh but your .jpr name in jdeveloper) > New > ADF Business
Components > Application Module
Package -- mahi.oracle.apps.fnd.Employee.server
Name -- ExtnCreateEmployeeAM
Extends -- mahi.oracle.apps.fnd.Employee.server.CreateEmployeeAM

Click Next NextNext
Select the Generate Java File(s) Check Box
Click Finish.
Write following code in ExtnCreateEmployeeAMImpl.java
import oracle.apps.fnd.framework.OAException;
import java.sql.PreparedStatement;
import java.sql.Connection;
public class ExtnCreateEmployeeAMImpl extends CreateEmployeeAMImpl
{
....

public void apply()
{
java.sql.Date d = getOADBTransaction().getCurrentDBDate().dateValue();
try
{
Connection conn = getOADBTransaction().getJdbcConnection();
String Query = "insert into test_tab1 values(:1,:2,:3,:4,:5,:6,:7)";
PreparedStatement stmt = conn.prepareStatement(Query);

stmt.setInt(1, getOADBTransaction().getUserId());
stmt.setString(2, getOADBTransaction().getUserName());
stmt.setDate(3, d);
stmt.setInt(4, getOADBTransaction().getUserId());
stmt.setDate(5, d);
stmt.setInt(6, getOADBTransaction().getUserId());
stmt.setInt(7, getOADBTransaction().getUserId());
stmt.execute();
}

catch(Exception exception)
{
throw new OAException("Error in Staffing Query"+exception, OAException.ERROR);
}
super.apply();
}
}

2. Perform AM Substitution
Double Click on Employee.jpx
Business Components Substitutions
Left Side : Base AM. i.e. CreateEmployeeAM
Right Side : Custom AM. i.e. ExtnCreateEmployeeAM
Click on Add

3. After substitution it will modify *.jpx
In our case it will modify Employee.jpx at project location
i.e. -- D:\xxxx\jdevhome\jdev\myclasses

4. Migrate/ Import the modified jpx
Open Command Prompt and go to following location of your project
D:\xxxx\jdevbin\oaext\bin

Use this Import Command to import jpx
Jpximport.bat D:\xxxx\jdevhome\jdev\myclasses\Employee.jpx -username apps -password
guptag123 -dbconnection
"(DESCRIPTION=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(H
OST=test.mahi.com)(PORT=1586)))(CONNECT_DATA=(SID= DEV2)))"
Once you Run the above command you will get a path for your Extension(Copy this path. It
will be used to delete this extension if any error occurs)

5. Congratulation you have successfully finished. Run Your CreateEmployeePG page and
Test Your Work