对于随后的所有编码的例子,假设下面是在该事件过程的顶部声明:
1
procedure event (event_name varchar2) is
2
form_name varchar2(30) :=
3
name_in(‘system.current_form’);
4
block_name varchar2(30) :=
5
name_in(‘system.cursor_block’);
6
begin
7![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/dot.gif)
8
end;
1.强制字段大写:
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
3
then
4
if (form_name = ‘APXVENDR’) then
5
app_item_property2.set_property(
6
‘VENDOR.NAME’,
7
CASE_RESTRICTION, UPPERCASE);
8
end if;
9
end if;
10
end;
2.更改字段提示:
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
3
then
4
if (form_name = ‘APXVENDR’) then
5
app_item_property2.set_property(
6
'vendor.name', PROMPT_TEXT,
7
'Supplier Name');
8
end if;
9
end if;
10
end;
3.更改按钮标签:
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
3
then
4
if (form_name = ‘APXVENDR’) then
5
app_item_property2.set_property(
6
'vendors.details', LABEL,
7
'More Details');
8
end if;
9
end if;
10
end;
4.更改字段背景颜色:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
3
then
4
if (form_name = ‘APXVENDR’and
5
block_name = ‘VENDOR’) then
6
app_item_property2.set_property(
7
'vendor.note', BACKGROUND_COLOR,
8
‘r255g255b0’); -- bright yellow
9
end if;
10
end if;
11
end;
5.隐藏字段:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
3
then
4
if (form_name = ‘APXVENDR’) then
5
app_item_property2.set_property(
6
'vendor.note', DISPLAYED,
7
PROPERTY_OFF); -- hide Notes field
8
end if;
9
end if;
10
end;
6.设置不可更新和插入:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
begin
2
if (event_name = ‘WHEN-NEW-BLOCK-INSTANCE’)
3
then
4
if (form_name = ‘APXVENDR’ and
5
block_name = ‘VENDOR’) then
6
set_block_property(block_name,
7
insert_allowed, property_false);
8
set_block_property(block_name,
9
update_allowed, property_false);
10
end if;
11
end if;
12
end;
7.添加菜单:
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’) then
3
if (form_name = ‘DEMXXEOR’) then
4
app_special2.instantiate(‘SPECIAL15’,
5
‘Print Order &Again’, ‘’, TRUE, ‘LINE’);
6
end if;
7
end if;
8
end;
As with the APP_SPECIAL routines, APP_SPECIAL2 routines support up to
45 entries spread among the Tools, Reports, and Actions menus, including
check boxes on the Tools menu. See your Oracle Applications Developer’s
Guide for more information.
8.切换工具菜单项:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
begin
2
if (event_name = ‘WHEN-NEW-BLOCK-INSTANCE’) then
3
if (form_name = ‘DEMXXEOR’ and
4
block_name = ‘ORDERS’) then
5
app_special2.enable(‘SPECIAL15’,
6
PROPERTY_ON);
7
elsif (form_name = ‘DEMXXEOR’ and
8
block_name = ‘LINES’) then
9
app_special2.enable(‘SPECIAL15’,
10
PROPERTY_OFF);
11
end if;
12
end if;
13
end;
9.为菜单添加逻辑:
1
begin
2
if (event_name = ‘SPECIAL15’) then
3
if (form_name = ‘DEMXXEOR’ and
4
block_name = ‘ORDERS’) then
5![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//* Add your Print Order logic here */
6
raise FORM_TRIGGER_FAILURE;
7
end if;
8
end if;
9
end;
10.要先测试函数or功能已定义:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
begin
2
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’) then
3
if (form_name = ‘DEMXXEOR’) then
4
if (FND_FUNCTION.TEST(
5
'DEM_DEMXXEOR_AUTHORIZED')) then
6![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**//* Add your logic here */
7
end if;
8
end if;
9
end if;
10
end;
11.如何在EVENT事件中调用外部SP:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
if FND_PROFILE.VALUE('USERNAME')='CUST01' then
2
custom01.event(event_name);
3![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/dot.gif)
4
elsif FND_PROFILE.VALUE('USERNAME')='CUST25' then
5
custom25.event(event_name);
6
Copyright © Oracle Corporation, 2000. All rights reserved.
7
Coding Events
8
Chapter 3 - Page 22
9
end if;
10
end event;
实例1:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1
Add the following code to your EVENT procedure:
2
procedure event(event_name varchar2) is
3
Copyright © Oracle Corporation, 2000. All rights reserved.
4
Coding Events
5
Chapter 3 - Page 31
6
form_name varchar2(30) :=
7
name_in('system.current_form');
8
block_name varchar2(30) :=
9
name_in('system.cursor_block');
10
begin
11
if (event_name = 'WHEN-NEW-FORM-INSTANCE') then
12
if (form_name = 'FNDSCAUS') then
13
app_item_property2.set_property(
14
'user.fax', DISPLAYED, PROPERTY_OFF);
15
-- hide the Fax field
16
app_item_property2.set_property(
17
'user.email_address',
18
CASE_RESTRICTION, UPPERCASE);
19
-- force E-Mail field to uppercase
20
app_item_property2.set_property(
21
'user.description',
22
REQUIRED, PROPERTY_ON);
23
-- make Description field required
24
app_item_property2.set_property(
25
'user.employee_name',
26
BACKGROUND_COLOR, 'r255g0b255');
27
-- make Person field magenta
28
app_item_property2.set_property(
29
'user.supplier_name',
30
PROMPT_TEXT, 'Vendor Name');
31
-- change prompt of Supplier field
32
end if;
33
end if;
实例2:
******