Custom PLL
Custom PLL
CUSTOM.pll
Contributed by Anil Passi Sunday, 01 April 2007
CUSTOM.pll is used to add extensions to Oracle's form Functionality. Some of the common scenario where CUSTOM.pll can be used are:1. Enabling/Disabling the fields 2. Changing the List of Values in a LOV field at runtime. 3. Defaulting values 4. Additional record level validations 5. Navigation to other screens. 6. Enabling Special Menu
Primarily there are two methods of extending Oracle Forms, and these are CUSTOM.pll FORMS Personalizations In this article we will cover the basics of using CUSTOM.pll for extending Oracle Forms
How and why does CUSTOM.pll work? Every form in Oracle Apps is created using something called as TEMPLATE.fmb. But some of the modules like HRMS have their own HR Specific Templates[HRTEMPLT.fmb]. These template files have form level triggers that make call to CUSTOM.pll. The triggers that can be trapped using CUSTOM.pll in HRMS screen can be different than those which can be trapped for other modules.
Commonly used events that are trapped using CUSTOM.pll are:ZOOM WHEN-NEW-FORM-INSTANCE WHEN-NEW-BLOCK-INSTANCE WHEN-NEW-RECORD-INSTANCE WHEN-NEW-ITEM-INSTANCE WHEN-VALIDATE-RECORD
However, for example in HRMS, you can also write code in CUSTOM.pll to trap below listed events :PRE-DELETE and POST-DELETE PRE-UPDATE and POST-UPDATE PRE-INSERT and POST-INSERT POST-FORMS-COMMIT WHEN-CREATE-RECORD KEY-DELREC
How to identify which trigger is most suitable for writing your business logic? You can either open the FMB itself, and see the triggers which are calling CUSTOM.pll. However, there is a easier way to work out the most suitable triggers. You can navigate to Help/Diagnostics/Custom Code/Show Custom Events
Once that radio button has been set, you will see the list of Events Displayed on the screen.
In some cases, the desired WHEN-NEW-BLOCK-INSTANCE or WHEN-NEW-ITEM-INSTANCE are not being fired. What can I do? It should always be possible to trap these events in CUSTOM.pll . But in some cases, the form might have these triggers at block/field level, with the trigger property being OVERRIDE. Due to this, the corresponding form level triggers[ to invoke CUSTOM.pll] do not fire. In this case you must raise a bug with Oracle on Metalink.
http://oracle.anilpassi.com
Powered by Joomla!
Apps
Structure code code in CUSTOM.pll IF event_name = 'WHEN-NEW-FORM-INSTANCE' THEN IF form_name = 'ARXTWMAI' AND block_name = 'INVOICE_HEADER' THEN xx_arxtwmai.default_customer; ELSIF form_name = 'ARXTWMAI' AND block_name = 'INVOICE_HEADER' THEN ..... END IF; ELSIF event_name = 'WHEN-NEW-BLOCK-INSTANCE' THEN ..... END IF ;
Lets take some scenario's where CUSTOM.pll can be used 1. Change the label of a field app_item_property2.set_property ('BLOCK.FIELD',label,'New Label'); 2. Default a value copy (TO_CHAR (n_person_id),'PERSON_BLOCK.PERSON_ID' ); 3. Alter the SQL for LOV Query PROCEDURE filter_customers_in_lov IS v_customer_group_id recordgroup; n_temp_id NUMBER; v_customer_lov lov; BEGIN v_customer_group_id := create_group_from_query('XX_CUSTOMER_GROUP' ,'select ... from hz_cust_accounts where ..your custom criteria here..'); n_temp_id := populate_group(v_customer_group_id); v_customer_lov := find_lov('EXISTING_LOV_NAME_HERE'); IF get_lov_property(v_customer_lov,group_name) = 'EXISTING_GROUP_NAME_HERE' THEN set_lov_property(v_customer_lov,group_name,'XX_CUSTOMER_GROUP'); END IF; END filter_customers_in_lov;
4. Make a field mandatory app_item_property2.set_property ('XXBLOCK_NAME.XXFIELD_NAME',required,property_true); Similarly you can enable or disable the fields too. 5. You can display messages, for example FND_MESSAGE.CLEAR; fnd_message.set_name('APPL_SHORT_NAME_HERE', 'MSG_NAME_HERE'); or fnd_message.set_string('message text'); fnd_message.warn or fnd_message.error or fnd_message.
6. Enable or Disable Special Menu PROCEDURE manage_special_menu IS mi_id menuitem; BEGIN mi_id := find_menu_item('SPECIAL.SPECIAL15'); IF name_in('system.cursor_block') = 'INVOICE_HEADER' THEN app_special2.instantiate('SPECIAL15', 'Print Invoice'); set_menu_item_property(mi_id, displayed, property_true); set_menu_item_property(mi_id, enabled, property_true); ELSE set_menu_item_property(mi_id, displayed, property_false); END IF; END manage_special_menu;
http://oracle.anilpassi.com Powered by Joomla! Generated: 9 May, 2011, 09:11
Apps
7. Handle the click on Special Menu IF event_name = 'SPECIAL15' THEN IF form_name = 'INVOICE_FORM' THEN xx_invoice_form.process_printing; END IF; IF form_name = 'SUPPLIER_FORM' THEN xx_supplier_form.email_supplier; END IF; END IF;
8. Ask user a question, and take appropriate action v_token_value VARCHAR2(1000); n_button_selection INTEGER; BEGIN fnd_message.set_name('APPL', 'MESSAGE'); fnd_message.set_token('XXTOKEN1', v_token_value); n_button_selection := fnd_message.question('Email Invoice', 'Fax Invoice', '', 1, 2, 'question'); IF n_button_selection = 1 THEN xx_call_invoice_print; ELSE xx_fax_invoice; END IF;
9. Call Another form function fnd_function.EXECUTE( function_name => 'XX_FORM_FUNCTION_NAME_HERE' ,open_flag => 'Y' ,session_flag => 'SESSION' ,other_params => 'P_INVOICE_ID = "' || n_invoice_header_id || '"' ,activate_flag => 'Y');
10. Make some segments of a KeyFlexfield Display-Only depending upon some condition For example to make 1st segment of a KFF display-only, we can use IF v_check_result='xyz' THEN FND_KEY_FLEX.UPDATE_DEFINITION( BLOCK => 'BLOCKNAMEHERE' ,FIELD => 'FLEXFIELDNAME' ,ENABLED => 'Y' ,DISPLAYABLE => 1); END IF ;
As you may have gathered by now, almost any form related task can be done using CUSTOM.pll Action Type in CUSTOM Allowed Opening SQL Cursors Yes Executing pl/sql stored procedures Yes Referencing fields using bind notation like :block.field No Exception management Yes
For additional reading on CUSTOM.pll, please visit Best Practices for Development on CUSTOM.pll Playing with CUSTOM.pll
http://oracle.anilpassi.com
Powered by Joomla!
Apps
http://oracle.anilpassi.com
Powered by Joomla!