Form学习笔记
- 格式:docx
- 大小:144.42 KB
- 文档页数:15
一、ERP中消息的使用:FND_MESSAGE.SET_NAME('OMS','OMS_PI_STANDARD_ERROR_60');其中'OMS'系统当前应用,OMS_PI_STANDARD_ERROR_60是消息名称FND_MESSAGE.SET_TOKEN('SEGMENT1',:DETAILS.factory_code);其中'SEGMENT1'是消息中定义的变量,:DETAILS.factory_code是要传入到'SEGMENT1'变量中的值。
FND_MESSAGE.ERROR;--提示错误类型(ERROR,SHOW…)注意:SEGMENT1前面加&符号就是变量。
例子:IF :BLOCK.ITEM IS NULL THENFND_MESSAGE.SET_NAME('OMS','OMS_PI_STANDARD_ERROR_60');FND_MESSAGE.SET_TOKEN('SEGMENT1',:DETAILS.factory_code);FND_MESSAGE.ERROR;raiseform_trigger_failure;END IF;二、FORM调用互传参数(A form中传值调用B form)A form中的Trigger下写入:fnd_function.execute(function_name => 'OMS_MO_ORDER'—功能名,open_flag => 'Y'—默认,session_flag => 'SESSION'—默认,activate_flag => 'HEADER', --焦点在哪个Window上,other_params => 'QUERY_ONLY="' || 'YES' || '"' ||'p_header_id=' || v_mo_header_id);function_name为ERP中定义的功能名称other_params参数中的QUERY_ONLY为查询状态,QUERY_ONLY为form标准参数B form中的WHEN-NEW-FORM-INSTANCE (FORM级)触发器中写入以下代码if :parameter.p_header_id is not nullthenset_block_property('header',default_where,'mo_header_id =' || :parameter.p_header_id);go_block('header');execute_query;end if;其中:parameter.p_header_id的值就是从A FORM中传过来的。
注意:fnd_function.execute中的p_header_id必须和set_block_property中的p_header_id名称必须相同,不然form找不到参数。
三、调用pll动态创建列表Setup1在FORM级触发器WHEN-NEW-FORM-INSTANCE中加入以下代码:Create_ListBox --cust块客户类型('OMS_CUST_TYPE', ' Select Description,lookup_code '||' From OMS_ALL_LOOKUP_CODES_V '||' Where lookup_type = ''OMS_CM_CUST_TYPE'' ','CUST.CUSTOMER_TYPE');CUST.CUSTOMER_TYPE就是LIST BoxSetup2在PL/SQL Libraries 中创建过程Setup3在Procedure Body中写入以下代码--以一个查询语句设置一个LISTBOXPROCEDURE CREATE_LISTBOX(P_RECORDGROUP_NAME VARCHAR2,P_QUERY_SQL VARCHAR2,P_LIST_ITEM_NAME VARCHAR2) ISv_rg_idRecordGroup;v_g PLS_INTEGER;BEGINv_rg_id := Find_Group( P_RECORDGROUP_NAME );IF NOT Id_Null(v_rg_id) THENDelete_Group(v_rg_id );END IF;v_rg_id := Create_Group_From_Query(P_RECORDGROUP_NAME,P_QUERY_SQL); v_g := POPULATE_GROUP(P_RECORDGROUP_NAME);POPULATE_LIST(P_LIST_ITEM_NAME,P_RECORDGROUP_NAME);END;四、commit_form的过程分为两步第一步是post。
将数据块上的变化post到数据库,就是将用户创建、删除、修改记录的动作翻译为SQL 语句,在数据库上执行。
第二步是commit。
这里指的是数据库commit。
在此之前,commit_form过程会先检查各个数据块的状态。
如果数据块状态不等于'CHANGED',后面的post-commit步骤不会进行。
我见过你所说的情况:原因是在非事务性forms触发器中直接使用DML语句去操作数据库,然后调用commit(或commit_form)。
因为直接使用DML语句,Forms的数据块状态不会相应改变,当然也就没有提交。
五、FORM中获取光标所在的TAB页面1. 在Form级触发器中添加触发WHEN-TAB-PAGE-CHANGED2. 在此触发器中写如下代码:DECLAREcanvas_id VARCHAR2(30); --标签页IDBEGINcanvas_id := GET_CANVAS_PROPERTY('标签画布名', topmost_tab_page);IF canvas_id='标签页1' then go_block('块1');end if;IF canvas_id='标签页2' then go_block('块2');end if;IF canvas_id='标签页3' then go_block('块3');end if;execute_query;END;六、设置时间DECLAREtimer_id Timer;one_minute NUMBER(5) := 60000;BEGINtimer_id := CREATE_TIMER('emp_timer', one_minute, REPEAT|NO_REPEAT); END;七、动态产生一个'LOV'框DECLARElv_id LOV;status BOOLEAN;BEGINlv_id := Find_LOV('lov_name'); ---'lov_name' 由导航器定义-- IFId_Null(lv_id) THEN-- lv_id := Find_LOV('lov_name1'); ---'lov_name1' 由导航器定义-- END IF;status := Show_LOV(lv_id,10,20);END;八、循环访问所有记录DECLAREcur_blkVARCHAR2(40) := :System.Cursor_Block;bk_id Block;BEGINbk_id := Find_Block(cur_blk);GO_BLOCK('SHOPPEDAYOVERTB_V');GO_RECORD(1);LOOPif get_block_property(bk_id,Update_Allowed)='TRUE' then:SHOPPEDAYOVERTB_V.import_flag:='N';UPDATE SHOPPEDAYOVERTB SET import_flag ='N' where SHOPPEDAYOVERTB.ROWID=:SHOPPEDAYOVERTB_V.ROW_ID;end if;EXIT WHEN (NAME_IN('ST_RECORD') = 'TRUE');NEXT_RECORD;END LOOP;commit;END;九、从当前form转到请求提交页面fnd_function.execute( function_name => 'FND_FNDRSRUN',open_flag => 'Y',session_flag => 'Y',other_params => 'DODT_REQ_ID="'||TO_CHAR(l_request_id)||'"');十、在R12中实现多OU编程A.首先最重要的是要在pre-form中初始化多OUBEGINAPP_STANDARD.EVENT(‘PRE-FORM’);//必须在APP_STANDARD.EVENT()后执行MO_GLOBAL.init ('INV');--参数可以使’S’—单OU,’M’-多OU,或者已经注册过的应用简称END;B.初始化后获取OU的信息,在Pre-form中获取OU信息,或在块上When-Create-Record获取OU信息Pre-formDECLAREl_default_org_id number;l_default_ou_name varchar2(240);l_ou_count number;BEGIN...mo_utils.get_default_ou(l_default_org_id, l_default_ou_name, l_ou_count);:PARAMETER.mo_default_org_id:= l_default_org_id;:PARAMETER.mo_default_ou_name := l_default_ou_name;:PARAMETER.mo_ou_count := l_ou_count;...END;When-Create-RecordIF :parameter.mo_default_org_id is not null and :_id is null THEN :_id := :parameter.mo_default_org_id);:block.operating_unit := :parameter.mo_default_ou_name;END IF;C.在各个触发器实现多OU的支持的代码When-Create-Record Trigger of Operating Unit Field BlockIF (:parameter.mo_default_org_id IS NOT NULL ) THEN-- Defaulting org_id from profile option:_id := :parameter.mo_default_org_id;:block.operating_unit := :parameter.mo_default_ou_name;-- Set policy contextmo_global.set_policy_context('S’,:_id);ELSEmo_global.set_policy_context('M', null);END IF;IF :<your block _id> is not null\IF :<block _id><>nvl(:<parameter.old_org_id>,-99) THEN -- Get the cache for current orgEND IF;ELSE-- Refresh the cache...END IF;When-Validate-Item Trigger of Operating Unit fieldIF (:<your block _id> IS NOT NULL ) THENIF :<block _id><>nvl(:<parameter.old_org_id>,-99) THENmo_global.set_policy_context('S', :_id);-- Get the cache for the current orgEND IF;ELSE -- :_id is nullmo_global.set_policy_context('M', null);-- Refresh the cacheEND IF;When-New-Record-Instance Trigger of Operating Unit Field Block IF (:<your block _id> IS NOT NULL ) THENIF :<block _id><>nvl(:<parameter.old_org_id>,-99) THEN mo_global.set_policy_context('S', :_id);-- Get the cache for the current orgEND IF;ELSE -- :_id is null, so set the context to multiplemo_global.set_policy_context('M', null);-- Refresh the cacheEND IF;Pre-Insert Trigger of Operating Unit Field BlockUse this trigger if the form allows the user to commit multiple records. IF (:<your block _id> IS NOT NULL ) THENIF :<block _id><>nvl(:<parameter.old_org_id>,-99) THEN mo_global.set_policy_context('S', :_id);-- Get the cache for the current orgEND IF;ELSE -- :_id is null, so set the context to multiplemo_global.set_policy_context('M', null);-- Refresh the cacheEND IF;Pre-Query Trigger of Operating Unit Field BlockBEGINIF :parameter.mo_ou_count = 1 THENmo_global.set_policy_context(‘S’,:parameter.mo_default_org_id);ELSEmo_global.set_policy_context('M', null);END IF;-- Other CodeEND;Pre-Record Trigger of Operating Unit Field Blockuse this trigger if the form forces the user to commit each record.IF (:parameter.current_record is not null and:parameter.current_record != :system.trigger_record) THENIF (:system.form_status in ('CHANGED','INSERT')) THENmo_global.set_policy_context('S', :parameter.old_org_id);-- Get the cache for the current org-- raise error message to the user to commit;-- raise form_trigger_failure;ELSE-- No pending commits.-- Reset the current record variable.:parameter.current_record := '';END IF;ELSE-- User has not navigated to another record.-- Do not reset the current record variable.null;END IF;Pre-Update TriggerUse this trigger if the form allows the user to commit multiple records commits that are in different operating units.IF (:<your block _id> IS NOT NULL ) THENIF :<block _id><>nvl(:<parameter.old_org_id>,-99) THENmo_global.set_policy_context('S', :_id);-- Get the cache for the current orgEND IF;END IF;十一、设置金额显示格式PROCEDURE FORMAT_PRICE(EVENT VARCHAR2) ISBEGINIF (EVENT IN ('WHEN-VALIDATE-ITEM','POST-QUERY'))THENAPP_ITEM_PROPERTY.SET_PROPERTY('LINES.SUGGESTED_PRICE',FORMAT_MASK, FND_ CURRENCY.GET_FORMAT_MASK(:ORDERS.CURRENCY_CODE,GET_ITEM_PROPERTY('LINES.S UGGESTED_PRICE',MAX_LENGTH)));APP_ITEM_PROPERTY.SET_PROPERTY('LINES.TOTAL_PRICE',FORMAT_MASK, FND_CU RRENCY.GET_FORMAT_MASK(:ORDERS.CURRENCY_CODE,GET_ITEM_PROPERTY('LINES.TOT AL_PRICE',MAX_LENGTH)));ELSEFND_MESSAGE.DEBUG('Invalid event passed to lines.format_price '||EVENT);END IF;END FORMAT_PRICE;十二、获取当前窗口GET_VIEW_PROPERTY(GET_ITEM_PROPERTY(:SYSTEM.CURSOR_ITEM,ITEM_CANVAS),WINDOW_NAME)十三、异常处理代码BEGINXxx;EXCEPTION WHEN OTHERS THEN:PACK_LINE_V.QUANTITY_CANCEL:=NULL;END;十四、提示框IF :CTR_PACK.SUM_QUERITY<sum_quantity and :PACK_HEADER_V.PACK_STATUS='SHIPPED' THENFND_MESSAGE.set_name('OMS','装箱数量不能小于已装柜数量!');FND_MESSAGE.error;raise form_trigger_failure;END IF;十五、信息提示框之基本用法1、messageUsage:message('提示信息');Effect:在FORMS 左下角会出现这个提示信息。