Monday, May 28, 2012

OAF Return String Array from Procedure

One of the issue we face in OAF is how to get Object from a Procedure. In this post we'll get String Array from Procedure.

Create a VARRAY in PlSql

CREATE OR REPLACE TYPE  STR_ARRAY IS VARRAY(100) OF VARCHAR2(50);

Java code
//setting out parameter
OADBTransaction transaction = getOADBTransaction();
try{
OracleCallableStatement cst = (OracleCallableStatement)transaction.createCallableStatement("begin apps.returnArray(:1,:2);end;",1);

cst.registerOutParameter(2, Types.ARRAY, "APPS.STR_ARRAY");
cst.setString(1,"Hello");
cst.execute();
//returning array type variable
java.sql.Array arr = (java.sql.Array)cst.getObject(2);
//Reading Array
      if (arr != null) {
        String[] strArray = (String[])arr.getArray();
        for (int i = 0; i < strArray.length; i++)
          System.out.println("array at "+i+":"+strArray[i]);
      }
}catch(SQLException ex){
System.out.println(ex);
}

Saturday, May 19, 2012

writeDiagnostics() method of OAF


Hi All, for the first time I am writing any blog. In this I've tried to share my OAF knowledge with all. Kindly bear with me and my language :). Your comments will be highly appreciated to improve it.

For creating logs from OAF java pages  writeDiagnostics() method is used.

writeDiagnostics(Object module ,String message,int logLevel);


module - current module, usually the "this" pointer
messageText - message to be included in the log. Limit 4000 characters.
logLevel - category or type of log message. Valid values are are from OAFwkConstants. (UNEXPECTED,ERROREXCEPTION,EVENT,PROCEDURE,STATEMENT,PERFORMANCE)


In controller this method can be accessed by OAPageContext class object
pageContext.writeDiagnostics(this,"Write Log",OAFwkConstants.STATEMENT) ;

While in AM, VO and EO the method can be accessed by the OADBTransactionImpl class object
OADBTransactionImpl.writeDiagnostics(this,"Log Message",OAFwkConstants.STATEMENT) ;


Set the profile option FND: Debug Log Level at user-level.


The logs written through this method can be viewed by enabling the Diagnostics on the OA Pages.