Thursday May 10, 2012

Implement Master Detail Relationship in OAF Page

Let us try to implement Master Detail Relationship in advanceedTable. We will create two tables master table and child table. Both have relationship with each other with Column1

 

(Note - Column1 is a primary key in both tables)

 

1. Create a New OA Workspace and Empty OA Project

File> New > General> Workspace Configured for Oracle Applications

File Name -- MasterDetailProj

Project Name – MasterDetailDemo

Default Package -- prajkumar.oracle.apps.fnd.masterdetaildemo

 

2. Create Application Module AM

MasterDetailDemo right click > New > ADF Business Components > Application Module

Name -- MasterdetailDemoAM

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server

Check Generate JavaFile(s)

 

3. We need two tables one table will be act as Master table and second table will be act as Child or detail table. Lets Create two tables

-- Master Table

CREATE TABLE master_table_demo
(   -- ---------------------  
    -- Data Columns
    -- ---------------------
    Column1                     VARCHAR2(100),
    Column2                     VARCHAR2(100), 
    -- ---------------------- 
    -- Who Columns 
    -- ---------------------- 
    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
);

 

-- Detail Table

CREATE TABLE detail_table_demo
(   -- ---------------------  
    -- Data Columns
    -- ---------------------
    Column1                     VARCHAR2(100),
    Column2                     VARCHAR2(100), 
    -- ---------------------- 
    -- Who Columns 
    -- ---------------------- 
    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
);

 

Note – Consider Master Table is Linked to Detail Table with Column1

 

4. Lets put some data in the tables

-- Insert Data into Master Table

INSERT INTO master_table_demo VALUES ( ‘VAL1’, ‘VAL2’, SYSDATE, 0, SYSDATE, 0, 0);

INSERT INTO master_table_demo VALUES ( ‘VAL3’, ‘VAL4’, SYSDATE, 0, SYSDATE, 0, 0);

 

-- Insert Data into Detail Table

INSERT INTO detail_table_demo VALUES ( ‘VAL1’, ‘VAL6’, SYSDATE, 0, SYSDATE, 0, 0);

INSERT INTO detail_table_demo VALUES ( ‘VAL3’, ‘VAL8’, SYSDATE, 0, SYSDATE, 0, 0);

 

5. Create a New Entity Object (EO) for Master Table

Right click on MasterDetailDemo > New > ADF Business Components > Entity Object

Name – MasterEO

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.schema.server

Database Objects -- master_table_demo

 

Note -- Make Column1 as a primary key

 

 

Check the Accessors, Create Method, Validation Method and Remove Method

 

6. Create a New Entity Object (EO) for Detail Table

Right click on MasterDetailDemo > New > ADF Business Components > Entity Object

Name – DetailEO

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.schema.server

Database Objects -- detail_table_demo

 

Note -- Make Column1 as a primary key

 

 

Check the Accessors, Create Method, Validation Method and Remove Method

 

Note – Column1 in both tables is common Column to make parent child relationship

 

7. Lets Create View Object for Master Table

Right click on MasterDetailDemo > New > ADF Business Components > View Object

Name -- MasterVO

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server

In Step2 in Entity Page select MasterEO and shuttle them to selected list

Create transient item by clicking on New

Name – DetailFlag

Type -- Boolean

 

 

In Step3 in Attributes Window select columns Column1, Column2, DetailFlag and shuttle them to selected list

In Java page deselect Generate Java file for View Object Class: MasterVOImpl

 

8. Lets Create View Object for Detail Table

Right click on MasterDetailDemo > New > ADF Business Components > View Object

Name -- DetailVO

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server

In Step2 in Entity Page select DetailEO and shuttle them to selected list

In Step3 in Attributes Window select columns Column1, Column2 and shuttle them to selected list

In Java page deselect Generate Java file for View Object Class: DetailVOImpl

 

9. Create View Link Add Your View Object to Root UI Application Module

Right click on MasterDetailDemo > New > ADF Business Components > View Link

Name – MasterdetailDemoVL

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.server

 

 

10. Add Your View Object to Root UI Application Module

Right click on MasterdetailDemoAM > Application Modules > Data Model >

Select MasterVO, DetailVO via ViewLink, DetailVO and shuttle to Data Model list

 

 

11. Create a New Page

Right click on MasterdetailDemo > New > Web Tier > OA Components > Page

Name -- MasterdetailDemoPG

Package -- prajkumar.oracle.apps.fnd.masterdetaildemo.webui

 

12. Select MasterdetailDemoPG and go to the strcuture pane where a default region has been created

 

13. Select region1 and set the following properties:

ID -- PageLayoutRN

Region Style -- PageLayout

AM Definition -- prajkumar.oracle.apps.fnd.masterdetaildemo.server.MasterdetailDemoAM

Window Title – Master Detail Demo Page Window

Title – Master Detail Demo Page Header

Auto Footer – True

 

14. Add a New Region MainRN

Select PageLayoutRN right click > New > Region

ID -- MainRN

Region Style – header

 

15. Create a Master Table Region

Select MainRN > New > Region

ID – MainTableRN

Region Style -- advancedTable

View Instance -- MasterVO1

Detail View Attribute – DetailFlag

Child View Attribute -- Column1

View Link Instance -- MasterdetailDemoVL1

Width – 100%

Rendered – True

 

16. Create Columns and their items for MainTableRN

Create Column1

Select MainTableRN > New > column

Select column1 > New > Item

ID – item1

Item Style – messageStyledText

View Attribute – Column1

 

Create Column2

Select MainTableRN > New > column

Select column2 > New > Item

ID – item2

Item Style – messageStyledText

View Attribute – Column2

 

17. Create a Detail Region

Select MainTableRN > New > detail

A new Region will be get created under detail set following properties for that region

ID – DetailRN

Region Style – header

 

18. Create a DetailTable Region

Select DetailRN > New > Region

For New region set following Properties

ID – DetailTableRN

Region Style – advancedTable

View Instance -- DetailVO2

View Link Instance -- MasterdetailDemoVL1

Width – 100%

Rendered – True

 

19. Create Columns and their items for DetailTableRN

Create Column3

Select DetailTableRN > New > column

Select column3 > New > Item

ID – item3

Item Style – messageStyledText

View Instance – DetailVO2

View Attribute – Column1

 

Create Column4

Select DetailTableRN > New > column

Select column4 > New > Item

ID – item4

Item Style – messageStyledText

View Instance – DetailVO2

View Attribute – Column2

 

20. Add Controller for Page MasterdetailDemoPG Select PageLayoutRN right click Set New Controller

Package Name -- prajkumar.oracle.apps.fnd.masterdetaildemo.webui

Class Name -- MasterdetailDemoCO

Set Following Code in CO

 

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import prajkumar.oracle.apps.fnd.masterdetaildemo.server.MasterdetailDemoAMImpl;

...

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processRequest(pageContext, webBean);

 MasterdetailDemoAMImpl AM =
  (MasterdetailDemoAMImpl)pageContext.getApplicationModule(webBean);

 pageContext.writeDiagnostics(this, "Calling Method", 1);

 AM.MasterDetails(pageContext,webBean);
}

 

21. Add Following Code in your AMImpl Class (MasterdetailDemoAMImpl.java)

 

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

...

public void MasterDetails(OAPageContext pageContext,OAWebBean webBean) 

 MasterVOImpl pvo = getMasterVO1(); 
        pvo.executeQuery(); 
}

22. Final Structure pane will look like following picture

 

23. Congratulation you have successfully finished. Run Your MasterdetailDemoPG page and Test Your Work

 

 

 

About

Welcome to My Oracle World Puneet Rajkumar

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today