对于随后的所有编码的例子,假设下面是在该事件过程的顶部声明:
procedure event (event_name varchar2) is
form_name varchar2(30) :=
name_in(‘system.current_form’);
block_name varchar2(30) :=
name_in(‘system.cursor_block’);
begin

end;
1.强制字段大写:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
then
if (form_name = ‘APXVENDR’) then
app_item_property2.set_property(
‘VENDOR.NAME’,
CASE_RESTRICTION, UPPERCASE);
end if;
end if;
end;
2.更改字段提示:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
then
if (form_name = ‘APXVENDR’) then
app_item_property2.set_property(
'vendor.name', PROMPT_TEXT,
'Supplier Name');
end if;
end if;
end;
3.更改按钮标签:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
then
if (form_name = ‘APXVENDR’) then
app_item_property2.set_property(
'vendors.details', LABEL,
'More Details');
end if;
end if;
end;
4.更改字段背景颜色:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
then
if (form_name = ‘APXVENDR’and
block_name = ‘VENDOR’) then
app_item_property2.set_property(
'vendor.note', BACKGROUND_COLOR,
‘r255g255b0’); -- bright yellow
end if;
end if;
end;
5.隐藏字段:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’)
then
if (form_name = ‘APXVENDR’) then
app_item_property2.set_property(
'vendor.note', DISPLAYED,
PROPERTY_OFF); -- hide Notes field
end if;
end if;
end;
6.设置不可更新和插入:
begin
if (event_name = ‘WHEN-NEW-BLOCK-INSTANCE’)
then
if (form_name = ‘APXVENDR’ and
block_name = ‘VENDOR’) then
set_block_property(block_name,
insert_allowed, property_false);
set_block_property(block_name,
update_allowed, property_false);
end if;
end if;
end;
7.添加菜单:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’) then
if (form_name = ‘DEMXXEOR’) then
app_special2.instantiate(‘SPECIAL15’,
‘Print Order &Again’, ‘’, TRUE, ‘LINE’);
end if;
end if;
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.切换工具菜单项:
begin
if (event_name = ‘WHEN-NEW-BLOCK-INSTANCE’) then
if (form_name = ‘DEMXXEOR’ and
block_name = ‘ORDERS’) then
app_special2.enable(‘SPECIAL15’,
PROPERTY_ON);
elsif (form_name = ‘DEMXXEOR’ and
block_name = ‘LINES’) then
app_special2.enable(‘SPECIAL15’,
PROPERTY_OFF);
end if;
end if;
end;
9.为菜单添加逻辑:
begin
if (event_name = ‘SPECIAL15’) then
if (form_name = ‘DEMXXEOR’ and
block_name = ‘ORDERS’) then
/* Add your Print Order logic here */
raise FORM_TRIGGER_FAILURE;
end if;
end if;
end;
10.要先测试函数or功能已定义:
begin
if (event_name = ‘WHEN-NEW-FORM-INSTANCE’) then
if (form_name = ‘DEMXXEOR’) then
if (FND_FUNCTION.TEST(
'DEM_DEMXXEOR_AUTHORIZED')) then
/* Add your logic here */
end if;
end if;
end if;
end;
11.如何在EVENT事件中调用外部SP:
if FND_PROFILE.VALUE('USERNAME')='CUST01' then
custom01.event(event_name);

elsif FND_PROFILE.VALUE('USERNAME')='CUST25' then
custom25.event(event_name);
Copyright © Oracle Corporation, 2000. All rights reserved.
Coding Events
Chapter 3 - Page 22
end if;
end event;
实例1:
Add the following code to your EVENT procedure:
procedure event(event_name varchar2) is
Copyright © Oracle Corporation, 2000. All rights reserved.
Coding Events
Chapter 3 - Page 31
form_name varchar2(30) :=
name_in('system.current_form');
block_name varchar2(30) :=
name_in('system.cursor_block');
begin
if (event_name = 'WHEN-NEW-FORM-INSTANCE') then
if (form_name = 'FNDSCAUS') then
app_item_property2.set_property(
'user.fax', DISPLAYED, PROPERTY_OFF);
-- hide the Fax field
app_item_property2.set_property(
'user.email_address',
CASE_RESTRICTION, UPPERCASE);
-- force E-Mail field to uppercase
app_item_property2.set_property(
'user.description',
REQUIRED, PROPERTY_ON);
-- make Description field required
app_item_property2.set_property(
'user.employee_name',
BACKGROUND_COLOR, 'r255g0b255');
-- make Person field magenta
app_item_property2.set_property(
'user.supplier_name',
PROMPT_TEXT, 'Vendor Name');
-- change prompt of Supplier field
end if;
end if;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25103190/viewspace-733985/ ,如需转载,请注明出处,否则将追究法律责任。