FORM开发
一、修改FORM级触发器
1.PRE-FORM
app_window.set_window_position('CUXCRVAS', 'FIRST_WINDOW');
2.WHEN-NEW-FORM-INSTANCE
FDRCSID('$Header: TEMPLATE.fmb 115.12 level:6 2013/11/05 10:00:48 pkm ship $');
APP_STANDARD.EVENT('WHEN-NEW-FORM-INSTANCE');
--
-- app_folder.define_folder_block('template test', 'folder_block', 'prompt_block', 'stacked_canvas', 'window', 'disabled functions');
-- app_folder.event('VERIFY');
--
cux_control.botton_control('when-new-form');
二、创建数据块 1.为QFIND快添加项
设置块和项的属性:
QFIND画布
修改块级触发器KEY-NXTBLK:
:parameter.G_query_find := 'TRUE';
app_find.find('CUX_CRVAL');
:parameter.G_query_find := 'FALSE';
分别编写以下触发器:
app_find.clear;
app_find.new('CUX_CRVAL');
:parameter.G_query_find := 'TRUE';
app_find.find('CUX_CRVAL');
:parameter.G_query_find := 'FALSE';
三、创建CUXCRVAS块
画布CUXCRVAS效果:
设置块和项属性
修改ITEM级触发器WHEN_CHECKBOX_CHANGED
BEGIN
IF :CUX_CRVAL.ATTRIBUTE1 IS NULL THEN
:CUX_CRVAL.END_DATE := NULL;
app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_FALSE);
ELSE
app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_TRUE);
app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_TRUE);
END IF;
END;
修改块级触发器:
1、QUERY_FIND
NULL;
APP_FIND.QUERY_FIND('CUXCRVAS','QFIND','QFIND');
2、PRE_INSERT
cux_private.per_insert;
3、PRE_UPDATE
cux_private.per_update;
4、PRE_DELETE
cux_private.per_delete;
5、PRE_QUERY
NULL;
IF :Parameter.G_query_find='TRUE' THEN
:CUX_CRVAL.CUSTOMER_ID:=:QFIND.CUSTOMER_ID;
--:CUX_CRVAL.CUSTOMER_NUMBER:=:QFIND.CUSTOMER_NUMBER;
--:CUX_CRVAL.CUSTOMER_NAME:=:QFIND.CUSTOMER_NAME;
:CUX_CRVAL.STATUS:=:QFIND.STATUS;
:Parameter.G_query_find:='FALSE';
END IF;
6、WHEN_NEW_RECORD_INSTANCE
APP_STANDARD.EVENT('WHEN-NEW-RECORD-INSTANCE');
cux_control.record_control;
四、LOV设置
五、修改程序单元
修改APP_CUSTOM包
package body app_custom is
procedure close_window(wnd in varchar2) is
/*
This procedure is called whenever the user closes a window, as
a result of the WHEN-WINDOW-CLOSED trigger firing. You are responsible
for supplying unqiue code that addresses the needs of each window, such as
deferring master-detail relations, or closing related windows.
Other windows that will be referenced into your form rely on the default
code at the beginning and end of this procedure - under no circumstances
should you modify that code.
*/
begin
/*
THE FOLLOWING CODE MUST NOT BE MODIFIED. It prevents windows from closing
while in enter-query mode.
*/
if (name_in('system.mode') = 'ENTER-QUERY') then
app_exception.disabled;
return;
end if;
/*
YOU MUST MODIFY THE FOLLOWING CODE to account for specific behaviors of your
form, including:
1. identifying the 'first window' of the form and treating
a close window on that window like a close form.
2. deferring master-detail relations for detail blocks that
exist in other windows.
3. closing other related windows.
The default code at the end of this procedure actually closes the window.
If you do that yourself in this code, issue a 'return;' at the end of
your logic for your specific windows.
*/
if (wnd = 'CUXCRVAS') then
app_window.close_first_window;
elsif (wnd = '<another window>') then
--defer relations
--close related windows
null;
elsif (wnd = '<yet another window>') then
--defer relations
--close related windows
null;
end if;
/*
THE FOLLOWING CODE MUST NOT BE MODIFIED. It ensures the cursor is not in
the window that will be closed (by moving it to the previous block if
needed), and actually closes the specified window.
*/
if (wnd = get_view_property(get_item_property(:SYSTEM.CURSOR_ITEM,
ITEM_CANVAS), WINDOW_NAME)) then
do_key('PREVIOUS_BLOCK');
end if;
hide_window(wnd);
end close_window;
procedure open_window(wnd in varchar2) is
/*
This procedure should be called from any code that could result
in a non-modal window being opened.
*/
begin
/*
YOU MUST MODIFY THE FOLLOWING CODE to account for specific behaviors of your
form, including:
1. Positioning the window to be opened
2. Resetting master-detail relations for blocks in the window
3. navigation to a block in that window
*/
if (wnd = '<a window>') then
--position the window
--reset master-detail relations
--navigate to a block in the window
null;
elsif (wnd = '<another window>') then
--position the window
--reset master-detail relations
--navigate to a block in the window
null;
elsif (wnd = '<yet another window>') then
--position the window
--reset master-detail relations
--navigate to a block in the window
null;
end if;
end open_window;
end app_custom;
编写CUX_CONTROL包
PACKAGE BODY cux_control IS
procedure summit is
begin
if :CUX_CRVAL.credit_values is null then
FND_MESSAGE.SET_STRING('信用额度不能为空!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
elsif :CUX_CRVAL.ATTRIBUTE1 ='Y' and :CUX_CRVAL.END_DATE IS NULL then
FND_MESSAGE.SET_STRING('请输入截至日期!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
elsif :CUX_CRVAL.ATTRIBUTE1 ='Y' and :CUX_CRVAL.credit_values = 0 then
FND_MESSAGE.SET_STRING('临时信用额度不能为0!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
ELSE
if :CUX_CRVAL.STATUS='已输入' then
:CUX_CRVAL.STATUS:='处理中';
if :CUX_CRVAL.ATTRIBUTE1 is null then
--FND_MESSAGE.DEBUG(:CUX_CRVAL.CREDIT_ID);
--FND_MESSAGE.DEBUG(:CUX_CRVAL.CUSTOMER_ID);
update cux_credit_control_all a
set a.STATUS='失效',a.active_flag='N',a.end_date=trunc(sysdate)
where (a.credit_id!=:CUX_CRVAL.CREDIT_ID or :CUX_CRVAL.CREDIT_ID is null)
and a.customer_id=:CUX_CRVAL.CUSTOMER_ID
and a.group_number=:CUX_CRVAL.group_number
and a.STATUS='处理中' and a.ATTRIBUTE1 is null ;
commit;
end if;
else
FND_MESSAGE.SET_STRING('当前记录不能提交!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
end if;
END IF;
/* set_block_property('CUX_CRVAL',UPDATE_ALLOWED,property_false);
set_block_property('CUX_CRVAL',DELETE_ALLOWED,property_false);*/
end summit;
procedure approve is
begin
if :CUX_CRVAL.STATUS='处理中' then
:CUX_CRVAL.STATUS:='生效';
:CUX_CRVAL.START_DATE:=trunc(sysdate);
:CUX_CRVAL.ATTRIBUTE2 := TO_CHAR(sysdate,'YYYY-MM-DD HH24:MI:SS');
if :CUX_CRVAL.ATTRIBUTE1 is null then
update cux_credit_control_all a
set a.STATUS='失效',a.active_flag='N',a.end_date=trunc(sysdate)
where a.credit_id!=:CUX_CRVAL.CREDIT_ID
and a.customer_id=:CUX_CRVAL.CUSTOMER_ID
and a.group_number=:CUX_CRVAL.group_number
and a.STATUS='生效'
and a.ATTRIBUTE1 is null ;
end if;
else
FND_MESSAGE.SET_STRING('当前记录不能审批!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
end if;
end approve;
procedure reject is
begin
if :CUX_CRVAL.STATUS='处理中' then
:CUX_CRVAL.STATUS:='拒绝';
:CUX_CRVAL.ATTRIBUTE2 := TO_CHAR(sysdate,'YYYY-MM-DD HH24:MI:SS');
else
FND_MESSAGE.SET_STRING('当前记录不能拒绝!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
end if;
end reject;
procedure botton_control(p_event in varchar2) is
v_user_id number;
v_approve_user_id number;
begin
if (p_event='when-new-form') then
:PARAMETER.P_USER_ID:=FND_GLOBAL.USER_ID;
v_approve_user_id:=fnd_profile.value('CUX_CREDIT_APPROVE_USER');
if :PARAMETER.P_USER_ID=v_approve_user_id then
app_item_property.set_property('BOTTON_CONTROL.SUMMIT',ENABLED,PROPERTY_FALSE);
app_item_property.set_property('BOTTON_CONTROL.APPROVE',ENABLED,PROPERTY_TRUE);
app_item_property.set_property('BOTTON_CONTROL.REJECT',ENABLED,PROPERTY_TRUE);
app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',INSERT_ALLOWED,PROPERTY_TRUE);
app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',UPDATE_ALLOWED,PROPERTY_TRUE);
else
app_item_property.set_property('BOTTON_CONTROL.SUMMIT',ENABLED,PROPERTY_TRUE);
app_item_property.set_property('BOTTON_CONTROL.APPROVE',ENABLED,PROPERTY_FALSE);
app_item_property.set_property('BOTTON_CONTROL.REJECT',ENABLED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',INSERT_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',UPDATE_ALLOWED,PROPERTY_FALSE);
end if;
end if;
end botton_control;
procedure record_control is
begin
if :CUX_CRVAL.STATUS='已输入' then
/* app_item_property.set_property('CUX_CRVAL.CUSTOMER_NUMBER', ENTERABLE,PROPERTY_ON);
-- app_item_property.set_property('CUX_CRVAL.CUSTOMER_NUMBER',UPDATE_ALLOWED,PROPERTY_TRUE);
app_item_property.set_property('CUX_CRVAL.CUSTOMER_NAME',ENTERABLE,PROPERTY_TRUE);
app_item_property.set_property('CUX_CRVAL.CREDIT_VALUES',ENTERABLE,PROPERTY_TRUE);
--set_block_property('CUX_CRVAL',UPDATE_ALLOWED,PROPERTY_TRUE); */
set_block_property('CUX_CRVAL',DELETE_ALLOWED,PROPERTY_TRUE);
if :CUX_CRVAL.ATTRIBUTE1 = 'Y' then
app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_TRUE);
app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_TRUE);
ELSE
app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_FALSE);
END IF;
null;
else
--set_block_property('CUX_CRVAL',UPDATE_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.CUSTOMER_NUMBER',UPDATE_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.CUSTOMER_NAME',UPDATE_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.CREDIT_VALUES',UPDATE_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_FALSE);
app_item_property.set_property('CUX_CRVAL.ATTRIBUTE1',UPDATE_ALLOWED,PROPERTY_FALSE);
set_block_property('CUX_CRVAL',DELETE_ALLOWED,PROPERTY_FALSE);
end if;
end ;
END cux_control;
编写CUX_EVENT包
PACKAGE BODY CUX_EVENT IS
PROCEDURE SUM_TRX_QTY IS
BEGIN
:BOTTON_CONTROL.SUM_TRX_QTY := 0;
GO_BLOCK('CUX_CRVAL');
first_record;
LOOP
if :CUX_CRVAL.STATUS='生效' and :CUX_CRVAL.ACTIVE_FLAG='Y' then
:BOTTON_CONTROL.SUM_TRX_QTY := :BOTTON_CONTROL.SUM_TRX_QTY +
nvl(:CUX_CRVAL.CREDIT_VALUES, 0);
end if;
IF :system.last_record = 'FALSE' THEN
----判断当前记录是否为最后一条
next_record;
ELSE
EXIT;
END IF;
END LOOP;
first_record;
END SUM_TRX_QTY;
END;
编写CUX_PRIVATE包
PACKAGE BODY cux_private IS
procedure per_insert is
begin
select cux_credit_control_all_s.NEXTVAL
into :CUX_CRVAL.CREDIT_ID
from dual;
FND_STANDARD.SET_WHO;
end per_insert;
procedure per_update is
begin
/* if :CUX_CRVAL.STATUS='生效' then
FND_MESSAGE.SET_STRING('当前记录不允许修改!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
else
FND_STANDARD.SET_WHO;
end if; */
FND_STANDARD.SET_WHO;
end per_update;
procedure per_delete is
begin
/* if :CUX_CRVAL.STATUS='生效' then
FND_MESSAGE.SET_STRING('当前记录不允许删除!');
FND_MESSAGE.ERROR;
RAISE Form_Trigger_Failure;
end if; */
null;
end per_delete;
END;
还没有评论,来说两句吧...