Sunday, December 30, 2018

Oracle OAF : Calling PLSQL Procedure From OAF

Controller
========================================

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
          OAApplicationModule am = pageContext.getApplicationModule(webBean);
          if (pageContext.getParameter("item3") != null)       
           {         
                Serializable[] ParamAddValues = { pageContext.getParameter("item1"),
   pageContext.getParameter("item2")};
                             
            String retSumValue = (String)am.invokeMethod("AddNumber", ParamAddValues);
            String message = "Sum:  " + retSumValue;                   
            throw new OAException(message, OAException.INFORMATION);
            }
  }
 

Application Module
========================================

import java.sql.CallableStatement;
import java.sql.SQLException;
import oracle.apps.fnd.framework.OAException; 
 
public String AddNumber(String item1,String item2)
    {
    OADBTransaction oadbtransaction = (OADBTransaction)getTransaction();
        OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getTransaction();
        String retValues;
        StringBuffer str = "Begin proc_in_oaf.addition(:1,:2,:3); End;";   
        OracleCallableStatement oraclecallablestatement =
(OracleCallableStatement)oadbtransaction.createCallableStatement(str.toString(), 1);
try{
oraclecallablestatement.setFloat(1,  Float.parseFloat(item1)  );
oraclecallablestatement.setFloat(2,  Float.parseFloat(item2) );
oraclecallablestatement.registerOutParameter(3, Types.VARCHAR);
oraclecallablestatement.execute();                     
retValues = oraclecallablestatement.getString(3);
}
catch(Exception e) {throw OAException.wrapperException(e);}
     return retValues;
    }

No comments:

Post a Comment