Saturday, April 8, 2017

Upload csv file using oracle OAF


We will perform the below listed task in order to complete our assignment

1. Create Object(Table or Tables)
2. Create Application Module
3. Create EO
4. Create VO
5  Create Page

6. Create Controller
7. Test Page

--------------------------------------------------

Create table.

create table apps.xx_import_csv_data
(
  column1            varchar2(100 byte),
  column2            varchar2(100 byte),
  column3            varchar2(100 byte),
  column4            varchar2(100 byte),
  column5            varchar2(100 byte),
  last_update_date   date                       not null,
  last_updated_by    number                     not null,
  creation_date      date                       not null,
  created_by         number                     not null,
  last_update_login  number
)
tablespace apps_ts_tx_data
pctused    0
pctfree    10
initrans   1
maxtrans   255
storage    (
            initial          128k
            next             128k
            maxsize          unlimited
            minextents       1
            maxextents       unlimited
            pctincrease      0
            buffer_pool      default
           )
logging
nocompress
nocache
noparallel
monitoring;

-------------------------------------------

Create Application Module

Navigation:
Right Click on Project -->New -->Business Tier -->ADF Business Components -->Application Module --> Press OK button.

New Window will appear to you which contains 5 steps

Step 1:
Specify Package called path where you want to save your application Module
E.g : Package: oracle.apps.fnd.server
Specify package name
E.g: Name:ImportcsvAM
Press Next Button
Step 2: Make sure in Data Model your Application Module is appearing and Press Button Next
Step 3:Press Button Next
Step 4: Check the Generate Java File(s) checkbox in Application Module  Class: ImportcsvAMImpl to generate the ImportcsvAMImpl java class. (It is already checked by default.)
Step 5: In Finish window, Press Finish Button

------------------------------------------- 
 
Create Entity Object

Navigation:
Right Click on Project -->New -->Business Tier -->ADF Business Components -->Entity Object --> Press OK button.

New Window will appear to you which contains 6 steps

Step 1: Specify the Entity Object Name
 E.g : ImportcsvEO
 Specify Package or Path oracle.apps.fnd.schema
Select Database object 
E.g: XX_IMPORT_CSV_DATA
Press Button Next
Step 2:  Press Button Next
Step 3: Press Button Next 
Now popup message will appear front of you as we did not define any primary key. Therefore, it will consider ROWID as primary key. Press Yes
Step 4: Check Create Method, Remove Method and  Validate Method
Press Button Next.
Step 5: Here you have a option to VO belongs to EO but we will not create and we will Press Button Next.
Step 6: In Finish window, Press Finish Button.

------------------------------------------- 
 
Create View Object

Navigation:
Right Click on Project -->New -->Business Tier -->ADF Business Components -->View Object --> Press OK button.

New Window will appear to you which contains 8 steps
Step 1:  Specify the View Object Name
 E.g : ImportcsvVO
 Specify Package or Path oracle.apps.fnd.server
select Radio Button Updatable Access through Entity Objects
Press Button Next
Step 2: In Available list go to  Oracle.apps.fnd.schema and shuffle ImportcsvEO to selected list
Press Button Next
Step 3: Shuffle the required columns to selected list and Press Button Next
Step 4: Press Button Next
Step 5: Press Button Next
Step 6: Press Button Next 
Step 7: Check the checkbox View Row Class: ImportcsvVORowImpl for both the Generate Java File and Accessors checkbox
Step 8: In Finish window, Press Finish Button.


Linking the view object to the application module(VO to AM)
   To link the view object to the application module, perform the following steps:
  1. In the Application Navigator tab, double-click the ImportcsvAM
  1. In the Application Module Editor select the Data Model node. 
  2. Expand the oracle.apps.fnd.server package, and click on the ImportcsvVO view object. 
  3. Shift the ImportcsvVO from Available View Objects: to Data Model: by clicking on the > button
------------------------------------------- 

Create Page 

Right Click on Project -->New -->Web Tier -->OA Components -->Page --> Press OK button.

New Window will appear, here you need to Name your page and specify package.
Name: ImportcsvPG
Package: oracle.apps.fnd.webui
Press Buttons OK 

Renaming the default region (PG)
  1. In the Application Navigator tab, click on the ImportcsvPG.xml page
  2. In the Structure pane, click on the item ImportcsvPG --> region1 node.
  3. Now in the Property Inspector, set the following properties                                                              ID: PageLayoutRN
    AM Definition: oracle.apps.fnd.server.ImportcsvAM
    Window Title: Import CSV File Window
    Title: Import CSV File           
  4. Click on the Save All button from the toolbar. Run the page    
Adding a region (RG)

  1. Click the ImportcsvPG.xml in the Applications Manager and the page
    components will appear in the Structure pane.
  2. In the Structure pane, right-click PageLayoutRN and select New | Region from
    the pop-up menu.
  3. In the Property Inspector, set the following properties:
    ID: ImportcsvRN
    Region Style: defaultSingleColumn
  4. Click on the Save All button from the toolbar.
Adding item to hold path

Navigation:
Right Click on PagePayoutRN -->New -->Item


Setting item properties

In the Structure pane, click on the Item attribute and set the following properties:
ID: MessageFileUpload
Item Style: MessageFileUpload 

Adding item for GO Button


Navigation:
Right Click on PagePayoutRN -->New -->Item


Setting item properties

In the Structure pane, click on the Item attribute and set the following properties:
ID: Go
Item Style: SubmitButton
Attribute Set :/oracle/apps/fnd/attributesets/Buttons/Go

Create Controller
 
Navigation:
Right Click on PagePayoutRN -->Set New Controller

New Window will appear to you, you need to specify Package and Name
Package: oracle.apps.fnd.webui
Name: ImportcsvCO

Add below listed code in processFormRequest

       OAApplicationModule am = (OAApplicationModule) pageContext.getApplicationModule(webBean);

 OAViewObjectImpl vo =  
       (OAViewObjectImpl)am.findViewObject("ImportcsvVO1"); 
 OAViewObjectImpl csvVO =  
       (OAViewObjectImpl)am.findViewObject("ImportcsvVO1"); 
     if (pageContext.getParameter("Go") != null) { 
       //Get Data of uploaded CSV file 
       DataObject csvUploadData =  
         pageContext.getNamedDataObject("MessageFileUpload"); 
       //Declare Variable that will be used in reading uploaded file 
       String fileName    = null; 
       String contentType = null; 
       Long fileCapacity  = null; 
       BlobDomain uploadStream = null; 
       BufferedReader inReader = null; 
       try { 
         fileName =  
             (String)
csvUploadData.selectValue(null, "UPLOAD_FILE_NAME"); 
         contentType =  
             (String)
csvUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE"); 
         uploadStream =  
             (BlobDomain)
csvUploadData.selectValue(null, fileName); 
         inReader =  
             new BufferedReader(new InputStreamReader(uploadStream.getBinaryStream())); 
         fileCapacity = new Long(uploadStream.getLength()); 
       } catch (NullPointerException ex) { 
         throw new OAException("Please Select an CSV File to Upload it to Database!!!",  
                    OAException.ERROR); 
       } 
       try { 
         String wholeLine = ""; 
         long counter = 0; 
         String[] seperatedCells; 
         while (((wholeLine = inReader.readLine()) != null))
         { 
           //Split the deliminated data and 
           if (wholeLine.trim().length() > 0) { 
             //split whole line to cells 
             seperatedCells = wholeLine.split(","); 
           
             Row row = vo.createRow();
             vo.insertRow(row);
             row.setNewRowState(Row.STATUS_INITIALIZED);
           
              row.setAttribute("Column1",seperatedCells[0]); 
              row.setAttribute("Column2", seperatedCells[1]); 
              row.setAttribute("Column3",seperatedCells[2]); 
              row.setAttribute("Column4", seperatedCells[3]); 
              row.setAttribute("Column5", seperatedCells[4]);
           } 
         }
       } catch (IOException e) { 
         throw new OAException(e.getMessage(), OAException.ERROR); 
       }
       
         am.getTransaction().commit();
         pageContext.forwardImmediately(
          "OA.jsp?page=/oracle/apps/fnd/webui/ImportcsvPG",
           null, OAWebBeanConstants.KEEP_MENU_CONTEXT,
           null,
           null,
           true,
           OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
        
       throw new OAException("CSV File Uploaded SuccessFully!!!",  
                  OAException.CONFIRMATION); 
     } 


------------------------------------------- 

Test Page

Navigation:

Right Click on ImportcsvPG -->Run 



Wednesday, April 5, 2017

How To Remove the 'Do you want to save changes?

if :System.Block_Status in( 'NEW' , 'CHANGED') then
    Clear_Block(DO_COMMIT);
      else
   Clear_Block(no_validate);   
end if;

Sunday, March 26, 2017

jbo-25058 error in oaf

1. Copy View Link from Master Region View Link Instance


2. Paste it in Details Region View Link Instance


Thursday, March 9, 2017

Application Module not displaying in projects list

Go to
   Tools --> Projects Properties  --> Project Content --> Jave Content
   Add the path where you set your package e.g C:\jdev\jdevhome\jdev\myproject
   Go to Exclude tab select path, press button remove and finally press button OK.

Saturday, March 4, 2017

Launching an Oracle E-Business Suite Form From a Submit Button in an OA Framework page

If you wish to launch an Oracle E-Business Suite form from a submit button in an OA Framework page, you must use the OAPageContext.forwardImmediatelyToForm(String url) method from oracle.apps.fnd.framework.webui.OAPageContext. An example of how to use this API is shown in the code sample below:

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if (pageContext.getParameter("Apply")!=null)    
{  
String destination =      "form:SYSADMIN:SYSTEM_ADMINISTRATOR:STANDARD:FND_FNDMNMNU";   pageContext.forwardImmediatelyToForm(destination);
}
}

Tuesday, December 13, 2016

Develop Search Screen / Search Page using Oracle OAF


The search page we are going to create/ developing based upon view only, as we are not going to perform any database transaction. Therefore we don' t need to create an entity object. 

In order to create search page first we need to perform following tasks.
  1. Creating an application module (AM)  
  2. Creating a view object (VO) 
  3. Linking VO to AM 
  4. Testing AM 
Creating an application module (AM)
  1. Right-click OAMujahidPacktProject project in the navigator and select New from the pop-up menu.
  2. Navigate to Business Tier
  3. ADF Components and select Application Module.
  4. Click on Button OK. Welcome page will display, click Next Button.
  5. In Step 1 of 4, enter the following details:                                                                 Package: oracle.apps.fnd.emp.server Name: EmpSearchAM
  6. In Step 2 of 4, click Next Button. 
  7. In Step 3 of 4, click Next Button. 
  8. In Step 4 of 4, check the Generate Java File(s) checkbox in Application     Module  Class: EmpSearchAMImpl to generate the EmpSearchAMImpl java class. (It is already checked by default.)
  9. In the Finish window, select the Finish Button. 
  10. Click Save All Button from the toolbar.


Creating a view object (VO)
  1. Right-click the OAMujahidPacktProject.jpr and select New from the pop-up menu. 
  2. Navigate to Business Tier --> Adf Business Components And Select View Object. 
  3. Click on OK. 
  4. In Step 1 of 7, enter the following details:
    Package: oracle.apps.fnd.emp.server
    Name: EmpSearchVO
  5. Select the Rows Populated by a SQL Query, with: radio button and select the
    Read-only Access radio button as shown in the following screenshot:

  1. Click Next.
  2. In Step 2 of 7, enter the following query in the Query Statement field:
     select * from XXHR_EMP_SEARCH_VL
     Note: if view does not exist then create it 
  3. Click the Test button to test the query (click on OK when prompted for the
    username and password apps/<apps>).

  1. Click on OK when the Query is valid message is displayed.
  2. Click on Next.
  3. In Step 3 of 7, click on Next.
  4. In Step 4 of 7, click on Next.
  5. In Step 5 of 7, click on Next.
  6. In Step 6 of 7, select the Never radio button in Updatable as shown in the following
    screenshot, and then click Next:


  1. In Step 7 of 7, uncheck the Generate Java File checkbox in View Object Class: EmpSearchVOImpl.
  2. Check the checkbox View Row Class: EmpSearchVORowImpl for both the Generate Java File and Accessors checkboxes, as shown in the following screenshot:
  1. After completing Step 7 of 7, click on Next.
  2. In the summary page, click on Finish.
  3. Click the Save All button from the toolbar.
Linking the view object to the application module(VO to AM)
   To link the view object to the application module, perform the following steps:
  1. In the Application Navigator tab, double-click the EmpSearchAM application
module in the OAPacktProject --> Application Sources -->
oracle.apps.fnd.emp.server package.
  1. In the Application Module Editor select the Data Model node. 
  2. Expand the oracle.apps.xxhr.emp.server package, and click on the EmpSearchVO view object. 
  3. Shift the EmpSearchVO from Available View Objects: to Data Model: by clicking on the > button as shown in the following screenshot:
  1. Click on OK.
  2. Click the Save All button from the toolbar.  
Testing the application module (AM)
  1. In JDeveloper, right-click the EmpSearchAM application module.
  2. Select Test from the pop-up menu.
  3. Click on the Connect button when the following Oracle Business Component
  4. Browser - Connect window appears:


  1. After a short while, the Oracle Business Component Browser (Local) window will appear.
  2. Double-click on the EmpSearchVO1 node and the browser will bring back data from the view object as shown in the following screenshot:

Creating the view layer for a query page
We have created our application module and successfully tested it, now we are going to create our user interface. We will create a page that allows us to query data based upon the attributes in our application module.
Creating Page
  1. In the Application Navigator tab, right-click on OAMujahidPacktProject.
  2. Select New from the pop-up menu.
  3. In the New Gallery window, navigate to Web Tier | OA Components and select Page from the Items: list as shown in the following screenshot:
     

  4. In the New Page window, set the following page details:
    Name: EmpSearchPG
    Package: oracle.apps.fnd.emp.webui
  5. Click on the OK button.
Renaming the default region (PG)
  1. In the Application Navigator tab, click on the EmpSearchPG.xml page
  2. In the Structure pane, click on the item EmpSearchPG | region1 node.
  3. Now in the Property Inspector, set the following properties                                      ID: PageLayoutRN
    AM Definition: oracle.apps.xxhr.emp.server.EmpSearchAM
    Window Title: Employee Search Window
    Title: Employee Search                                                                                                A summary of the steps is displayed in the following screenshot:
  4. Click on the Save All button from the toolbar. Run the page
          In the Application Navigator tab, right click the EmpSearchPG.xml page and
          select Run from the pop-up menu.

The following page will appear with an empty Employee Search region, as we have not added  any items to the page just yet. You can see that the page automatically inherits the Oracle EBS branding, look, and feel of other OA Framework pages.


Adding a query region (RG)
  1. Click the EmpSearchPG.xml in the Applications Manager and the page
    components will appear in the Structure pane.
  2. In the Structure pane, right-click PageLayoutRN and select New | Region from
    the pop-up menu.
  3. In the Property Inspector, set the following properties:
    ID: EmpQueryRN
    Region Style: query
    Construction Mode: resultsBasedSearch
    Include Simple Panel: True
    Include Views Panel: True
    Include Advanced Panel: True
  4. Click on the Save All button from the toolbar.

Adding a results region (RG) using a wizard
  1. Right-click on EmpQueryRN in the Structure pane, and select New | Region
    Using Wizard from the pop-up menu.
  2. In Step 1 of 4, select the oracle.apps.fnd.emp.server.EmpSearchAM
    application module from the drop-down list.
  3. Click on EmpSearchVO1 from the Available View Usages pane, and click on Next.
  4. In Step 2 of 4, set the values as required (No need to add WHO columns)
  5. In Step 3 of 4, shift the following attributes from the Available View Attributes to
    the Selected View Attributes pane by clicking on the > button:
  6. In Step 4 of 4, set the following values
  7. Click on Next and then Finish.
  8. In the Structure pane, click on the EmpResultsRN and set the following properties
    in the Property Inspector
          Width: 100%
          User Personalization: True
          Additional Text: Employee Search Results

Setting item properties
  1. In the Structure pane, click on the FullName attribute and set the following properties:
  2. Search Allowed: True
    Sort Allowed: yes
  3. In the Structure pane, click on the EmployeeNumber attribute and set the following properties:
  4. Search Allowed: True
    Sort Allowed: yes
    Initial Sort Sequence: first
  5. In the Structure pane, click on the MgrFullName attribute and set the following properties:
  6. Search Allowed: True
    Sort Allowed: yes
  7. In the Structure pane, click on the MgrEmployeeNumber attribute and set the following properties:
  8. Search Allowed: True
    Sort Allowed: yes
  9. Click the Save All button from the toolbar.
Testing the page

  1. Right-click on the EmpSearchPG.xml page and select Run from the pop-up menu.
  2. Enter some search criteria in the Simple Search parameters region, and click on
    the Go Button.