FORM开发相关技术(二)
1.取得需对应的货币
其中:GET_ITEM_PROPERTY('LINES.PRICE',MAX_LENGTH)为返回一个该item的最大长度,
FND_CURRENCY.GET_FORMAT_MASK(currency_code IN varchar2,field_length IN number)return varchar2;
2.格式化(需要的话进行汇率转换)item的货币类型
APP_ITEM_PROPERTY.SET_PROPERTY('LINES.PRICE',FORMAT_MASK,
FND_CURRENCY.GET_FORMAT_MASK(:ORDERS.CURRENCY_CODE,
GET_ITEM_PROPERTY('LINES.PRICE',MAX_LENGTH) ))
3.动态控制item的显示格式的触发范围
在Block-level的Post-query trigger和Item-level的 when-validate-item trigger调用handler,控制显示格式。
CALENDAR 日历
如何实现在form中弹出calendar并返回所选日期的功能?
1.设text item为日期型, LOV属性为:ENABLE_LIST_LAMP并且Validate from List LOV—>No
2.在该text item 的KE_LISTVAL下加入如下代码:calendar.show;
trigger属性Execution Hierarchy—>Override,fire in enter-query mode—>No。
使用APP_DATE.FND_DATE取得服务器端的时间环境
4 . Dependencies item的编程
语法:1.APP_FIELD.SET_DEPENDENT_FIELD(EVENT,:block.master_item = CONDITION,
‘block.dependent_item’);
用途:A conditionally-dependent item changes validation when the value in the master
item changes. Specify the condition rather than the master item name.
This procedure makes an item enterable or not enterable based on whether the master item
is NULL or a specified condition is TRUE, and clears the field. The dependent item can be
a text item, check box, or poplist.
You typically call this procedure in the following triggers:
? WHEN–VALIDATE–ITEM on the master field
? WHEN–VALIDATE–ITEM on the field(s) the condition is based on or in event INIT
on the dependent field
? PRE–RECORD
? POST–QUERY (required only when the dependent item is in a
multi–record block)
:block.master_item = CONDITION包括:
--APP_FIELD.SET_DEPENDENT_FIELD(EVENT,(:block.master_item IS NOT NULL),
’block.dependent_item’);用于Multiple items may depend on a single master.
--APP_FIELD.SET_DEPENDENT_FIELD(EVENT,((:block.master_item1 IS NOT NULL) AND
(:block.master_item2 IS NOT NULL)),’block.dependent_item’);
用于Two master items may share a dependent item.
--APP_FIELD.SET_DEPENDENT_FIELD(EVENT,’block.master_item,’block.dependent_item’);
用于Cascading dependence - an item can be both master and dependent.
5.APP_FIELD.SET_EXCLUSIVE_FIELD
用途Mutually exclusive items—they look like two items, but behave as one. Use
APP_FIELD.SET_EXCLUSIVE_FIELD to code.
--APP_FIELD.SET_EXCLUSIVE_FIELD(EVENT,’block.item1’,’block.item2’,’block.item3’);
Call item handler procedures in:
– WHEN-VALIDATE-ITEM for each exclusive item
– PRE-RECORD on the items’ block (Fire in Enter-Query Mode: No)
– WHEN-CREATE-RECORD on the items’ block
6.APP_FIELD.SET_INCLUSIVE_FIELD
用途Mutually Inclusive Items—one for all and all for one!
Use APP_FIELD.SET_INCLUSIVE_FIELD to code a set of items where, if any
of the items is not null, all items are required.
--APP_FIELD.SET_INCLUSIVE_FIELD(EVENT,’block.item1’,’block.item2’);
? Call item handler procedures in:
– WHEN-VALIDATE-ITEM for each inclusive item
– PRE-RECORD on the items’ block (Fire in Enter-Query Mode: No)
7.APP_FIELD.SET_REQUIRED_FIELD
用途:Conditionally Mandatory items—use APP_FIELD.SET_REQUIRED_FIELD to
require certain items only if a certain condition is met.
--APP_FIELD.SET_REQUIRED_FIELD(EVENT,(CONDITION),’block.item’);
通常在以下的trigger中调用Dependencies控制逻辑:PRE-RECORD,when-create-record,
when-validate-item,when-checkbox-changed, when-radio-changed,when-list-changed
和‘INIT’事件。PRE-RECORD和INIT是在操作数据前初始化这些逻辑,而其他是在item发生变化后验证这些逻辑,满足条件则进行后续的动作。
使用APP_ITEM_PROPERTY.SET_PROPERTY代替SET_ITEM_PROPERTY设置item属性APP_ITEM_PROPERTY.SET_PROPERTY modifies the following properties:
? DISPLAYED
? ENABLED
? ENTERABLE
? ALTERABLE (item instance level)
? ALTERABLE_PLUS (item level)
? REQUIRED
注意:在APP_ITEM_PROPERTY.SET_PROPERTY使用 item id 或者 block.item_name
语法:
item_id := Find_item(’block_name.item_name’);
app_item_property.set_property(item_id,property_name,setting);
等同于 app_item_property.set_property(’block_name.item_name’,property_name,setting);
8. Tab Related Code
Tab-related Variables 与Tab-related相关的变量
? :SYSTEM.TAB_NEW_PAGE
– name of the tab page the user clicked on(取得用户点击后的tab 页)
? :SYSTEM.EVENT_CANVAS
– name of canvas that owns the newly-selected tab page(取得用户新点击的画布)
? :SYSTEM.TAB_PREVIOUS_PAGE
– name of the tab page that was topmost before the user
clicked on the new one(取得在用户点击新的页面前的tab页)
Dynamically Changing Tabs
? Dynamically hide tabs only at form startup.
– set_tab_page_property(...VISIBLE)
? Dynamically enabling/disabling tabs.
– set_tab_page_property(...ENABLED...)
Tab-related Trigger
? WHEN-TAB-PAGE-CHANGED
– fires only when user clicks on a tab
– cannot be fired programmatically
– can only exist at the form level
target_canvas_name VARCHAR2(30) := :system.tab_new_page;--取得当前用户点击的tab页
curr_canvas_name VARCHAR2(30) := get_item_property(:system.cursor_item,item_canvas);--返回当前画布的名称
current_tab VARCHAR2(30) := get_canvas_property('TAB_LINES_REGIONS',topmost_tab_page);
--返回在tab画布上的顶层的tab页的名字
set_canvas_property('TAB_LINES_REGIONS', topmost_tab_page, curr_canvas_name); --将当前的画布设为可交换页顶层的tab
9.Window 与Region Behavior 编程:
WINDOW的控制:(使用app_window 包来取得标准的窗口控制动作)