CUSTOM.PLL的使用
在开发中对系统标准form的修改一般不建议修改系统原有FORM,对所需要修改的内容一般写在CUSTOM.PLL里即可,应为每个form运行的时候都会调用CUSTOM.PLL具体概念性东西可参考网上资料,很多的这里不再重述,只针应用做介绍
一,开发对象:程序 PROCEDURE event(event_name VARCHAR2);
二.判断在哪里触发
举例
IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-FORM-INSTANCE' THEN
--SET_MENU_ITEM_PROPERTY('SPECIAL.MENU15',LABEL,'自动创建');
--FND_MESSAGE.DEBUG('WHEN-NEW-FORM-INSTANCE');
set_menu_item_property('FILE.SAVE', enabled, PROPERTY_ON);-- able save menu
app_special2.instantiate('SPECIAL13', special_menu_name13, NULL, TRUE); --添加菜单API
app_special2.instantiate('SPECIAL14', special_menu_name14, NULL, TRUE); --添加菜单API
app_special2.instantiate('SPECIAL15', special_menu_name15, NULL, TRUE); --添加菜单API
RETURN;
END IF;
IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-ITEM-INSTANCE' /*AND
block_name = 'INV_SUM_FOLDER'*/ THEN
IF name_in('INV_SUM_FOLDER.QUICK_PO_NUMBER') IS NULL THEN
set_item_property('INV_SUM_CONTROL.MATCH', enabled, property_false);
ELSE
set_item_property('INV_SUM_CONTROL.MATCH', enabled, property_true);
END IF;
--IF :SYSTEM.FORM_ATATUS = 'NEW' OR :SYSTEM.FORM_ATATUS = 'CHANGED' THEN
--V_STATUS := SYSTEM.BLOCK_ATATUS;
--FND_MESSAGE.DEBUG('SYSTEM.BLACK_ATATUS');
-- END IF;
V_INVOICE_ID := NAME_IN('INV_SUM_FOLDER.INVOICE_ID');
SELECT COUNT(*)
INTO V_COUNT
FROM AP_INVOICE_LINES_ALL L
WHERE l.invoice_id = V_INVOICE_ID
AND L.PO_LINE_ID IS NOT NULL
AND L.amount <> 0;
--FND_MESSAGE.DEBUG(V_INVOICE_ID||'---'||V_COUNT);
IF V_COUNT = 0 THEN
app_special.enable('SPECIAL15', property_OFF);
ELSE
app_special.enable('SPECIAL15', property_on);
END IF;
RETURN;
END IF;
IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-BLOCK-INSTANCE' THEN
--SET_MENU_ITEM_PROPERTY('SPECIAL.MENU15',LABEL,'自动创建');
app_special.enable('SPECIAL13', property_on);
app_special.enable('SPECIAL14', property_on);
app_special.enable('SPECIAL15', property_on);
RETURN;
END IF;
三.获取FORM里面ITEM的值
V_INVOICE_ID := NAME_IN('INV_SUM_FOLDER.INVOICE_ID');
四.工具里面菜单开发
定义变量
form_name VARCHAR2(30) := name_in('system.current_form');
block_name varchar2(30) := name_in('system.cursor_block');
special_menu_name13 VARCHAR2(2000);
special_menu_name14 VARCHAR2(2000);
special_menu_name15 VARCHAR2(2000);
菜单名称
special_menu_name13 := '返利';
special_menu_name14 := '订单';
special_menu_name15 := '更新';
初始化菜单
IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-FORM-INSTANCE' THEN
--SET_MENU_ITEM_PROPERTY('SPECIAL.MENU15',LABEL,'自动创建');
--FND_MESSAGE.DEBUG('WHEN-NEW-FORM-INSTANCE');
set_menu_item_property('FILE.SAVE', enabled, PROPERTY_ON);-- able save menu
app_special2.instantiate('SPECIAL13', special_menu_name13, NULL, TRUE); --添加菜单API
app_special2.instantiate('SPECIAL14', special_menu_name14, NULL, TRUE); --添加菜单API
app_special2.instantiate('SPECIAL15', special_menu_name15, NULL, TRUE); --添加菜单API
RETURN;
END IF;
启用菜单
IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-BLOCK-INSTANCE' THEN
--SET_MENU_ITEM_PROPERTY('SPECIAL.MENU15',LABEL,'自动创建');
app_special.enable('SPECIAL13', property_on);
app_special.enable('SPECIAL14', property_on);
app_special.enable('SPECIAL15', property_on);
RETURN;
END IF;
触发菜单执行功能
IF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
AND (event_name = 'SPECIAL13')) THEN
五。调用客户化FORM
IF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
AND (event_name = 'SPECIAL13')) THEN
IF name_in('System.Form_Status') = 'CHANGED' THEN
old_level := NAME_IN('system.message_level');
COPY('5','system.message_level');
commit;
COPY(old_level,'system.message_level');
END IF;
param_to_pass1 := name_in('INV_SUM_FOLDER.ORG_ID');
param_to_pass2 := name_in('INV_SUM_FOLDER.VENDOR_ID');
param_to_pass4 := name_in('INV_SUM_FOLDER.INVOICE_ID');
param_to_pass5 := name_in('INV_SUM_FOLDER.ACCTS_PAY_CODE_COMBINATION_ID');
param_to_pass6 := name_in('INV_SUM_FOLDER.GL_DATE');
param_to_pass7 := name_in('INV_SUM_FOLDER.SET_OF_BOOKS_ID');
--FND_MESSAGE.DEBUG('CUSTOM.PLL');
--FND_MESSAGE.DEBUG('param_to_pass4 '||param_to_pass4);
--FND_MESSAGE.DEBUG('param_to_pass5 '||param_to_pass5);
--FND_MESSAGE.DEBUG('param_to_pass6 '||param_to_pass6);
--FND_MESSAGE.DEBUG('param_to_pass7 '||param_to_pass7);
V_PROPERTY := Get_Menu_Item_Property('FILE.SAVE',enabled);
--FND_MESSAGE.DEBUG('V_PROPERTY '||V_PROPERTY);
--set_menu_item_property('FILE.SAVE', enabled, PROPERTY_OFF);-- disable save menu
fnd_function.execute(function_name => 'CUXAPREBATE',
open_flag => 'Y',
session_flag => 'Y',
other_params => 'G_ORG_ID="' || param_to_pass1 ||
'" G_VENDOR_ID="' ||
param_to_pass2 || /*'"'||*/
'" G_INVOICE_ID="' ||
param_to_pass4 ||
'" G_CCID="' ||
param_to_pass5 ||
'" G_GL_DATE="' ||
param_to_pass6 ||
'" G_SET_OF_BOOKS_ID="' ||
param_to_pass7 || '"');
ELSIF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
AND (event_name = 'SPECIAL14')) THEN
param_to_pass3 := name_in('INV_SUM_FOLDER.QUICK_PO_NUMBER');
fnd_function.execute(function_name => 'CUXAPPOINFOR',
open_flag => 'Y',
session_flag => 'Y',
other_params => 'G_PO_NUMBER="' || param_to_pass3 ||
'"' ); END IF;
六。更新FORM上数据
IF ((form_name = 'APXINWKB') /*and (Block_Name = 'LINES')*/
AND (event_name = 'SPECIAL15')) THEN
BEGIN
--fnd_message.debug('XXXXXXXX:'||NAME_IN('INV_SUM_FOLDER.VENDOR_ID'));
V_INVOICE_ID := NAME_IN('INV_SUM_FOLDER.INVOICE_ID');
FOR REC_INVOICE IN rec_invoice_line(p_invoice_id => V_INVOICE_ID) LOOP
open rec_invoice_lok(p_invoice_id => REC_INVOICE.INVOICE_ID);
BEGIN
SELECT H.TERM_ID
INTO V_TERM_ID
FROM CUX_OMS_PO_HEADERS H,PO_HEADERS_ALL PH
WHERE H.PO_NUMBER = PH.SEGMENT1
AND H.PROCESS_STATUS = 'COMPLETE'
AND PH.PO_HEADER_ID = REC_INVOICE.PO_HEADER_ID;
EXCEPTION
WHEN OTHERS THEN
FND_MESSAGE.DEBUG('V_TERM_ID:'||SQLERRM);
END ;
BEGIN
SELECT rt.transaction_date
into v_date
FROM rcv_transactions rt
WHERE rt.TRANSACTION_ID = REC_INVOICE.RCV_TRANSACTION_ID
AND ROWNUM = 1;
EXCEPTION
WHEN OTHERS THEN
FND_MESSAGE.DEBUG('v_date:'||SQLERRM);
END ;
SELECT V.NAME
INTO V_NAME
FROM ap_terms_vl V
WHERE V.TERM_ID = V_TERM_ID;
COPY(V_NAME,'INV_SUM_FOLDER.TERMS_NAME');
COPY(V_TERM_ID,'INV_SUM_FOLDER.TERMS_ID');
COPY(v_date,'INV_SUM_FOLDER.TERMS_DATE');
/*UPDATE AP_INVOICES_ALL
SET TERMS_ID = V_TERM_ID,
TERMS_DATE = v_date
WHERE INVOICE_ID = REC_INVOICE.INVOICE_ID;*/
close rec_invoice_lok;
exit;
END LOOP;
old_level := NAME_IN('system.message_level');
COPY('5','system.message_level');
commit;
COPY(old_level,'system.message_level');
--query_block(p_block_name =>'INV_SUM_FOLDER');
EXCEPTION
WHEN OTHERS THEN
FND_MESSAGE.DEBUG('更新发票头时出现错误:'||sqlerrm);
END;
ELSE
RETURN;
END IF;
七.失效/生效 FORM项或者菜单
IF form_name = 'APXINWKB' AND event_name = 'WHEN-NEW-ITEM-INSTANCE' /*AND
block_name = 'INV_SUM_FOLDER'*/ THEN
IF name_in('INV_SUM_FOLDER.QUICK_PO_NUMBER') IS NULL THEN
set_item_property('INV_SUM_CONTROL.MATCH', enabled, property_false);
ELSE
set_item_property('INV_SUM_CONTROL.MATCH', enabled, property_true);
END IF;
--IF :SYSTEM.FORM_ATATUS = 'NEW' OR :SYSTEM.FORM_ATATUS = 'CHANGED' THEN
--V_STATUS := SYSTEM.BLOCK_ATATUS;
--FND_MESSAGE.DEBUG('SYSTEM.BLACK_ATATUS');
-- END IF;
V_INVOICE_ID := NAME_IN('INV_SUM_FOLDER.INVOICE_ID');
SELECT COUNT(*)
INTO V_COUNT
FROM AP_INVOICE_LINES_ALL L
WHERE l.invoice_id = V_INVOICE_ID
AND L.PO_LINE_ID IS NOT NULL
AND L.amount <> 0;
--FND_MESSAGE.DEBUG(V_INVOICE_ID||'---'||V_COUNT);
IF V_COUNT = 0 THEN
app_special.enable('SPECIAL15', property_OFF);
ELSE
app_special.enable('SPECIAL15', property_on);
END IF;
RETURN;
END IF;