Monday, 8 June 2015

Oracle Apps: fnd_profile.value('ORG_ID') returns null

FND_PROFILE.value('ORG_ID') will return value only if the 'MO: Operating Unit' is set for the responsibility used.

If you need to get the ORG_ID in a MOAC enabled instance, 
use FND_GLOBAL.org_id or MO_GLOBAL.get_current_org_id instead.

From the reference given below:

"For MOAC-enabled instances, FND_PROFILE.VALUE('ORG_ID') will no longer convey the correct org context for a given session.  The customer *has to change* all FND_PROFILE.VALUE('ORG_ID') calls to either use MO_GLOBAL.get_current_org_id() (which is highly recommended by the MO Team or FND_GLOBAL.ORG_ID().  Do NOT use FND_PROFILE.VALUE('ORG_ID') for any MOAC-enabled instances."


To get the org_id in OA Framework code:

use appModule.getOADBTransaction().getOrgId() or pageContext.getOrgId()
instead of pageContext.getProfile("ORG_ID").

Reference: 
After Patch 8222387 Why Does Fnd_profile.Value('Org_id') Return No Value (Doc ID 784279.1)
Conc Programs Using Parameter Fnd_profile.Value(Org_id) Get Apps-Fnd-01436 (Doc ID 784489.1)


Feel free to point out if anything is missing/wrong in this blog.

Saturday, 6 June 2015

OAF: How to create a PVO and use that for Spel Binding in Oracle Application Framework

In this post I will give an example to show how to create a PVO ("Application Properties" View Object) and use the attributes to change the properties of the bean dynamically. I will give same method to set the PVO Attribute values. This method can be used when there is only 1 attribute to be set or if there are multiple attributes.

Scenario:
I have created 2 tables in the page (say Table1 and Table2). I need to show Table1 when the page loads and hide Table2. Based on some conditions, I will need to change the Tables in screen dynamically. 


  • Create a PVO with 2 attributes (1 for each table). Set the value of the attribute appropirately.
  • Use Spel binding to associate the attribute to the table. Refer: OAF: Spel Binding

Create PVO with 2 attributes (I have created one additional Id column also, which can be set as the Key Attribute). Make sure that you set the Updatable property to 'Always'.





Add this VO to the Application Module and then add the below methods in the AMImpl.

 import oracle.jbo.domain.Number;  
 public void intializeXXCustomPVO()  
 {  
      OAViewObjectImpl xxCustomPVO = getXXCustomPVO1();  
      if(xxCustomPVO.getRowCount() == 0 )  
      {  
           Row xxCustomPVORow = xxCustomPVO.createRow();  
           xxCustomPVORow.setNewRowState(Row.STATUS_INITIALIZED);        
           xxCustomPVORow.setAttribute("Id",new Number(-1));  
           xxCustomPVO.insertRow(xxCustomPVORow);  
      }  
 }  

 public void setXXCustomPVOValues(String[] name,String[] val)  
 {  
      OAViewObjectImpl xxCustomPVO = getXXCustomPVO1();  
      xxCustomPVO.setRangeSize(-1);  
      Row row = xxCustomPVO.getRowAtRangeIndex(0);  
      for(int i = 0; i < name.length; i ++)  
      {  
           if("Y".equals(val[i]))  
           {  
                row.setAttribute(name[i],Boolean.TRUE);  
           }  
           else  
           {  
                row.setAttribute(name[i],Boolean.FALSE);  
           }  
      }  
 }  
Write the below code in the processRequest of the Controller. This will create a Row in the PVO and initialize the PVO attributes.
 import java.io.Serializable;  
 import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;  
 OAApplicationModuleImpl appModule = (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);  
 appModule.invokeMethod("intializeXXCustomPVO");
  
 String[] name = {"RenderAttr1","RenderAttr2"};  
 String[] val  = {"Y","N"};
  
 Serializable[] params = {name, val};  
 Class[] paramTypes    = {String[].class, String[].class};
  
 appModule.invokeMethod("setXXCustomPVOValues", params, paramTypes);  

Write the below code in the
processFormRequest based on your condition.Change the values of the val[] appropriately, based on your use case.
 OAApplicationModuleImpl appModule = (OAApplicationModuleImpl)pageContext.getApplicationModule(webBean);
  
 String[] name = {"RenderAttr1","RenderAttr2"};  
 String[] val  = {"N","Y"};
  
 Serializable[] params = {name, val};  
 Class[] paramTypes    = {String[].class, String[].class};
  
 appModule.invokeMethod("setXXCustomPVOValues", params, paramTypes);  

You can use the below syntax to set the Rendered property of the bean.
   ${oa.XXCustomPVO1.RenderAttr1}

   ${oa.XXCustomPVO1.RenderAttr2}


Feel free to point out if anything is missing/wrong in this blog.

Friday, 5 June 2015

Forms & Reports: How to install 11gR2 Forms and Reports Builder in Windows 7 64bit OS

It took some time for me to successfully install Oracle Forms and Reports Builder in my Windows 7 64 bit machine, because of the Java version and 32 bit/64 bit issues. So I thought I will add this to my blog, so that it will be useful for others and also for my future reference.

The steps are detailed in this excellent post: Installing Oracle Forms and Reports 11G Release 2

I will just mention the main points here. For the detailed instructions you can follow the above mentioned blog.


  • Install 64 bit JDK. I installed JDK 7u79 (jdk-7u79-windows-x64.exe).
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

  • Install Weblogic Server 10.3.6. Make sure that you download the Generic version (wls1036_generic.jar). I missed this point and wasted 2-3 hours :).
http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html
  • Install Oracle Forms and Reports 11g Release 2 64bit. I installed 11.1.2.2.0. (ofm_frmrpts_win_11.1.2.2.0_64_disk1_1of2.zipofm_frmrpts_win_11.1.2.2.0_64_disk1_2of2.zip)








Feel free to point out if anything is missing/wrong in this blog.

Wednesday, 3 June 2015

OAF: Issues associated with VO Substitution in Oracle Applications Framework - Part2

In this post I will explain the fix for some other issues associated with VO Substitution in Oracle Application Framework.

This is the continuation of my other blogs on the VO Substitution issues:
OAF: Issues associated with VO Substitution in Oracle Applications Framework - Part1
OAF: Transient Attributes not getting populated in Extended VO


Sample errors:
## Detail 0 ## java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: INVOICE_ID

## Detail 0 ## java.sql.SQLSyntaxErrorException: ORA-01722: invalid number

Reference of errors :
https://community.oracle.com/thread/3729150
https://community.oracle.com/thread/3727660


Fix:
Change the Binding Style of VO from 'Oracle Named' to 'Oracle Positional'.


Refer the below link for more details about the Named and Positional bindings.
Binding and Defining


Feel free to point out if anything is missing/wrong in this blog.

Tuesday, 2 June 2015

OAF: EL (Expression Language)


Prior to Release 12.2, EL support was referred to as SPEL (Simplest Possible Expression Language) support, which included a subset of the currently supported EL types and EL-supporting properties.
You could find more details of SPEL in my other blog: OAF: Spel Binding

The below details are from the OA Framework Developer's Guide 12.2.3 : Oracle Application Framework Developer's Guide Release 12.2.3 (Doc ID 1593765.1)

EL Types
${oa.<ViewInstance>.<ViewAttr>}
Evaluates to <ViewInstance>.getAttribute("<ViewAttr>").
${oa.current.<ViewAttr>}
Evaluates to <ViewInstance_attached_to_the_bean>.getAttribute("<ViewAttr>").
${oa.encrypt.<ViewInstance>.<ViewAttr>}
Returns the encrypted value of the <ViewInstance>.getAttribute("<ViewAttr>") statement.
${oa.FunctionSecurity.<FunctionName>}
Returns true or false depending on whether FunctionName is granted to the current user.
${oa.request.<paramName>}
Evaluates to pageContext.getParameter("<paramName>").
${oa.session.<paramName>}
Evaluates to pageContext.getSessionValue("<paramName>").
${oa.sessiondirect.<paramName>}
Evaluates to pageContext.getSessionValueDirect("<paramName>").
${oa.txn.<paramName>}
Evaluates to pageContext.getTransactionValue("<paramName>").
${oa.txntrans.<paramName>}
Evaluates to pageContext.getTransactionTransientValue("<paramName>").
${oa.pageContext.<methodName>}
Evaluates to pageContext.<methodName>().
Note: Only public methods without parameters may be invoked using this EL syntax.
${oa.class.<className>.<methodName>}
Invokes the method in the specified class.
Notes:
• Provide <className> as a fully qualified class name.
• The class must have a no-argument (zero argument) constructor.
• Only public methods without parameters may be invoked using this EL expression.

Usage Notes:
  • Use oa.boolean.false or oa.boolean.true to represent Boolean.FALSE or Boolean.TRUE, respectively.
  • For the negation or ! (NOT) operator, use oa.boolean.false, as in the example,  ${oa.session.isItemRendered == oa.boolean.false}.
  • For an EL expression:
    • You may only specify a static numeric value.
    • Use ${oa.text.<TEXT>} to represent a string.
    • Use oa.boolean.false or oa.boolean.true to represent a Boolean.
Sample Usage:

  • ${oa.session.param1 == oa.request.param1}
  • ${oa.session.paramLength + ( oa.request.fieldLength * 2 ) }
  • ${oa.session.isItemRendered == oa.boolean.false}

Combining Static Text with EL
Use the syntax ${oa.text.<TEXT>} to prepend or append static text to an EL expression.

Usage Notes
  • Warning: If you append static text to an EL expression, be aware that the static text will not get translated and the order of the text may vary depending on the language.
  • You may append text to an EL expression in any order, as shown in these examples, where ${EL} represents any valid EL type:
    • ${oa.text.<TEXT>} + ${EL}
    • ${EL} + ${oa.text.<TEXT>} + ${EL}
Sample Usage
  • ${oa.text.Welcome Mr.} + ${oa.EmpVO.Empname}

Feel free to point out if anything is missing/wrong in this blog.

OAF: Spel Binding

Simplest Possible Expression Language (SPEL) - An industry-standard expression language included in the JSP Standard Tag Library (JSTL)

For selected properties, OA Framework supports the use of SPEL expressions to quickly bind the property to an underlying data source that provides the property's value. For example, you could bind the Rendered property of a button to a view object attribute to ascertain whether it should be hidden or shown when the page renders.

The SPEL syntax for this property looks like:
   ${oa.<ViewInstanceName>.<ViewAttributeName>}
       
      eg:-  ${oa.XXViewObject1.ViewAttrName}

If you are working with a table-in-table or HGrid that uses view links, you need to modify your SPEL syntax as shown: ${oa.current.viewAttrName}. The inclusion of current keyword lets you say "get the value from whatever row BC4J is using to render the current row" since you won't know how to access the view objects and row sets created dynamically for these complex components.

To add a VOAttribute value in a link 
eg: OA.jsp?OAFunc=XXX_FUNC&VENDOR_SITE_ID={@VendorSiteId}&SUPP_NAME={@SupplierName}

You can also use SPEL based on the security grant. The below expression will return false if <FunctionName> is granted to the current user/responsibility, otherwise true
   ${oa.FunctionSecurity.<FunctionName>}

If you want to pass a attribute for the form submission and if you want to encrypt the parameter, you can add the expression as below in the parameters property window:
   ${oa.encrypt.<ViewInstanceName>.<ViewAttributeName>} 

From 12.2, there is more support: OAF: EL (Expression Language)

Feel free to point out if anything is missing/wrong in this blog.

Monday, 1 June 2015

OAF: JDR_UTILS

In this post I will explain some of the procedures of JDR_UTILS, which will be useful when you work on OA Framework. You can describe the JDR_UTILS package if you have apps user database account access.

Most commonly used procedures are as below:

listCustomizations 
printDocument
deleteDocument
listDocuments

  • jdr_utils.listCustomizations()
This procedure can be used to check whether any personalization exists for a particular page or  substitution exists for a particular EO/VO/AM.
 begin  
  jdr_utils.listCustomizations('/ajtest/oracle/apps/fnd/test/webui/TestPG');  
 end;  
 begin  
  jdr_utils.listCustomizations('/ajtest/oracle/apps/fnd/test/server/TestVO');  
 end;  
  • jdr_utils.printDocument()
This procedure can be used to get the Page / Personalization / Substitution file. You can pass the output of the above procedure as a parameter to this procedure to get the details.
 begin  
  jdr_utils.printDocument('/ajtest/oracle/apps/fnd/test/webui/TestPG');  
 end;  
 begin  
  jdr_utils.printDocument('/ajtest/oracle/apps/fnd/test/webui/customizations/site/0/TestPG');  
 end;  
 begin  
  jdr_utils.printDocument('/ajtest/oracle/apps/fnd/test/server/customizations/site/0/TestVO');  
 end;  
  • jdr_utils.deleteDocument()
This procedure can be used to delete a particular Page / Personalization / Substitution. Please be careful when you use this procedure. Make sure that you are using the right parameter when using this procedure. You will have to COMMIT after calling calling this procedure.
 begin  
   jdr_utils.deleteDocument('/ajtest/oracle/apps/fnd/test/webui/TestPG');  
 end;  
 begin  
   jdr_utils.deleteDocument('/ajtest/oracle/apps/fnd/test/webui/customizations/site/0/TestPG');  
 end;  
 begin  
   jdr_utils.deleteDocument('/ajtest/oracle/apps/fnd/test/server/customizations/site/0/TestVO');  
 end;  
  • jdr_utils.listDocuments()
This procedure will print all the files under the specified path. 
 begin  
   jdr_utils.listDocuments('/ajtest/oracle/apps/fnd/test/webui');  
 end;  
You can add an additional parameter to recursively print all the documents under the specified path
 begin  
   jdr_utils.listDocuments('/ajtest/oracle/apps/fnd/test',true);  
 end;  

A nice explanation of all the API's in jdr_utils is available in this blog : List of JDR_UTILS APIs
Feel free to point out if anything is missing/wrong in this blog.