OAF How to invoke concurrent program with parameters on button event

/*===========================================================================+
 |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package cnsi.oracle.apps.fnd.webui;

import java.util.Vector;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.cp.request.ConcurrentRequest;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.server.OADBTransaction;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

/**
 * Controller for ...
 */
public class InvokeConcurrentProgCO extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    String eventNameStr= pageContext.getParameter(EVENT_PARAM);
    
    if(eventNameStr!=null && "invoke_event".equals(eventNameStr))
      {
       
       int requestID = submitCPRequest(pageContext,webBean);
       
       throw new OAException("COncurrent Request ID-->"+requestID);
      
      }
    
  }
  
    public int submitCPRequest(OAPageContext pageContext, OAWebBean webBean)
    {

         OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
           try {

           OADBTransaction tx = (OADBTransaction)am.getOADBTransaction();
           java.sql.Connection pConncection = tx.getJdbcConnection();
           ConcurrentRequest cr = new ConcurrentRequest(pConncection);

           String applnName = "FND"; //Application that contains the concurrent program
           String cpName = "XXMI_INV_REPORT_NEW"; //Concurrent program name
           String cpDesc = "Invoking From OAF"; // concurrent Program description

           // Pass the Arguments using vector
           // Here i have added my parameter headerId to the vector and passed the vector to the concurrent program

            String headerIDStr ="123";
            //Number  invoiceIDNum = new Number(123);

           Vector cpArgs = new Vector(); 
           cpArgs.addElement(headerIDStr); 
    //           cpArgs.addElement("Test1"); 
    //           cpArgs.addElement("Test2"); 
               

           // Calling the Concurrent Program

           int requestId = cr.submitRequest(applnName, cpName, cpDesc, null, false, cpArgs);
           tx.commit();

           return requestId;

           } catch (Exception e) {
            e.printStackTrace();
            throw new OAException(e.getMessage());

           }
           

    }

}

Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Category: OAF