Showing posts with label OAF. Show all posts
Showing posts with label OAF. Show all posts

Sep 26, 2019

OAF Attachment Page with AK Entity

To display the content of attachments in OAF, we need to follow the below approach in JDevloper as well in EBS Application

Step 1: Create the AK Entity for the attachment section and map it to the right database table with Primary column

Responsibility: AK Html Forms
Navigation: AK Entities





Step 2: Under the Page development in JDevloper, create the region and attachment item with type 'attachmentLink'

Create a Region with 'defaultSingleColumn' and create a sub-item with type 'attachmentLink' and map the correct VO in the View Instance. Add the attachment Prompt and Link Text for user convenience.




Step 3: Create the Primary Key and Category Map under the entity map section for attaching the item with AK entities.


Step 4: Tag the correct Primary Key column in the View Attribute column for linking the content with FND_ATTACHED_DOCUMENTS table.

Note: All the uploaded content will be stored in FND ATTACHED DOCUMENTS table with the mapped primary column crId.

 Category is mentioned as MISC (Miscellaneous) under the categoryMap for the uploaded content.















Step 5: Validate the OAF page and result will be displayed like below for the Attachment Section,


















Page Controller to capture the raised attachment events,

    if ("oaAddAttachment".equals(pageContext.getParameter(EVENT_PARAM)) ||
     "oaUpdateAttachment".equals(pageContext.getParameter(EVENT_PARAM)) ||
     "oaDeleteAttachment".equals(pageContext.getParameter(EVENT_PARAM)) ||
     "oaViewAttachment".equals(pageContext.getParameter(EVENT_PARAM)) )

{

System.out.println("Attachment Event Raised");
     
}

Sep 24, 2019

OAF Setup for DB and APP Connection

All the custom page can be developed and tested in our work system with the help of JDeveloper before deploying it to the Oracle Application. But still it need access to Application and DB in order to avoid the unnecessary error while deploying the custom page in the E-Business Suite.

For developing any custom page we need both DB as well APP connection detail string in order to fetch the database objects and application infra for the proper deployment. If the custom development runs well in JDeveloper then it will surely works well in the Application side too.. !!!


A. Database Connection setup

Enter the following details in the DB Setup

Navigation: JDevloper (Tools --> Project Properties --> Oracle Application --> Database Connection)

Step 1: Enter the Database name (Naming Convention can be anything and not related to DB TNS entry)



Step 2: Enter the DB Username and Password


Step 3: Enter the DB Host name, Port and SID as per your DB TNS entry


Step 4: Test the connection and make sure it return the status "SUCCESS"



B. Application Setup for the Login User with DBC file

Keep the DBC file under the path "jdevhome\jdev\dbc_files\secure"



Make sure the FND user have the correct responsibility attached before mapping it in the APP setup

Enter the following details in the APP Setup

Navigation: JDevloper (Tools --> Project Properties --> Oracle Application --> Runtime Connection)

Step 1: Place the DBC file under the specified path as mentioned above and BROWSE and map it under the 'DBC File Name'

Step 2: Enter the Username and Pwd with right Application Short name and Responsibility Key.


DBC file in JDeveloper Tool

How to get the DBC file from APP Server to use it in JDeveloper Tool

Step 1: Login to APP Server and go to $INST_TOP

cd $INST_TOP/appl/fnd/12.0.0.0/secure

ls -ltr

-rw-------. 1 applmgr dba 827 Jul 10 06:13 DEV.dbc

Step 2: Permission will be limited for other users other than application manager, so cat the file and save it

cat DEV.dbc

Copy the content and save it with .dbc extension

Step 3: JDevloper Path for DBC connection

If once saved the file, place it under jdevhome\jdev\dbc_files\secure

If all 3 steps done, try playing with OAF Page !!!

OAF Controller Functions

1. Deriving Various Bean values

a. messageStyledText

OAMessageStyledTextBean lvariable = (OAMessageStyledTextBean)webBean.findChildRecursive("column1");

b. messageTextInput

OAMessageTextInputBean lvariable = (OAMessageTextInputBean)webBean.findChildRecursive("column1");

c. messageChoice

OAMessageChoiceBean lvariable = (OAMessageChoiceBean)webBean.findChildRecursive("column1");

d. messageLovInput

OAMessageLovInputBean lvariable = (OAMessageLovInputBean)webBean.findChildRecursive("column1");

e. submitButton

OASubmitButtonBean lvariableSubmitButton = (OASubmitButtonBean)webBean.findChildRecursive("submitButton1");

f. button

OAButtonBean lvariableButton = (OAButtonBean )webBean.findChildRecursive("button1");

2. To commit the database transactions

getTransaction().commit();

3. To discard the database transactions

getTransaction().rollback();

4. To Forward a page from one screen to another

if (pageContext.getParameter("nextPage")!=null) {

      pageContext.forwardImmediately("OA.jsp?page=/oracle/apps/fnd/framework/newpage/webui/xxSearchPG",
                                           null,
                                           OAWebBeanConstants.KEEP_MENU_CONTEXT,
                                           null,
                                           params,
                                           true, // retain AM
                                           OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
     

    }

5. To initiate an Application Module (AM)

xxSearchAMImpl am = (xxSearchAMImpl)pageContext.getApplicationModule(webBean);
 
am.invokeMethod("apply");

6. To put a session value

pageContext.putSessionValue("currentPage","Page1");

7. To get a session value

String variableNew = (String)pageContext.getSessionValue("variableOld");

8. To hide a button/submit button using the Render property

OASubmitButtonBean SaveVariable = (OASubmitButtonBean)webBean.findChildRecursive("button1");

SaveVariable.setRendered(false);

SaveVariable.setRendered(true);

9. Forming Dynamic Parameter in Controller

HashMap params = new HashMap(1);
params.put("PageMode","CREATE");

      if ( pageContext.getParameter("PageMode")!=null && pageContext.getParameter("PageMode").equals("CREATE")  )

       {
     
System.out.println("Page for Create Action");

 am.invokeMethod("createRecord");

//Set Parameter value for PageMode back to Original State.
             
           HashMap params = new HashMap(1);
           params.put("PageMode","NULL");
         
         }

Oracle Application Framework Developer and Personalization Guide

URL to find the OAF Developer and Personalization Guide for the version R12.2

Oracle Application Framework Developer Guide:

Oracle Application Framework Developer's Guide, Release 12.2.4 (Doc ID 1676216.1)




Oracle Application Framework Personalization Guide:

https://docs.oracle.com/cd/E26401_01/doc.122/e22031.pdf





Sep 23, 2019

Table Events | OAF Page

Table events are HTTP requests that are trapped and processed by OA Framework and handled during the processFormRequest phase.



1. EVENT_PARAM - indicates the event generated by a web bean (a table, in this case).


2. GOTO_EVENT - when 'Next' or 'Previous' navigation links are selected


3. SORT_EVENT - when a column header is selected to sort that column


4. HIDE_EVENT - when the 'Hide' link of a detail disclosure is selected


5. SHOW_EVENT - when the 'Show' link of a detail disclosure is selected


6. ADD_ROWS_EVENT - when the 'Add Another Row' button is selected


7. UPDATE_EVENT - when the total row 'Recalculate' button is selected


8. VALUE_PARAM - indicates a value that is relevant to a particular event: When a detail disclosure Hide/Show is selected, the value parameter contains the row index corresponding to the row whose Hide/Show was selected. When the 'Next' or 'Previous' link of table navigation bar is selected, the value parameter contains the index of the first row of the current range. For example, when the row range 1-10 is displayed, the value is 1 and when the row range 11-20 is displayed, the value is


9. SIZE_PARAM - indicates the number of rows currently displayed in the table (relevant only to the navigation event).


10. STATE_PARAM - indicates the current sort state (ascending or descending) of the column on which sorting is invoked (relevant only for the sort event).



Hide a mandatory field | OAF Page

If the business wants to hide a field in the seeded page, you can do it by personalizing the page and set Rendered property to false.
But this solution will not help you if the field is marked as mandatory by the seeded page.

The reasons are Mandatory Validations are usually done at the EO level. Hence even if you hide the mandatory field, the validation would still happen at the server. If the column has not null constraint in the table, it will throw a database error.


How to solve this ?

You can fix this by setting a default value for the mandatory field.

Extend the controller and set the value in the process Request() method. This is the safest way to default the value to the mandatory field.

After defaulting the mandatory variable, personalize the page and set the rendered property to false.

Hope it helps !!

Sep 4, 2019

OAF Date Field conversion to String using standard library SimpleDateFormat

In OAF if we create an attribute with DATE type then the value retained will be in the format of  yyyy-MM-dd hh:mm:ss.S

Ex: 2019-05-25 00:00:00.0



In order to convert the date format from yyyy-MM-dd hh:mm:ss.S to dd-MMM-yyyy, use the below piece of snippet.

Code to handle the Date Conversion:

import java.text.SimpleDateFormat;

    String convStr1=null;

OAMessageDateFieldBean  par1=(OAMessageDateFieldBean )webBean.findIndexedChildRecursive("crTargetFrom");             
                Timestamp TargetFrom = (Timestamp)par1.getValue(pageContext);

System.out.println("Target From :"+TargetFrom);

SimpleDateFormat format                = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
SimpleDateFormat formatDate            = new SimpleDateFormat("dd-MMM-yyyy");

                try
                   {

                    java.util.Date dateStr1 = format.parse(TargetFrom.toString());

                    convStr1 = formatDate.format(dateStr1);

                                     
                    System.out.println("String date Converted : "+convStr1);

                    }
                 
                catch (Exception e)
                    {

                    System.out.println("String date exception "+e);

                    }

Aug 21, 2019

Throw Bundled Exception | OAF Page



  ArrayList bundle=new ArrayList();     //first we have to initialize the Array List

             
  if(empname.contains("@"))
                {
                bundle.add(new OABundleeption("Special character not allowed",OABundleeption.ERROR));
                }
  if("".equalsIgnoreCase(pageContext.getParameter("StartDate").trim()))
                {
                bundle.add(new OABundleeption("Start date shold not be null",OABundleeption.ERROR));
                }
  if(!bundle.isEmpty())
                {
                OABundleeption.raiseBundledOABundleeption(bundle);
                }
                }

List all the Parameter names and values | OAF Page



import java.util.Enumeration; 

Enumeration enums = pageContext.getParameterNames(); 
 while(enums.hasMoreElements())
{ 
   String paramName = enums.nextElement().toString(); 
   System.out.println("Param name:-->" +paramName+ ";Value:-->"+pageContext.getParameter(paramName)); 
 }



Create VO Programmatically | Dynamic VO | OAF


ViewObject dynamicViewObject = appModule.findViewObject("XXDynamicVO"); 

 if(dynamicViewObject == null) 
 { 
  String voQuery = " SELECT USER_NAME " + 
                                " FROM fnd_users FU " + 
                                " WHERE FU.user_id = :1 "; 
  customViewObject = appModule.createViewObjectFromQueryStmt("XXDynamicVO",voQuery); 
 } 

 if(customViewObject != null) 
 { 
  customViewObject.setWhereClause(null); 
  customViewObject.setWhereClauseParams(null); 
  customViewObject.setWhereClauseParam(0,userID); 
  customViewObject.executeQuery(); 
  Row customViewObjectRow = customViewObject.first(); 
  if(customViewObjectRow != null) 
  { 
       String userName = (String)customViewObjectRow.getAttribute(0); 
  } 
 }  

Aug 20, 2019

Call PL/SQL Procedure | From OAF Page



 import oracle.jdbc.OracleCallableStatement;  
 import oracle.jdbc.OracleTypes;
 import oracle.jbo.domain.Number;
 import oracle.jbo.domain.Date;
   
 public void callPLSQLProc(Number id,String code,Date currentDate)  
 {  
      OracleCallableStatement callableStatement = null;  
      try  
      {  
           String callProc = " BEGIN xxx_pkg.xxx_proc "+  
                                         "(p_id             => :1," +  
                                         " p_code           => :2," +
                                         " p_date           => :3," +
                                         " p_commit         => :4," +                                                  
                                         " x_return_status  => :5," +  
                                         " x_msg_data       => :6," +  
                                         " x_msg_count      => :7);"+  
                                    " END; ";  
           callableStatement = (OracleCallableStatement)getOADBTransaction().createCallableStatement(callProc,1);  
           callableStatement.setNUMBER(1, id);  
           callableStatement.setString(2, code);          
           callableStatement.setDATE(3, currentDate);    
           callableStatement.setString(4, "Y");     
           callableStatement.registerOutParameter(5,OracleTypes.VARCHAR,255);  
           callableStatement.registerOutParameter(6,OracleTypes.VARCHAR,255);  
           callableStatement.registerOutParameter(7,OracleTypes.NUMBER,255);    
           callableStatement.execute();  
           String resultMessage = (String)callableStatement.getString(5);  
           String msgData  = (String)callableStatement.getString(6);  
      }  
      catch(Exception e)  
      {  
           e.printStackTrace();  
           throw new OAException(e.toString(),OAException.ERROR);  
      }  
      finally  
      {  
           try  
           {  
                callableStatement.close();  
           }  
           catch(Exception exception2)  
           {  
                throw OAException.wrapperException(exception2);  
           }  
      }  
 }        

:1,:2,:3 & :4 è IN Parameter   
:5,:6,:7 è Out Parameter

Call PL/SQL Function | From OAF Page



 import oracle.apps.fnd.framework.server.OADBTransaction; 
 import oracle.jdbc.driver.OracleTypes; 
 import oracle.jdbc.OracleCallableStatement;
 
 public String callFunction( String id) 
 { 
      String status = null;
      OADBTransaction oadbtransaction = getOADBTransaction(); 
      OracleCallableStatement oraclecallablestatement = null; 
      Object obj = null; 
     
      String sqlString = "BEGIN :1:=xx_pkg.xx_func( p_id => :2 ); END;"; 
      
      try 
      { 
           oraclecallablestatement =             (oracleCallableStatement)oadbtransaction.createCallableStatement(sqlString , 1); 
           oraclecallablestatement.registerOutParameter(1, OracleTypes.VARCHAR, 0, 10); 
           oraclecallablestatement.setString(2, id); 
           oraclecallablestatement.executeQuery(); 
           status = String.valueOf(oraclecallablestatement.getString(1)); 
      } 
      catch(Exception exception1) 
      { 
           throw OAException.wrapperException(exception1); 
      } 
      finally 
      { 
           try 
           { 
                oraclecallablestatement.close(); 
           } 
           catch(Exception exception2) 
           { 
                throw OAException.wrapperException(exception2); 
           } 
      } 
      return status ; 
 }  

:1 è Out Parameter to hold results from function.

:2 è IN Parameter   
 




Transient Attributes not getting populated | VO Extension




Scenario:

Standard VO has some transient attributes which gets populated by overriding the getter methods in the VORowmpl. When we extend this VO for adding some additional attributes, everything works except the original transient attributes. Those attributes are coming as null.

The reason is, when the extended VORowImpl is getting generated by the Jdeveloper, it will not call the super method (which is already overridden). So you need to modify the getter method of the Transient attribute in the extended VO to call the getter method in the Standard VO using super.


Standard VORowImpl getter method will be something as shown below.

                                public String getAttribute1() { 
                                                                return "Calculated Value"; 
 }  


Generated getter method in the extended VORowImpl  as shown below.

                                public String getAttribute1() { 
  return (String) getAttributeInternal("Attribute1"); 
 }  
Solution:

To fix this, modify the getter method of the extended VORowImpl as shown below.

                                public String getAttribute1() {  
  //return (String) getAttributeInternal("Attribute1"); 
  return super.getAttribute1();
 }

Populate LOV | Tab Out in OAF




Expectation :

Type search words in LOV Field & TAB out, it should populate the values as per search.

Issue : 

In LOV field, No response occurs when we type something & then click on TAB key.

Solution :

                Set disable validation Property to False for LOV.

Display Current Date | OAF Page

        To Create an Date Bean programmatically

        OAMessageDateFieldBean currentdate =  (OAMessageDateFieldBean)createWebBean(pageContext,
                                                                                      OAWebBeanConstants.MESSAGE_DATE_FIELD_BEAN,
                                                                                       null,
                                                                                           "datefield");
                                                                                           currentdate.setReadOnly(true);

        pageLayoutBean.addIndexedChild(currentdate);


               
         To Initialize Date
               
   OAApplicationModule am = pageContext.getApplicationModule(webBean);--Initialize/Invoke AM
   SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");   -- Formatting
   String dateString = am.getOADBTransaction().getCurrentDBDate().toString();--Get DB Date from AM


   java.sql.Date sqlDate = null;

        Parsing Date Format 

        try {
            sqlDate = new Date(f.parse(dateString).getTime());
            System.out.println("What is sqlDate value ********** " + sqlDate);
         }
        catch (ParseException e) {
            e.getMessage();
        }

        OAMessageDateFieldBean dateField =
            (OAMessageDateFieldBean)webBean.findIndexedChildRecursive("datefield");
       
        To set current Date in Bean

        if (dateField != null) {
            dateField.setValue(pageContext, sqlDate);
            System.out.println("I am checking dateField  not null ********* " + dateField );
        }


Jul 2, 2019

Oracle Application framework JDR_UTILS API

A. JDR_UTILS.LISTDOCUMENTS

This API will help to list all the OA Framework documents from the particular path/module.

Sample Script to use it in TOAD/SQL DEVELOPER

BEGIN
jdr_utils.listdocuments('/oracle/apps/ap/oie/creditCard/statement/webui/UnusedCCTrxnPG', TRUE);
END;

B. JDR_UTILS.LISTCUSTOMIZATIONS

To list all the Personalizations and Extensions for a specific custom enhancement use the jdr_utils.listcustomizations.

Sample Script to use it in TOAD/SQL DEVELOPER

BEGIN
jdr_utils.listcustomizations('/oracle/apps/ap/oie/creditCard/statement/webui/UnusedCCTrxnPG');
END;

C. JDR_UTILS.PRINTDOCUMENT

To view the actual implementation code or logic for a specific enhancement use the jdr_utils.printdocument.

Sample Script to use it in TOAD/SQL DEVELOPER

BEGIN
jdr_utils.printdocument('/oracle/apps/ap/oie/creditCard/statement/webui/UnusedCCTrxnPG');
END;

D. JDR_UTILS.DELETEDOCUMENT

To delete a document or a personalization we can use the jdr_utils.deletedocument API.

Sample Script to use it in TOAD/SQL DEVELOPER

BEGIN
jdr_utils.deletedocument('/oracle/apps/ap/oie/creditCard/statement/webui/customizations/user/12345/UnusedCCTrxnPG');
END;

Jun 17, 2019

Oracle OAF Profile Option Overview


Oracle OAF has some important profile options which is useful in extension or personalization.

1. FND_Diagnostics
Setting this profile option to YES, will add anew link "Diagnostics" at top right on page, that allow developer to trace logs.

To add log when coding use the following code in Controller or Application Module
In Controller write this code:-
pageContext.writeDiagnostics(this, "Phrase will be added to logs", 1);

In Application Module write this code
getOADBTransaction().writeDiagnostics(this, "Phrase will be added to logs", 1);
2. Personalize Self-Service Defn
 Set this profile to Yes to allow personalization.  
3. FND: Personalization Region Link Enabled :
Set this profile to  Yes  show "Personalize  Region" links above each  region in a page. 
4. Disable Self-Service Personalization
Yes will disable all personalization at any level. 

5. FND: Personalization Document Root Path
Set this profile option to a directory at application server machine which will contain import/export personalization files

Jun 14, 2019

How to refresh or clear page in OAF



//Clear button code
       if(pageContext.getParameter("Clear")!=null)
         {
            pageContext.forwardImmediatelyToCurrentPage(null, false, null); 
         
         }


Note : "Clear" refers to the Button ID in page.

Find | DBC File Path in Oracle Applications.


Navigation :

  Click on About This Page in homepage ==> Under Tabs, click on Java System Properties ==> Search for keyword DBCFILE.

Useful Workflow Commands

  WFLOAD apps/columbus789 0 Y DOWNLOAD APEXP_FINDEV.wft APEXP Locations: $PO_TOP/patch/115/import/US/porpocha.wft $PO_TOP/patch/115/import/U...