Wednesday, March 20, 2013

Launching Web Page From Oracle APPS Forms


We already know that OAF page can be launched from Oracle Applications PUI. We can also launch a web page or custom built html from Oracle Applications PUI. Below steps explains you on how to achieve the same.

Note: In 11i, we used to achieve this functionality by creating a FND function of type SSWA plsql function that opens a new window (Kiosk Mode) or SSWA plsql function. But from R12, these types should not be used. So we have to follow below procedure to launch a web page or custom html from Oracle Applications  PUI.

1) Create an .htm file calling the external link, for instance "xxpage.htm". 
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=http://google.com">
</head>
</html>
or a custom html content
<html>
<body> 
<b>Our custom page</b>
</body>
</html>

2) Put this file under $OA_HTML directory. Check the permissions of the file

3) Go to System Administrator responsibility
4) Define a new fnd function as follows
- Enter function name and user function name 
- Function Type : 'JSP Interoperable with OA'
- HTML Call : xxpage.htm  

5) Search for the FND menu where you want to add access to our custom html. Add the newly created function to the menu with a proper name(displays in the navigator).

6) Clear cache and launch the page from Navigator. It's inevitable to clear the cache or else it raises a security exception upon launching the page.

Please let me know if I miss any points. I am happy to add here if it's relevant.

Tuesday, March 19, 2013

Assigning Enter Key to a button on OAF Page


In lot of web pages if we press enter, then it submits the page. Similarly we can also submit the page on pressing Enter key in our Custom OAF pages. If there are more than one button then we can assign Enter key to one of the button. This way the user can submit the page by just pressing on Enter key. Below code gives you an idea on how to assign enter key to a button(page can contain any number of submit buttons). It's obvious that we can only assign Enter key to one button in a page. So when the user presses enter key, the page gets submitted and execute the respective code.

Note: When we implement Search bean in OAF, by default Enter key is assigned to Go button in the search bean. So when the user clicks on enter search gets executed automatically.

import java.util.Hashtable;
import oracle.apps.fnd.framework.webui.OABoundValueEnterOnKeyPress;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    OAPageLayoutBean page = pageContext.getPageLayoutBean();
    Hashtable applyParams = new Hashtable();
    /*There is a button in the page with id 'Apply' and     we are assigning Enter key to this Apply button.*/     applyParams.put ("Apply", "VAL1");     page.setAttributeValue(           OAWebBeanConstants.ON_KEY_PRESS_ATTR,           new OABoundValueEnterOnKeyPress(pageContext,                 "DefaultFormName", // enclosing form name                 applyParams, // request parameters                 false, // client unvalidated                 false)); // server unvalidated } public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)   {     super.processFormRequest(pageContext, webBean);     /*When the user clicks on Enter key then the page     consider it like Apply button is pressed.*/     if (pageContext.getParameter("Apply") != null)     {        --Do your work here         } }

Please let me know if I miss any points. I am happy to add here if it's relevant.

Friday, March 1, 2013

Setting Oracle APPS(E-Biz) context in Stored Procedure(PL/SQL)


What is e-biz context?
While viewing or updating any data in Oracle APPS we need to login. But sometimes developers view/update data from stored procedures (PL/SQL). So in order to get the accurate results, it’s always better to mimic the db that we are accessing from a legitimate FND user with a proper responsibility. So to make sure the db is mimicked, we need to set the e-biz context (Setting FND User and Responsibility) before accessing any data.
Why do we need to set the e-biz context or what are the uses of setting e-biz context?
Most of the time while calling Oracle supplied APIs or custom APIs or even accessing some views, we might need to set the e-biz context. Below are the some of the reasons why we need to set the context.
  • If the calling API is inserting, updating or deleting any table data, then the WHO columns will be populated properly. 
  • Some of the results of the APIs are depending upon the security profile attached to the responsibility. For example in Oracle HRMS, based in the security profile attached to the responsibility, the data displayed will differ. So setting the context will ensue that we get correct data in return. 
  • Selecting data from the secured views like PER_PEOPLE_V and PER_ASSIGNMENTS_V doesn't yield any results if the e-biz context is not set.

What are the mandatory things we need to set as part of e-biz context?
While accessing Oracle APPS, we need to login using FND User and then we need to select a responsibility before accessing any functionality. So just to replicate the same we need to set below values before accessing any data or calling any API.
  • FND User
  • FND Responsibility

How to set the e-biz context from Stored Procedure(PL/SQL)?
Oracle has already provided below API to set the e-biz context in your stored procedure.
FND_GLOBAL.APPS_INITIALIZE(USER_ID IN NUMBER,
                            RESP_ID IN NUMBER,
                            RESP_APPL_ID IN NUMBER,
                            SECURITY_GROUP_ID IN NUMBER DEFAULT 0,
                            SERVER_ID IN NUMBER DEFAULT -1)
How do I know what is my USER_ID and RESP_ID?
You can find USER_ID from FND_USER table if you know your FND user name using below SQL.
SELECT USER_ID FROM FND_USER WHERE USER_NAME = '<Your FND User Name>'
And you can find RESP_ID and RESP_APPL_ID from FND_RESPONSIBILITY table if you know your responsibility Key or name using below SQLs.
SELECT RESPONSIBILITY_ID, APPLICATION_ID FROM FND_RESPONSIBILITY WHERE RESPONSIBILITY_KEY = '<Responsibility Key>'
SELECT RESPONSIBILITY_ID, APPLICATION_ID FROM FND_RESPONSIBILITY_TL WHERE RESPONSIBILITY_NAME = '<Responsibility Name>'
Finally how to set the e-biz context after getting all required values?
FND_GLOBAL.APPS_INITIALIZE is used for initializing the Oracle Applications context before calling any public  API's or custom build APIs in Oracle E-business suite.
Oracle HRMS uses security views to display the data based on the responsibility the user is accessing. If you are using same secured views in your pl/sql, then while calling those APIs it gives wrong values as the e-biz context is not set.
Listed below is a sample call to FND_GLOBAL.APPS_INITIALIZE function. We are passing the mandatory parameters. You can pass other parameters depending on your requirement.
FND_GLOBAL.APPS_INITIALIZE(USER_ID=> <Your User ID>,

                                              RESP_ID  => <Your Responsibility ID>,
                                              RESP_APPL_ID => <Your Responsibility Application ID>);
Then call your your respective API or get the results from secured views. 
Please let me know if I miss any points. I am happy to add here if it's relevant.