Thursday, September 11, 2008

Master Detail Forms


1) Create Two Tables (With Parent / Child relationships)

a) Create table orders
(order_no number(10),
custoner varchar2(20),
order_date date)
/
b) Create table lines
( line_no number(10),
order_no number(10),
item varchar2(20),
qty number(10),
price number(10),
amount number(10))
/

2) Alter the table structures and primary and foreign keys
Alter table orders add constraint orders_pk primary key (order_no);
Alter table lines add constraint lines_fk foreign key (order_no) references orders (order_no);

3) Create public synonyms for the tables.
4) Register two tables with constraints information.
5) Open form builder software.
6) Open template.fmb file.
7) Save as è TETMADET.fmb
8) Change form module name as form name.
9) Delete default blocks , canvasses and windows.
10) Create two windows , two canvasses
Window1 : Orders
Window2 : Lines
Canvas1 : Orders
Canvas2 : Lines

11) Assign Canvasses to Windows.
12) Assign Windows to Canvasses.
13) Assign property classes to windows and canvasses.
14) Create Two Blocks
Block1 : Orders Type : Form
Block2 : Lines Type : Tabular No of Records : 5

15) Define master detail block relationship between two blocks .
Relationship Name : Orders_Lines

16) Create a Control Block
17) Create a Check box on detail window/ detail canvas
Block => Control
Name => Orders_lines (Same as your master detail relationship name)
Checked value => Immediate
Unchecked Value => Deferred
Default => Immediate

18) Create a Push button in Master Window / Master Canvas
Name : LINES
Label : Lines ..
Block => Control

19) Assign Text Item property class to all text items on Orders and Lines block.
20) Set Module / Form Level properties
First navigation data block => Orders
Console Window => Orders

21) Modify App_custom Package
Close window procedure
If ( wnd = ‘Orders’) then
App_window.close_first_window;
Elsif (wnd = ‘Lines’) then
App_window.set_coordination(‘WHEN-WINDOW-CLOSED’, :CONTROL.ORDER_LINES (CHECKBOX) , ‘ORDERS_LINES’ (RELATIONSHIP NAME) );
End if;

Open Window Procedure
If (wnd = ‘Orders’) then
Go_block (‘ Orders’) ;
Return;
If (wnd = ‘Lines’) then
App_window.set_coordination (‘ OPEN-WINDOW’, :CONTROL,ORDERS_LINES , ‘ORDERS_LINES’);
Go_block (‘ Lines’);
End if;

22) Create a program unit
Name : Control
Type : Package Spec
Procedure Lines (Event In Varchar2) ;
Procedure Orders_Lines ( Event In Varchar2);

23) Create a program unit
Name : Control
Type : Package Body
Procedure Lines (Event In Varchar2) is
Begin
If (event = ‘ WHEN – BUTTON – PRESSED’ ) then
App_custom.open_window (‘Lines’);
Return;
End if;
End Lines;

Procedure Orders_Lines ( Event In Varchar2) then
Begin
If (Event = ‘ WHEN – CHECKBOX – CHANGED’) then
End if ;
End order_lines;

24) In control block write a WBP trigger on Lines Button.
Control . Lines ( ‘WHEN – BUTTON – PRESSED’);


25) In control block write a WCC trigger on Orders_Lines checkbox.
Control.orders_lines(‘WHEN- CHECKBOX – CHANGED’);

26) Modify PRE – FORM trigger
APP_WINDOW.SET_WINDOW_POSITION(‘ORDERS’,NULL,’ORDERS);

27) Save and Compile .
28) Register the form.

1 comment:

Unknown said...
This comment has been removed by the author.