Sunday 21 July 2013

Execute parameterized PL SQL procedure from OAF page


import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.server.OADBTransactionImpl;
import oracle.jdbc.OracleCallableStatement;
import java.sql.Types;
import oracle.apps.fnd.framework.OAException;

...
public String dataSumAction(String item1,String item2)
{ OADBTransaction oadbtransaction = (OADBTransaction)getTransaction();
  OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getTransaction();
 String retValues;
 StringBuffer str = new StringBuffer();
 str.append( " BEGIN ");
 str.append( " test_package.data_sum( ");
 str.append( "       item1           => :1, ");
 str.append( "       item2           => :2, ");
 str.append( "       data_sum    => :3  ");
 str.append( "    ); ");
 str.append( " END; ");
 OracleCallableStatement oraclecallablestatement =
  (OracleCallableStatement)oadbtransaction.createCallableStatement(str.toString(), 1);
 try{
  oraclecallablestatement.setInt(1,  Integer.parseInt(item1) );
  oraclecallablestatement.setInt(2,  Integer.parseInt(item2) );
  oraclecallablestatement.registerOutParameter(3, Types.VARCHAR);

  oraclecallablestatement.execute();
                   
  retValues = oraclecallablestatement.getString(3);
 }
 catch(Exception e)
 {
  throw OAException.wrapperException(e);
 }
 return retValues;
}


========================================================================

 public void testStoredProcedure() { 
  
     OADBTransaction txn = getDBTransaction();  
     CallableStatement callableStatement =txn.createCallableStatement("begin mmm_procedure(:1, :2); end;",OADBTransaction.DEFAULT);  
     try 
      {  
       callableStatement.registerOutParameter(2, Types.VARCHAR);  
       callableStatement.setString(1, "mahi");  
       String outParamValue = null;  
       callableStatement.execute();  
       outParamValue = callableStatement.getString(1);  
       callableStatement.close();  
     } 
     catch (SQLException sqle) 
     {  
       callableStatement.close(); 
     } 

   } 

Launch Workflow from OAF Page



Using class oracle.apps.fnd.framework.webui.OANavigation provided by Oracle for Workflow API, you can launch workflow directly from OAF Page.  There are two ways to launch workflow :

1.  Oracle PL/SQL API (wf_engine)
2.  Java Wrappers

we shall launch a workflow from OAF page.

1.  Create a submit button and name the partial event as "launchWF"
2.  Write below java procedure to invoke workflow

import oracle.apps.fnd.framework.webui.OANavigation;

    public void launchWF(OAPageContext pageContext)
    {
        String PItemType = "XXTEST";
        String PProcess = "XXTEST_PROCESS";
        String PItemKey = "SEQUENCE VALUE";  // This can be a random item key generated
   
        OANavigation wf = new OANavigation();
   
        // Now create Workflow Process
        wf.createProcess(pageContext, PItemType, PProcess, PItemKey);
   
        // Set Employee number
        wf.setItemAttrText(pageContext, PItemType, PItemKey,"EMPLOYEE_ID", "101");
   
        // Start Workflow Process
        wf.startProcess(pageContext, PItemType, PProcess, PItemKey);

    }


3.  Call the above procedure in ProcessFormRequest Method

    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    {
    super.processFormRequest(pageContext, webBean);

    if ("launchWF".equals(pageContext.getParameter(EVENT_PARAM)))
      {
        launchWF(pageContext);
      }
    }

Tuesday 16 July 2013

Passing parameters from one OAF page to another OAF Page

//In  processFormRequest()
HashMap xxhashMap = new HashMap(1);
xxhashMap .put("ParamName1", "Value1");

oapagecontext.setForwardURL("MY_FUNCTION", (byte)0, null, xxhashMap , true, "N", (byte)0);

OR
oapagecontext.setForwardURL("OA.jsp?page=/xxelng/oracle/apps/per/hiring/webui/XXConfermationPG",
                                      null,
                                      OAWebBeanConstants.KEEP_MENU_CONTEXT,
                                      null, xxhashMap , true,
                                      OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
                                      OAWebBeanConstants.IGNORE_MESSAGES);

You can then retrieve this parameter in processRequest() via:
oapagecontext.getParameter("ParamName1");

Friday 12 July 2013

Set DFF Segment Required in OA Framework

In processRequest or processFormRequest Use this code.....

OADescriptiveFlexBean oaDFF = (OADescriptiveFlexBean)webBean.findIndexedChildRecursive("FlexField"); // put your dff web bean name here
oaDFF.processFlex(pageContext);


// If you want to set the first Dff (first dff shown in the page) to required then

OAMessageChoiceBean FirstDff = (OAMessageChoiceBean)oaDFF.findIndexedChild("FlexField0");

if (FirstDff != null)
{
FirstDff .setRequired("yes"); // Try to access the value here using getText() or getValue() methods..
}


// If you want to set the  second DFF (second dff shown on page) then

OAMessageChoiceBean SecDffe = (OAMessageChoiceBean)oaDFF.findIndexedChild("FlexField1");

 {
SecDffe .setValue("Default value string"); // Try to access the value here using getText() or getValue() methods..
}

 ========================================================================

OADescriptiveFlexBean oaDFF = (OADescriptiveFlexBean)webBean.findChildRecursive("FlexDFF"); // put your dff web bean name here
oaDFF.processFlex(pageContext);

Enumeration dffElements= null;
dffElements= oaDFF.getChildNames();
while(dffElements.hasMoreElements())
    {
       String DffName = (String)dffElements.nextElement();
       OAWebBean dffbeans=(OAWebBean)oaDFF.findChildRecursive(DffName );
      if(dffbeans != null)
       {                   
           dffbeans.setRequired(OAWebBeanConstants.REQUIRED_NO);
         }

   }