Friday, June 24, 2016

CO Extension in OAF

CO Extension in OAF
Now we are going to extend a standard oaf page.
Here we take Appraisal page from Employee self service Responsibility.











Requirement:Extend the oaf page to add Validation in ‘Appraisal Date’ field to avoid entering future date in this field.












Click 'About this Page' to view the fields and all the information related to this page.



Identify which CO to be extended.














Generally we can download the .class file for this page from server, sometime it gives  dependency error.
To avoid this error we can create our own(dummy) java file as similar to the standard java file as shown below. Package location should be same as the standard file location.















Add ProcessRequest, ProcessFormRequest and other imports in this java file.
  package oracle.apps.per.selfservice.appraisals.webui;
  import oracle.apps.fnd.common.VersionInfo;
  import oracle.apps.fnd.framework.webui.OAControllerImpl;
  import oracle.apps.fnd.framework.webui.OAPageContext;
  import oracle.apps.fnd.framework.webui.beans.OAWebBean;
  public class EmpMyAppraisalsCompletedCO 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);
        }

    }
     Run the java file to get the .class files in myclasses location.



     
     


















Now create another java class file which extends our dummy standard class file as shown below.
Package path should be similar to standard path but it should starts with our custom name.
   
xxappraisals.oracle.apps.per.selfservice.appraisals.webui















Add ProcessRequest, ProcessFormRequest and other required java imports.
public class xxEmpMyAppraisalsCompletedCO9 extends EmpMyAppraisalsCompletedCO
Here CO Extented java file should extend our dummy java file.















Download the .xml file of standard oaf page from mds location.





       
























Get required field names from xml file.



     











Using the field name and event name we can write date validation.

package xxappraisals.oracle.apps.per.selfservice.appraisals.webui;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;
import oracle.apps.per.selfservice.appraisals.webui.EmpMyAppraisalsCompletedCO;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

  public class xxEmpMyAppraisalsCompletedCO9 extends EmpMyAppraisalsCompletedCO {
    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);
        //throw new OAException("Appraisal Date Validation",  OAException.INFORMATION);
    }

    /**
     * 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) {
        //if(pageContext.getParameter("PMPGo")!=null) PMPGo 
         OAQueryBean queryBean = (OAQueryBean) webBean;
         queryBean.getCurrentSearchPanel(); 
        String currentPanel = queryBean.getCurrentSearchPanel();
        if (SEARCH.equals(currentPanel) && queryBean.getGoButtonName() != null && pageContext.getParameter("PMPGo")==null)
           {
            pageContext.writeDiagnostics(pageContext,  "Go event : " + pageContext.getParameter("event").toString(),  11);
            String appraisaldate = pageContext.getParameter("ApprDate");
            pageContext.writeDiagnostics(pageContext,  "Appraisal Date : " + appraisaldate,  11);
            try {
                SimpleDateFormat formatter2 =  new SimpleDateFormat("dd-MMM-yyyy");
                Date dob = formatter2.parse(appraisaldate);
                pageContext.writeDiagnostics(pageContext,  "Appraisal Date formated : " + dob, 11);
                java.util.Date date = new java.util.Date();
                String dateStr = formatter2.format(date);
                Date current_date = formatter2.parse(dateStr);
                if (dob.compareTo(current_date) > 0) {
                    throw new OAException("Appraisal Date should be Earlier than Current Date", OAException.ERROR);
                }
            } catch (ParseException e) {
                pageContext.writeDiagnostics(pageContext,  "Appraisal Date issue : " +  appraisaldate, 11);           }
        }
          
             
        super.processFormRequest(pageContext, webBean);
    }
  }















Run the java file to get the .class file in myclasses location.



  











.class Files are available in myclasses location

















Move the class file folder to JAVA_TOP location.













Now we have completed our coding part for validation in CO extension, now we have to personalize to make effect in standard page.
The page may have more than one CO attached, so identify the correct region and CO and click Personalize button.













Provide the path of your custom folder in JAVA_TOP along with your CO name.
xxappraisals.oracle.apps.per.selfservice.appraisals.webui.xxEmpMyAppraisalsCompletedCO.
We can personalize at various levels like Function level, Site level, Organization level, Responsibility level.
Here we are personalizing in Function level.













Return back from the personalization page and check whether the validation works. 
Here our validation works as expected with proper error message.



 








We have Successfully Extended the Standard page and added validation.

Sunday, February 28, 2016

Oracle Alerts

What are Oracle Alerts?
Oracle Alerts monitor your Database information and notify you when the condition that you have specified is found. You can define Alerts in any Oracle application or custom Oracle application.

Alerts are 2 types of alerts in oracle apps.
1. Periodic Alerts
2. Event based Alerts.


Event Based Alerts: 
These Alerts are fired/triggered based on some change in data in the database.

Periodic Alert:

These Alerts are triggered hourly,daily, weekly, monthly or yearly based on your input.


What can be done with Alerts?
  • You can send notifications
  • You can send log files as attachments to notifications
  • You can call PL/SQL stored procedures.
  • You can send approval emails and get the results.
  • Print some content dynamically

Navigation:
  • Go to “Alert Manager” Responsibility
  • Alert >> Define











2. Define Application Name, Alert name and then select periodic alert tab.
3. And Define Frequency of the alert, Start time, End time, and place your query in query area.
4. Click Verify button to verify the sql query and Run button to run locally to check whether it is working or not.



5. Click Action button and provide action name.















6. Click Action Dtails and provide the email id to whom it should send and subject, body.















7. Save you changes and check the alert.