Friday, 3 March 2017

Create A Custom region in OAF Page (OAF EXTENSION, CUSTOMIZATION, PERSONALIZATION)


This post will help u create a custom region in OAF Page. In this post I will include all the steps to create a custom region so that the customization is done easily. So let us start by understanding the requirement.
Requirement: We have a OAF page of AP Invoice approval notification. In this page I want to include a region showing the TDS details applied to the invoice.
The details include:
  • Section type
  • Name
  • Tax rate
  • Tax amount 
Pre - Requisite: JDeveloper (u can download it from oracle site, Patch number: 8431482).                         SSH (or any file transfer tool like winzcp etc.).
Steps:
1        Download the patch & install the JDeveloper in your system.
2        Download the DBC file from the server using FTP. You can get the path by navigating Oracle apps ERP home page --> about page --> Java System Properties.                                          path: /data02/CLONE/apps/fs1/inst/apps/CLONE_idev/appl/fnd/12.0.0/secure/CLONE.dbc
3        Copy & paste the dbc file in your system at the path D:\JDeveloper\jdevhome\jdev\dbc_files\secure.
4        Set the environment variable. path My Computer --> properties --> advance settings --> set the path D:\JDeveloper\jdevhome\jdev.
5        Open the JDeveloper.
6        Create a Database connection: Go to Connection Navigator & then right click on Database and select New Database Connection. Then click on next button. In the next window give the DB connection a name and then click on next button. In the next window write the username & password like apps/apps. In the next window specify the host & SID and then click next and then press finish button.

7        Create a New OA Workspace & New OA Project: Go to Application navigator, right click on the Applications and select New OA Workspace. In next window specify the Workspace Name and ensure “Add a new Project” checkbox is ticked and then click on Ok button. In the next window mention the Project name, let the directory remain as it is but in default package field keep the path same as that on the server Eg. xxflx.oracle.apps.ap.invoice.request.negotiation.webui  (Only xxflx can be changed and rest is same as that of the server and it should be remained as it is.). In the next window select the database connection which we created earlier and click on next button. In the next window select the DBC file which we have downloaded it from the server. And fill the details as mentioned below:
    a.       User Name : sysadmin
b.      Password : sysadmin
c.       Application short name : AP

d.      Responsibility key : XX_AP_INVOICE_USER (system administrator --> security --> Responsibility --> Define.)

8        Create Custom VO (View Object): Right click and select New from the list and then select Business Tier --> ADF Business Components--> View Object and click on Ok button. In the next window give the path in the package field as xxflx.oracle.apps.ap.invoice.request.negotiation.server and give the VO a name and click on next --> next --> next --> next. In the SQL Statement window paste the query which is mentioned below and click on ok button then finish button. Please see the images below for better understanding.
Query:
select b.SECTION_TYPE TDS_SECTION,
a.TAX_NAME,
a.TAX_RATE,
ROUND(sum(A.TAX_RATE/100*c.AMOUNT)) BASE_TAX_AMOUNT,
a.tax_id,
b.invoice_id
from jai_cmn_taxes_all a,
JAI_AP_TDS_INV_TAXES b,
ap_invoice_distributions_all c
where b.invoice_distribution_id = c.INVOICE_DISTRIBUTION_ID and
a.TAX_ID = b.ACTUAL_TAX_ID and
b.invoice_id = nvl(:1,b.invoice_id)
group by
b.section_type,
a.tax_name,
a.tax_rate,
a.tax_id,
b.invoice_id
ORDER BY A.TAX_ID



9        Create a custom AM: Right click and select New from the list. In the next window select Business Tier -->ADF Business Components -->Application Module and select Ok button. In the next window select the package path as xxflx.oracle.apps.ap.invoice.request.negotiation.server and give the application module a name and click next button. In the next window move the VO from “Available View Objects” to “Data Model --> App Module” and click on next & then finish button.


10    Create custom region: Right click and select New from the list. Select Web Tier --> OA Components -->Region and click on Ok button. In the next window give the region a name and select style as stackLayout and click on Ok button. Now click on the region and set its property in BC4J --> AM Definition as the custom AM.



               
11    Create table region inside the stackLayout region: Right click on the Region inside the Structure region below the Application navigator and select New --> Region using wizard. In the opened window select the custom AM and click on the VO in the available View Objects. In the next window give the region a name and then select the style as Table and click next button. In the next window move all the available objects to select View objects which u want to display and then click on next & then finish button.



12    Create a controller: Right click on the region and select the Set new Controller.  In the next window give the controller a name and in package field remove single webui and click on Ok button.



13    Paste the below mentioned code into the respective files:
a)      xxfiltdssectionCO.java
/*===========================================================================+
 |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package xxflx.oracle.apps.ap.invoice.request.negotiation.webui;

import java.sql.Types;

import java.util.Enumeration;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import java.io.Serializable;


/**
 * Controller for ...
 */
public class xxfiltdssectionCO 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);
        String  Invoice_id = (String)pageContext.getParameter("InvoiceId");
       OAApplicationModule am = pageContext.getApplicationModule(webBean);
       Serializable[] parameters = {
                            Invoice_id
                              };
       am.invokeMethod("initDetails",parameters);  
       String parameterName;
       Enumeration e = pageContext.getParameterNames();
       while(e.hasMoreElements())
       {
               parameterName = (String)e.nextElement();
               if(pageContext.isLoggingEnabled(2)){
               pageContext.writeDiagnostics(this, "Parameter Name=>" + parameterName + " Parameter Value=> " + pageContext.getParameter(parameterName),2);
               }

       }     
       if(pageContext.isLoggingEnabled(2)){
             pageContext.writeDiagnostics(this, "XXFIL End of debug", 2);
       }
 
  }

  /**
   * 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);
  }

}

b)      xxfiltdssectionAMImpl.java
package xxflx.oracle.apps.ap.invoice.request.negotiation.server;

import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class xxfiltdssectionAMImpl extends OAApplicationModuleImpl {
    /**This is the default constructor (do not remove)
     */
    public xxfiltdssectionAMImpl() {
    }
    public void initDetails (String Invoice_id) {
       
        xxfiltdssectionVOImpl vo= getxxfiltdssectionVO1();
        vo.initQuery(Invoice_id);
    }
    /**Container's getter for xxfiltdssectionVO1
     */
    public xxfiltdssectionVOImpl getxxfiltdssectionVO1() {
        return (xxfiltdssectionVOImpl)findViewObject("xxfiltdssectionVO1");
    }
    /**Sample main for debugging Business Components code using the tester.
     */
    public static void main(String[] args) {
        launchTester("xxflx.oracle.apps.ap.invoice.request.negotiation.server", /* package name */
      "xxfiltdssectionAMLocal" /* Configuration Name */);
    }
}
c)       xxfiltdssectionVOImpl.java
package xxflx.oracle.apps.ap.invoice.request.negotiation.server;

import oracle.apps.fnd.framework.server.OAViewObjectImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class xxfiltdssectionVOImpl extends OAViewObjectImpl {
    /**This is the default constructor (do not remove)
     */
    public xxfiltdssectionVOImpl() {
    }
   
   public void initQuery(String id)
     {
             if ((id != null) )
             {
            
             setWhereClauseParams(null); // Always reset
             setWhereClauseParam(0, id);
             executeQuery();  
            
             }
     }
}
14    Migrate the code to the server. Move the complete directory xxflx to the server on path : /data01/CLONE/apps/fs1/EBSapps/comn/java/classes ($JAVA_TOP). Then compile all the java files on the server using cmd eg. javac xxfiltdssectionAMImpl.java.
Import the Region using the command mentioned below:
java  oracle.jrad.tools.xml.importer.XMLImporter $JAVA_TOP/xxflx/oracle/apps/ap/invoice/request/negotiation/webui/xxfiltdssectionRN.xml -username apps -password apps456 -dbconnection "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=xxx.xxxx.com)(PORT=xxxx)))(CONNECT_DATA=(SERVICE_NAME=xxx)))" -rootdir $JAVA_TOP

Now bounce the apache and OA core using the cmd below:
·         adcgnjar
·         cd $ADMIN_SCRIPTS_HOME
·         ./adapcctl.sh stop
·         ./adapcctl.sh start 
·         ./admanagedsrvctl.sh stop oacore_server1
·         ./admanagedsrvctl.sh start oacore_server1

15    Add the region using Personalization. Open the Application and Enable the OAF Personalization by setting the profile “FND: Personalization Region Link Enabled” & “Personalize Self-Service Defn”to Yes. Now Open the AP Invoice Notification Page.  Here we want a region below Invoice Lines so click on link Personalize Stack Layout and then in the next window in the personalization structure select “Complete View”. In the Structure there is “Create Item” icon, click on it and then in the next window select the following properties
·         Level:  Site
·         Item Style: stackLayout
·         Id: TdsSection
·         Extends: /xxflx/oracle/apps/ap/invoice/request/negotiation/webui/xxfiltdssectionRN
                And click on apply button.

And that’s it you are finished with the adding of custom region in the OAF Page. Go and check the OAF Page.    












No comments:

Post a Comment