Anil's Blog is Best Viewed on GOOGLE CHROME

Friday, April 10, 2009

How to return array from Application Module

Controller Code

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import oracle.apps.fnd.framework.OAException; 
  

Serializable paras[] = {employee_id};
Object result[] = new Object[10]; // declaring result of Array Type
result = (Object[])am.invokeMethod("getparameters", paras); // Calling AM Method

String userid = (String)result[0]; // Capturing value from Array
String userName = (String)result[1]; // Capturing value from Array


Application Module Code

public Object[] getparameters(String employeeid)
{
ResultSet resultset = null;
int employee_id = Integer.parseInt(employeeid);

Object result[] = new Object[10];
OADBTransaction oadbtransaction = getOADBTransaction();
Debug.write(oadbtransaction, this, "Employee id is " + employee_id, 1);

try
{
Connection conn = getOADBTransaction().getJdbcConnection();
String query = "sselect user_id, user_name from fnd_user where employee_id=:1";

PreparedStatement stmt = conn.prepareStatement(query);
stmt.setInt(1, employee_id);

for(resultset = stmt.executeQuery(); resultset.next(); 
{

result[0] = resultset.getString("user_id");
Debug.write(oadbtransaction, this, "Project Number is " + result[0], 1);

result[1] = resultset.getString("user_name");
Debug.write(oadbtransaction, this, "Project ClassCode is " + result[1], 1);

}
}

catch(Exception e)

{
Debug.write(oadbtransaction, this, "Exception " + e.getMessage(), 1);
}
return result; // Returning result array to Controller
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.