Search This Blog

Showing posts sorted by relevance for query co extension. Sort by date Show all posts
Showing posts sorted by relevance for query co extension. Sort by date Show all posts

Saturday, March 19, 2016

21. OAF CO Extension

CO Extension in OAF


In this lesson we are going to see how to extend CO (Controller) in OAF. Before that let us see the requirement. Go to the following navigation.
Purchasing, Vision Operations -> Supply Base ->Supplier User Management ->Supplier User Creation ->Invite Supplier User.
 
For reference let’s have a look into the below image:-
Invite supplier user navigation in OAF
After selecting the Invite Supplier User we will see OAF page. The same page part is shown in the below image.
Invite supplier  user OAF page
If you observe in the above image User Information is highlighted which contains Email Address and Note. Here our requirement to add User Name field into the User Information. It means if we logged in with Operations user then that User Name must display in User Information.
If you observe, according to the requirement, we need to display the User Name when the page is loaded. It means we need to write the code in the processRequest of Controller class.
 
 
Let us see the CO extension process step wise:-
Step 1: First to display the user name we need to create one item, so therefore create one item for that Select Personalize “User Information” in OAF page.
After that select create Item image as shown in the below image:
Creating item in OAF CO extension
 
For item in the properties:-

Level      : Site
Item Style : Message Text Input
ID         : UserName
Prompt     : User Name
Item properties in CO extension
 
Step 2: Finding the Controller to extend. Before extending CO we need to find out which Controller we need to extend. This step explains how to find the main CO in page.
Go to “About This Page”, Expand all. After expanding all we can see the controller name in Controller column in the same row where the page name contains.
For example in our requirement the page name is Invite a Supplier User, so in that row InvitationCO is added. It means Invitation CO is the main Controller.
The below image shows two controllers, but if you observe InvitationCO is the main Controller because which is attached to the main page region.
Finding main controller in OAF CO extension
So therefore finally we came to know that InvitationCO is the Controller which we need to extend.
 
Step 3: Download the Controller from the $Java_Top and create the directory structure in JDeveloper Patch file in our desktop system.
Note that it is not necessary that we need to download entire files in the structure. Copying the whole files in the structure may take long time for copying and also most of the times it impact on JDeveloper performance.
The below sample image shows the copying and creating directory structure process, which shows actually what exact files are copying from the server.
Copying the controller files from server to desktop
Step 4: Open the JDeveloper and Create the Dummy work space.
New workspace creation for CO extension in Jdeveloper
Note that while in Project Wizard you must give the same package name which you will find in about this page. For example see the below image.
Creating new project in Jdeveloper for CO extension
After finishing project, create the dummy page for structure.
 
Step 5: In this step you need to create one new controller. Normally we will create controller on page, just by right clicking on the page region we will select Set New Controller… option, but here in Controller extension it is not like that. Let’s see how to set controller in CO Extension.
In Application Navigator, Right click on webui and select “New…” Option.
Creating CO in CO extension process
In Categories extract General and then select Simple Files. Select JavaClass in Items. The below image shows the Java Class Selection process.
Creating java class for controller extension
In Extends click on the Browse button and select Original CO (InvitationCO). This Original CO will be available because we copied the CO and created the same directory structure in JDeveloper patch.
Selecting the original CO in CO extension
So therefore finally after giving Name, Package, and Extends click on OK button.
Java class creation process in CO extension
 
Step 6: In this step go to the controller java file, create the processRequest method same as it is in seeded. After creating method write the java code to display the User Name. The below is the java code that you need to type. Note that copying the below code and pasting it in your JDeveloper is fine, but check the import files properly.
[sql]package xxcoextension.oracle.apps.pos.registration.webui;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
import oracle.apps.pos.registration.webui.InvitationCO;
public class InvitationCOEx extends InvitationCO
{
  public InvitationCOEx()
  {
  }
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
    String UName = pageContext.getUserName();
    OAMessageTextInputBean mst =(OAMessageTextInputBean)webBean.findChildRecursive(“UserName”);
    mst.setValue(pageContext,UName);
  }
}
[/sql]
 
Step 7: Copy the project folder and paste it in $Java_Top, Classes directory (folder) of server. The below image shows the sample process of moving the files from the desktop to the server.
Moving the CO extension project file to server
Step 8: Login to the Application and click on “About This Page”, now we can see the Extended CO name which is replaced with the Earlier Seeded Name.
Finding extended CO in OAF page
Here Like VO and AM extension no need to run the Import script. But to activate the CO you must follow the below step wise process.
First step, select Personalize Page option and then select Personalize button, for example see the below image.
Personalizing page in CO Extension
In step two, at site level give the package name. Here you must be careful while creating package name. See the directory structure where actually the class file contains.
 
For example our class file is located in the following directory structure.
xxcoextension/oracle/apps/pos/registration/webui/InvitationCOEx.class
Now replace the slash (/) with the dots and remove .class, for example see the below one:
xxcoextension.oracle.apps.pos.registration.webui.InvitationCOEx
Finally the controller path is ready and that we need to give in site level (site level is an example we are taking here, you can take any other level too if required to restrict).
 
The below image shows the example, where actually the controller class path is given.
Giving controller class for page in CO extension
Now finally you can see that after extending CO we are able to see the User Name, whenever the page got loaded. For example see the below image:
Final output after extending CO in OAF

Wednesday, February 3, 2021

Oracle EBS R12 CO Extension for Attachment Mandatory in SSHR Review Page

Read this below blog to have a overview how the CO Extension works.

http://mogalafzal.blogspot.com/2016/03/21-oaf-co-extension.html


Requirement: 

To make the attachments mandatory in the review page for certain EIT and SIT Transactions, not all.

Created lookup value with the Function_name as lookup_code to validate attachments required. Attached procedures and images of lookups for reference.


1.

Page: /oracle/apps/per/selfservice/review/webui/ReviewPG
Controller: ReviewCO --> ReviewCOEx

Create new project with package name: xxcust.oracle.apps.per.selfservice.review.webui

import the folder from the java top :  oracle.apps.per.selfservice.review.webui.ReviewCO (class file)


2.

Write below code in PFR in your extend of ReviewCO as ReviewCOEx java file.


public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean) {
        

      OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
         // throw new OAException("under sql exception"+oapagecontext.getParameter("OAFunc"),OAException.INFORMATION);
 OADBTransactionImpl txn = (OADBTransactionImpl)oapagecontext.getRootApplicationModule().getOADBTransaction();      
        
        //getting the function id name and comparing it with our lookup values to check if required Y or N
          String outParamValue = null;  
      CallableStatement callableStatement =      
        txn.createCallableStatement("begin P_GET_TXN_NAME_YN(:1, :2); end;",OADBTransaction.DEFAULT);      
      try {     
          callableStatement.setString(1,oapagecontext.getParameter("OAFunc"));// "HR_EIT_VS_SS"
        callableStatement.registerOutParameter(2, Types.VARCHAR);  
        
        
        callableStatement.execute();  
        outParamValue = callableStatement.getString(2);  
        callableStatement.close();  
      } catch (SQLException sqle) {  
        
            throw new OAException("under sql exception"+sqle,OAException.ERROR);
      }  
      
          OADBTransactionImpl txn2 = (OADBTransactionImpl)oapagecontext.getRootApplicationModule().getOADBTransaction();
          OAMessageAttachmentLinkBean uploadBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("AttachmentLink");
          String ssdn = (String)uploadBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
          
          //getting the status of the Attachments as None for no attachments, but for arabic it is issue, so we are using lookup values for arabic ex: 'La shai' as 'None' in description.
          String outParamValue2 = null;  
          CallableStatement callableStatement2 =
          txn2.createCallableStatement("begin P_GET_ATTACH_STATUS(:1, :2); end;",OADBTransaction.DEFAULT);
          try {
          callableStatement2.setString(1,ssdn);
          callableStatement2.registerOutParameter(2, Types.VARCHAR);
          
          
          callableStatement2.execute();
          outParamValue2 = callableStatement2.getString(2);
          callableStatement2.close();
          } catch (SQLException sqle2) {
          
            throw new OAException("under sql exception"+sqle2,OAException.ERROR);
          }
       
          /* For testing the outputs
           if (oapagecontext.getParameter("HrSubmit")!= null) {
             throw new OAException("ssdn.trim " + ssdn.trim() + "  outParamValue " +outParamValue + "  outParamValue2 " +outParamValue2 ,OAException.ERROR);
          }
              //throw new OAException("outParamValue " +outParamValue,OAException.ERROR);          }
       */
          if ("Y".equals(outParamValue)){
     if (oapagecontext.getParameter("HrSubmit")!= null)
      {
     // OAMessageAttachmentLinkBean uploadBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("AttachmentLink");
     // String ssdn = (String)uploadBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
         //throw new OAException("ssdn.trim " + ssdn.trim(),OAException.ERROR);
      if ("None".equals(outParamValue2 )  )//|| "View".equals(ssdn.trim()) )//|| "?? ???".contains(ssdn.trim()))
      {
//      throw new OAException("There is no attachment kindly click on add button and browse your attachment",OAException.ERROR);
          throw new OAException("PER", "FUJ_ATTACHMENT_MAND", null, OAException.ERROR, null);

       //   throw new OAException("outParamValue2 " + outParamValue2 + "  outParamValue " +outParamValue ,OAException.ERROR);
      }
      else
      {
      
      super.processFormRequest(oapagecontext, oawebbean);
      }
      }
      else
      {
      //System.out.println("There exists an attachment to the expense claim. The process will now continue");
      super.processFormRequest(oapagecontext, oawebbean);
      }
      }
      else
      {
          super.processFormRequest(oapagecontext, oawebbean);
          //throw new OAException("output value is "+outParamValue,OAException.ERROR);
      }   
          
      }


3.




4 . 

Personlization

5. Move the class folder to the java_top and test the same.

6. for any update in the java code, change the name of the file ex: ReviewCOEx to ReviewCOEx2 or 3 and so on, run/make the code run

and then repeat the step 4,5.

7. Procedures 

CREATE OR REPLACE PROCEDURE APPS.P_GET_TXN_NAME_YN
(P_TXN_NAME VARCHAR2,
P_OUTPUT OUT VARCHAR2)
AS
BEGIN
SELECT 'Y'
INTO P_OUTPUT
 FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_SSHR_ATTACH_REQUIRED'
AND LANGUAGE = 'US'
AND LOOKUP_CODE = P_TXN_NAME;
/*SELECT 'Y'
INTO P_OUTPUT
FROM OAF_TEST
WHERE TXN_NAME = P_TXN_NAME;*/
EXCEPTION WHEN OTHERS THEN
P_OUTPUT := 'N';
END;
/


DECLARE
A VARCHAR2(200);
BEGIN
--P_GET_ATTACH_STATUS('?? ???',A);
P_GET_ATTACH_STATUS('None',A);
DBMS_OUTPUT.PUT_LINE(A);
END;

CREATE OR REPLACE PROCEDURE APPS.P_GET_ATTACH_STATUS
(P_TXN_NAME VARCHAR2,
P_OUTPUT OUT VARCHAR2)
AS
BEGIN
SELECT DESCRIPTION
INTO P_OUTPUT
 FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_SSHR_VALID_COEX'
AND LANGUAGE = 'US'
AND LOOKUP_CODE = UPPER(TRIM(P_TXN_NAME));
/*SELECT 'Y'
INTO P_OUTPUT
FROM OAF_TEST
WHERE TXN_NAME = P_TXN_NAME;*/
EXCEPTION WHEN OTHERS THEN
P_OUTPUT := 'N';
END;
/

Saturday, March 19, 2016

19. OAF VO Extension

Extensions in OAF


In this lesson we will see the different types of extensions in OAF (Oracle Apps Framework). We use extensions if we want to do any changes in the already shipped oracle E-Business suite. The main purpose we use extensions is to make changes in the already well designed Oracle E-Business suite pages.
We have two types of extensions
  1. BC4J Extensions
  2. CO Extension

BC4J Extensions are again divided into three types and they are:
  • VO Extension
  • AM Extension
  • EO Extension
You can see in the further chapters how to create extensions in OAF and how the extensions will make changes in OAF.

VO Extension in OAF


In this lesson we are going to see how to extend the VO (View Object) in OAF (Oracle Applications Framework).
Before going to extent the VO let us understand the requirement first. Navigate to the Purchasing, Vision Operations (USA).
Purchasing, Vision Operations (USA) -> Supply Base -> Supplier User Management -> Supplier User Creation -> Register Supplier User.
 
The same navigation process is shown in the below image:-

Purchasing Vision Operations Register Supplier User Navigation
The below image shows the Register Supplier User OAF page which will appear once we select Register Supplier User option as discussed.
supplier user oaf page in oracle apps
When we click on the Supplier Name search option (LOV) in the above page we will see Supplier Name and Supplier Number.
So therefore our task is to add Vendor Lookup Code additional column in the search list.
Using Customization we can add a column but we cannot carry data to that created column so therefore we need to go for extension if we want to carry data along with Supplier Name and Supplier Number. Hence we have to go for extension let us see how to extent and here the requirement is just to carry data and display it so therefore we know that using VO we can achieve it and hence no need to perform any DML operation like INSERT,UPDATE, DELETE.
 
Let us see the requirement step wise:

Step 1: Identify the VO from the page. It means first we need to identify which VO to be extend. Go to about this page and expand the “Business Component Reference Details”. For reference look at the below image:
Business Component Reference Details in OAF
After that select VendorsVO as we know that supplier called as Vendors  and their information stores in PO_VENDORS table. According to the naming convention VO ends with VO after name we can identify.
In any SSHR Pages, to find exactly the VO, Attribute Name, just download the Page (PG) from metadata and open it Jdev and view the field (vo, attribute).

metadata file path: 
/ora/VIS/apps/apps_st/appl/per/12.0.0/mds/selfservice/absence/webui
(or import the page)

Classes Path:
/ora/VIS/apps/apps_st/comn/java/classes/oracle/apps/per/selfservice/absence

View objects in OAF page1
Click on the VendorsVO so that we can see the query statement used for that VendorsVO, the below image shows the query of vendorsVO which is used in Register Supplier User OAF page.
Query in view objects
 
Step 2: Identify the page and copy or download it from Application Top.
Note that all the Pages and Regions will be there in Application Top and all the Controller (CO), Application Module (AM), View Object (VO) will be there in Java Top.

We can identify the page when we click on about this page, we can find one path which contains page name.
Identifying page name in OAF
The below image shows the page in Server Application Top, from that we need to copy the file.
Application top page in OAF
From the above Application Top we need to copy the “RegSuppUserPG.xml” page, note that the path may be different in your environment so check the path properly or concern the DBA for your required file to copy.
After copying the file move it to any existing project of OAF in desktop system for example see the below image it was moved into the following location in Desktop.
Note that we need to paste the page in Webui of JDeveloper
OAF desktop file location to move from application top
After copying open the JDeveloper so that we can see the copied page if JDeveloper is already open then refresh the JDeveloper so that the page will appear automatically. Select the page and we can see VO Name in the page structure.
For reference look at the below image:-
page structure of regsupplieruser in OAF extensions
Here in the above page structure we can identify that VO name is RegistrationVO but for Supplier Name we can see that Oracle OAF standard page used External VO hence we need to carry the External VO too from the server. The below image shows the finding process of External VO in the original page structure.
Finding LOV in OAF extensions
Now we can observe that the external LOV name is SupplierLOVRN, copy the SupplierLOVRN.xml file and paste it in the same location where we pasted the Register Supplier page. Refresh the JDevelper so that we can see the External LOV. Now in the external LOV we can identify the Exact VO which we need to extend to achieve our requirement.
The below image shows the finding process of exact VO from the External VO.
Finding exact VO in OAF extensions
Step 3: Now finally after finding the exact VO download the VO from the Java Top and create the directory structure whatever the VO had in myProjects of desktop JDeveloper folder.
Note that the following image shows the pos directory in Apps server is copying to apps folder in Desktop JDeveloper, here if we are copying from oracle on wards then the JDevelper will take heavy time for further process, and hence we need to download only the required things from the Server.
The below image screenshot is of WinSCP tool.
Copying the VO from the server in OAF
The below is image shows after copying and creating the same directory structure it looks like the following. N
File structure of VO in server and Jdeveloper
 
Step 4: After creating the directory structure now create one dummy workspace and Project in JDeveloper for VOExtension. And in the project creation process in step1 the default package name must be same as the path which we found in About this page. But here we need to remove the slash (/) symbol and in that place we have to keep dots (.), for reference have a look into the below image.
Default package in VO extension
After creating project check that in applications “oracle.apps.pos” structure is available if you didn’t find that package then open the project properties, select Project Content.
Project content in OAF Jdeveloper
Click on Add button and select the proper directory structure. Select it and click on Ok now check that the Oracle.apps.pos package will appear.
Adding directory in J developer project
 
Step 5:Copy the SQL Query from the VendorsVO and modify the Query in Toad or SQL Developer Tool or if any other and save the query and keep it aside. In query add the column name “vendor_type_lookup_code”. The modified SQL Query is shown below:
[sql]SELECT * FROM (Select vendor_id, vendor_name, segment1, vendor_type_lookup_code
               from PO_VENDORS where enabled_flag = ‘Y’
               and ( START_DATE_ACTIVE is null OR START_DATE_ACTIVE < SYSDATE )                 and ( END_DATE_ACTIVE is null OR END_DATE_ACTIVE > SYSDATE ) 
               and (vendor_type_lookup_code is null or vendor_type_lookup_code <> ‘EMPLOYEE’)) QRSLT
        ORDER BY upper(vendor_name)[/sql]
 
Step 6: Now create the New VO in custom directory. Extract the Package select Registration right click on it and then select New View Object… For reference look into the below image.
Creating new VO in custom package OAF
Some times while creating VO JDeveloper may show some dialogue box errors that required “so and so” file not found in the “package”, we can ignore these kind of messages click on OK but we must be very cautious about the missing files may be which are must required for our extension process.
The below image shows the package name specification process.
Package name specifications in OAF extensions
After that in the extends part click on the Browse button and then select the Original VO name that we can find in the directory structure which we copied and created same as it is in the server.
Selecting original VO in VO extension of OAF
The below sample image shows After selecting the Extends VO.
Browsing the original VO to extension in OAF
After clicking next to the query remove the existing SQL Query and place the modified SQL Query in which we added a coloumn “vendor_type_lookup_code” and finish the VO creation process.
Step 7: Now we need to substitute the new VO with the existing VO for that select Tools  -> Project Properties, for reference look into the below image.
Extract the Business Components, select Substitutions and then Select the proper VO from the available list and in Substitute list, for example as shown in the below image:
Selecting VO in substituitions
After adding into the project properties now we need to move the project folder from MyClasses to the server environment Classes Directory. Be cautious while moving the files from desktop to the server. Here no need to replace the existing files at all for the first time.

To generate the class Files, just right click the package and click rebuild.
The below figure shows the moving process from the desktop to the server.
Moving the file structure from desktop to server in OAF
After that run the jpxImport script, the below one is the sample JPXImport script.
java oracle.jrad.tools.xml.importer.JPXImporter $JAVA_TOP/xxvoextension/VOExtensionPrj.jpx -username apps -password apps -dbconnection "(description = (address_list = (address = (community = tcp.world)(protocol = tcp)(host =www.newtonapples.com/old)(port = 1521))) (connect_data = (service_name = naora1)))"

for Windows:
jpximport.bat D:\JDev_Home\jdevhome\jdev\myprojects\hrss_extensions.jpx -username apps -password apps -dbconnection "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.10)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=PROFFRD2)))"
After successfully running import script, now go to Functional Administrator, click on Core Service Tab and then select Caching Framwork -> Click on Clear All Cache button. We can even click on Clear All Statistics button if we want.

The below image shows the functional administrator page.
Clearing cache in functional administrator OAF
After that check whether the Extended VO is available or not in the About this page once the extended VO appears then now click on the LOV option of Supplier Name.
Click on “Personalize Supplier Table”.
After clicking on it create one item and select level as site and item type as Message Styled Text. We need to create one item because we modified VO and we added column to the VO but we not yet displayed it in OAF page so to display it in OAF page we need to create one item.
Here in View Instance we need to give the old VO name rather than the new VO name. For view attribute give the attribute name which is generated when we click on the Next button after modifying VO we will find the attribute name for Vendor_type_lookup_code that name we need to give here.
New item properties in VO extension OAF
Save the newly created item and now again click on the Supplier name so there fore here we go and we can find the Vendor Lookup Code which we created.
Item after extension of VO in OAF
So therefore finally we finished the VO Extension process in OAF.


Result in VO extension OAF