实例演示:为component and context programming一里的T_marc,创建一个子节点T_mard。
并标记为Singleton,并为其分配一个supply function。根据父节点的物料号,工厂,读取
相应工厂下的各个库位的库存。
1,在component的context T_marc节点下创建一个子阶段t_mard,cardinaltiy 为1:n,Singleton复选框,够中。
在supply function里输入读取库存的方法名称。
2,在output_view视图里,做update mapping ,并增加一个Table UI元素,用于存放库存的数据。并进行相应的绑定。
3,component method,编写supply function方法。可以借助注释完成。
method GET_MARD .
* General Notes
* =============
* A common scenario for a supply method is to aquire key
* informations from the parameter <parent_element> and then
* to invoke a data provider.
* A free navigation thru the context, especially to nodes on
* the same or deeper hierachical level is strongly discouraged,
* because such a strategy may easily lead to unresolvable
* situations!!
* if necessary, get static attributes of parent element
DATA ls_parent_attributes TYPE wd_this->element_t_marc.
parent_element->get_static_attributes(
IMPORTING
static_attributes = ls_parent_attributes ).
*
** data declaration
DATA lt_t_mard TYPE wd_this->Elements_t_mard.
DATA ls_t_mard LIKE LINE OF lt_t_mard.
** @TODO compute values
** e.g. call a data providing FuBa
*调用FM,读取应用数据。
CALL FUNCTION 'ZGET_MARD'
EXPORTING
material = ls_parent_attributes-matnr
plant = ls_parent_attributes-werks
tables
t_mard = lt_t_mard
.
** bind all the elements
node->bind_table(
new_items = lt_t_mard
set_initial_elements = abap_true ).
*
endmethod.
4,创建application,激活,测试如下。
点击Next