component and context programming二

实例演示:为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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值