1、FORM使用app_calculate.running_total汇总行金额,行上有编码重复验证。
情况一:当录入多个编码重复的行并保存时,报错,清除一个重复行再保存(头行金额一致),报错“编码重复”,再清除重复行,头上金额不减少。
情况二:失效清除按钮,当录入多个编码重复的行并保存时,报错,删除一个重复行再保存(头行金额一致),报错“编码重复”,再删除重复行(头行金额一致),保存,头金额重新又加上了已删除行金额,报错“编码重复”
汇总头行金额代码:
头汇总项:amount,amount_dis, amount_dis_rtot_db
bast_amount, base_amount_dis, base_amount_dis_rtot_db
行项: amount, amount_dis, amount_dis_rtot_db, amount_dis_rtot_old
bast_amount, base_amount_dis, base_amount_dis_rtot_db, base_ amount_dis_rtot_old
触发器:
from级:
POST-FORMS-COMMIT:
lines.running_total('POST-FORMS-COMMIT');
LINES.CHECK_LINES_DATE;
PRE-COMMIT:
lines.running_total('PRE-COMMIT');
update CUX_DOC_YSJH_HEADERS
set amount= nvl(:header.amount_dis,:header.amount),
base_amount = nvl(:header.base_amount_dis,:header.base_amount)
where header_id=:header.header_id;
头块:
POST-QUERY:
SELECT nvl(SUM(AMOUNT),0),SUM(BASE_AMOUNT)
INTO :HEADER.AMOUNT_dis,:HEADER.BASE_AMOUNT_dis
FROM CUX_DOC_YSJH_LINES t
WHERE t.header_id = :HEADER.header_id;
:HEADER.AMOUNT_dis_RTOT_DB:=:HEADER.AMOUNT_dis;
:HEADER.BASE_AMOUNT_dis_RTOT_DB:=:HEADER.BASE_AMOUNT_dis;
IF nvl(:PARAMETER.CUX_QUERY_ONLY,'NO') = 'YES' THEN
set_block_property('header',QUERY_ALLOWED , PROPERTY_FALSE);
END IF;
行块:
KEY-DELREC:
lines.running_total('KEY-DELREC');
Delete_Record;
KEY-DURREC:
duplicate_record;
lines.running_total('KEY-DUPREC');
:lines.SEQ_NO := :lines.SEQ_NO + 1;
WHEN-CLEAR-BLOCK:
lines.running_total('WHEN-CLEAR-BLOCK');
POST-QUERY:
app_folder.event('POST-QUERY');
app_globe.event('POST-QUERY');
:lines.amount_dis := :lines.amount;
:lines.amount_dis_RTOT_DB := :lines.amount;
:lines.base_amount_dis := :lines.base_amount;
:lines.base_amount_dis_RTOT_DB := :lines.base_amount;
lines.running_total( 'POST-QUERY' );
lines.control_dis('POST-QUERY');
KEY-CLRREC:
lines.running_total('KEY-CLRREC');
app_folder.event('KEY-CLRREC');
POST-INSERT:
lines.running_total('POST-INSERT');
PRE-RECORD:
lines.running_total('PRE-RECORD');
POST-UPDATE:
lines.running_total('POST-UPDATE');
PRE-INSERT:
:lines.amount := :lines.amount_dis;
:lines.base_amount := :lines.base_amount_dis;
LINES.CHECK_LINES_DATE;
PRE-UPDATE:
:lines.amount := :lines.amount_dis;
:lines.base_amount := :lines.base_amount_dis;
LINES.CHECK_LINES_DATE;
程序单元:
PROCEDURE running_total(event VARCHAR2) IS
BEGIN
app_calculate.running_total(event,'lines.amount_dis','header.amount_dis');
app_calculate.running_total(event,'lines.base_amount_dis','header.base_amount_dis');
END running_total;
PROCEDURE CHECK_LINES_DATE IS
L_CNT NUMBER;
L_CNT_F NUMBER; --统计是否有<0的对应发票
L_TYPE_ID varchar2(50);
BEGIN
SELECT COUNT(1)
into l_cnt
FROM (SELECT cdl.type_id, COUNT(*) cnt
--INTO l_type_id, l_cnt
FROM cux_doc_ysjh_lines cdl, cux_doc_ysjh_headers cdh
WHERE cdh.header_id = cdl.header_id
AND nvl(cdl.attribute2, 'Y') = 'N' --是否允许新增标识
AND cdh.header_id = :header.header_id
GROUP BY cdl.type_id
having COUNT(*)>1);
IF L_CNT >= 1 THEN
:HEADER.STATUS_DESC := '新建';
:HEADER.STATUS :='INCOMPLETE';
FND_MESSAGE.CLEAR;
FND_MESSAGE.SET_STRING('付款编码不允许有重复行录入.');
FND_MESSAGE.ERROR;
RAISE FORM_TRIGGER_FAILURE;
END IF;
END CHECK_LINES_DATE;