web dynpro for abap基础知识(四)
2009-12-29 17:39
344 查看
访问一个node element
获得一个指向node的引用后就可以使用get_element( )方法来获得指向element at selection的引用,类型为IF_WD_CONTEXT_ELEMENT。
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lo_el_flights TYPE REF TO if_wd_context_element.
lo_wd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
*get element at lead selection
lo_el_flight = lo_flight_flights->get_element( ).
*if lead selection is not set, ELEM_FLIGHTS will be initial
IF ( lo_el_flights IS INITIAL ).
...
ENDIF.
要获得索引为n的element,使用方法get_element( index = n )。get_element_count( ) 方法返回一个collection中的element的数目。
访问单个node的attribute
一旦获得了指向一个node element的引用,就可以使用下面两个方法来访问这个node的attribute。get_attribute( )可以访问任意一个attribute,所需的参数是要访问的attribute的名字。另一个方法是get_static_attributes( ),用于访问static defined attributes(此处不明白)。
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lo_el_flights TYPE REF TO if_wd_context_element.
DATA: lv_connid TYPE wd_this->element_flights-connid.
lo_wd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
lo_el_flight = lo_flight_flights->get_element( ).
*get single attribute
lo_el_flights->get_attribute(
EXPORTING
name = 'CONNID'
IMPORTING
value = lv_connid ).
controller context中的每个node在interface IF_<ctrl_name>中都有一个隐含的名为element_<node_name>structure和名为elements_<node_name>的standard internal table,其line type是element_<node_name>。这个internal table用于存放multiple node elements的attributes。(此处不明白,既然每个node都有一个这样对应的internal table,为什么还说存放multiple node elements的attributes??)
一个使用get_static_attributes( )访问一个node 的static attributes的例子:
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lo_el_flights TYPE REF TO if_wd_context_element.
DATA: ls_flights TYPE wd_this->element_flights.
lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
lo_el_flights = lo_nd_flights->get_elements
*get all static declared attributes
lo_el_flights->get_static_attributes(
IMPORTING
static_attributes = ls_flights ).
获取所有node elements的static attribues:
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lt_flights TYPE wd_this->element_flights.
lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
*get all static declared attributes for all node element
lo_nd_flights->get_static_attributes_table(
IMPORTING
table = lt_flights ).
(完成)
获得一个指向node的引用后就可以使用get_element( )方法来获得指向element at selection的引用,类型为IF_WD_CONTEXT_ELEMENT。
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lo_el_flights TYPE REF TO if_wd_context_element.
lo_wd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
*get element at lead selection
lo_el_flight = lo_flight_flights->get_element( ).
*if lead selection is not set, ELEM_FLIGHTS will be initial
IF ( lo_el_flights IS INITIAL ).
...
ENDIF.
要获得索引为n的element,使用方法get_element( index = n )。get_element_count( ) 方法返回一个collection中的element的数目。
访问单个node的attribute
一旦获得了指向一个node element的引用,就可以使用下面两个方法来访问这个node的attribute。get_attribute( )可以访问任意一个attribute,所需的参数是要访问的attribute的名字。另一个方法是get_static_attributes( ),用于访问static defined attributes(此处不明白)。
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lo_el_flights TYPE REF TO if_wd_context_element.
DATA: lv_connid TYPE wd_this->element_flights-connid.
lo_wd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
lo_el_flight = lo_flight_flights->get_element( ).
*get single attribute
lo_el_flights->get_attribute(
EXPORTING
name = 'CONNID'
IMPORTING
value = lv_connid ).
controller context中的每个node在interface IF_<ctrl_name>中都有一个隐含的名为element_<node_name>structure和名为elements_<node_name>的standard internal table,其line type是element_<node_name>。这个internal table用于存放multiple node elements的attributes。(此处不明白,既然每个node都有一个这样对应的internal table,为什么还说存放multiple node elements的attributes??)
一个使用get_static_attributes( )访问一个node 的static attributes的例子:
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lo_el_flights TYPE REF TO if_wd_context_element.
DATA: ls_flights TYPE wd_this->element_flights.
lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
lo_el_flights = lo_nd_flights->get_elements
*get all static declared attributes
lo_el_flights->get_static_attributes(
IMPORTING
static_attributes = ls_flights ).
获取所有node elements的static attribues:
DATA: lo_nd_flights TYPE REF TO lf_wd_context_node.
DATA: lt_flights TYPE wd_this->element_flights.
lo_nd_flights = wd_context->get_child_node( name = wd_this->wdctx_flights ).
*get all static declared attributes for all node element
lo_nd_flights->get_static_attributes_table(
IMPORTING
table = lt_flights ).
(完成)
相关文章推荐
- web dynpro for abap基础知识(2)
- web dynpro for abap基础知识(3)(转)
- Web dynpro for ABAP ALV 相关知识
- Web Dynpro for ABAP SELECT OPTIONS
- ALV Select options for ABAP Web dynpro
- 【WD4A学习笔记】- web dynpro for abap 在线帮助文档
- Web Dynpro for ABAP: creating Dynamic UI Elements and Context: Step by Step
- Web Dynpro for ABAP Config…
- MVC Architecture for Webdynpro for ABAP
- Web Dynpro for ABAP "调用 SALV_WD_TABLE GET_MODEL 时没有数据" 报错解决
- web dynpro for abap基础知识(4)(转)
- web dynpro for abap bapi的使用
- Web Dynpro for ABAP SELECT OPTIONS
- web dynpro for abap 基础知识(一)
- Programming dynamic ALV in WebDynpro for ABAP
- Creating editable ALV using webdynpro for ABAP
- web dynpro for abap 基础知识
- webdynpro for abap - link .
- web dynpro for abap基础知识(三)
- SAP web dynpro for abap 环境配置