Monday, 22 May 2017

Generate Report on button event in OAF Page

Steps to call report on button event:
-----------------------------------------
1. we can call report using 'submitRequest' method in 'ConcurrentRequest' class which is in the directory oracle.apps.fnd.cp.request
2. Call custom method in Button event. Here Print is the submit button Id.

    if(pageContext.getParameter("Print")!=null)   // Print button event
    {
      String SupplierName=pageContext.getParameter("SupplierName");  //get the required parameter
      OADBTransaction txn=am.getOADBTransaction();   // create Transaction object
      int req_id=0;
   
         req_id = SubmitPrintReport(SupplierName, txn);  //call Method which invokes the report
pageContext.writeDiagnostics("req_id in Print Event"+req_id,1);
    }

//----'SubmitPrintReport' Method Definition

  public int SubmitPrintReport(String SuppName,  OADBTransaction tx)
   {
     try
      {
         Connection pConncection = tx.getJdbcConnection();  //Create Connection Object

         ConcurrentRequest cr = new ConcurrentRequest(pConncection); //Create Object for ConcurrentRequest Class
        String applnName = "XX"; //Report Application Short Name
 
        String cpName = "XXMPP_SUPP_SECURITY_DEPOSIT"; // Concurrent Program Short Name

        String cpDesc = null;  //Concurrent Program Description
      Vector cpArgs = new Vector(); //Create vector object to add parameters

     cpArgs.addElement(SuppName); //Add parameter to vector
       
   
       try
        {
         cr.addLayout("XXMPP", "XXMPP_SUPP_SECURITY_DEPOSIT", "EN", "", "PDF", null); // addLayout to the report
      }
     catch (Exception e)
         {
        throw OAException.wrapperException(e);
       }
 
         int requestId = cr.submitRequest(applnName, cpName, cpDesc, null, false, cpArgs); //call SubmitRequest method in ConcurrentRequest class to submit the request.
         tx.commit(); //commit the transaction
        return requestId;  //return request Id
     }
       catch (RequestSubmissionException e) {
        OAException oe = new OAException(e.getMessage());
        throw oe;
      }
  }