Sunday 7 July 2013

Returning array from am

How to return array from Application Module

Controller Code

  1. import java.sql.ResultSet;  
  2. import java.sql.SQLException;  
  3. import java.sql.Connection;  
  4. import java.sql.PreparedStatement;  
  5. import oracle.apps.fnd.framework.OAException;   
  6.     
  7.   
  8. Serializable paras[] = {employee_id};  
  9. Object result[] = new Object[10]; // declaring result of Array Type  
  10. result = (Object[])am.invokeMethod("getparameters", paras); // Calling AM Method  
  11.   
  12. String userid = (String)result[0]; // Capturing value from Array  
  13. String userName = (String)result[1]; // Capturing value from Array  

Application Module Code

  1. public Object[] getparameters(String employeeid)  
  2. {  
  3. ResultSet resultset = null;  
  4. int employee_id = Integer.parseInt(employeeid);  
  5.   
  6. Object result[] = new Object[10];  
  7. OADBTransaction oadbtransaction = getOADBTransaction();  
  8. Debug.write(oadbtransaction, this"Employee id is " + employee_id, 1);  
  9.   
  10. try  
  11. {  
  12. Connection conn = getOADBTransaction().getJdbcConnection();  
  13. String query = "sselect user_id, user_name from fnd_user where employee_id=:1";  
  14.   
  15. PreparedStatement stmt = conn.prepareStatement(query);  
  16. stmt.setInt(1, employee_id);  
  17.   
  18. for(resultset = stmt.executeQuery(); resultset.next();   
  19. {  
  20.   
  21. result[0] = resultset.getString("user_id");  
  22. Debug.write(oadbtransaction, this"Project Number is " + result[0], 1);  
  23.   
  24. result[1] = resultset.getString("user_name");  
  25. Debug.write(oadbtransaction, this"Project ClassCode is " + result[1], 1);  
  26.   
  27. }  
  28. }  
  29.   
  30. catch(Exception e)  
  31.   
  32. {  
  33. Debug.write(oadbtransaction, this"Exception " + e.getMessage(), 1);  
  34. }  
  35. return result; // Returning result array to Controller  
  36. }  

No comments:

Post a Comment