Hi WD4A colleagues,
currently I'm trying to create a node dynamically to my view context. The node must be able to handle mutiple lines (itab). The creation of the NODE_INFO and the NODE itself seem to work.
But at the moment I'm populating my node with lo_node->bind_table, only the first item of the collection get's a proper element (CL_WDR_CONTEXT_ELEMENT). Anybody an idea what I'm doing wrong?
Thanks and best,
Sander
DATA lo_root_node_info TYPEREF TO cl_wdr_context_node_info.
DATA lo_node_info TYPEREF TO cl_wdr_context_node_info.
DATA lo_root_element TYPEREF TO cl_wdr_context_element.
DATA lo_context TYPEREF TO cl_wdr_controller.
DATA lo_node TYPEREF TO if_wd_context_node.
DATA lo_tabledescr TYPEREF TO cl_abap_tabledescr.
DATA lo_structdescr TYPEREF TO cl_abap_structdescr.
DATA lr_data TYPEREF TO DATA.
DATA lv_node_name TYPESTRING.
FIELD-SYMBOLS<ft>TYPEANY TABLE.
TYPES:BEGIN OF ty_s,
NUMBERTYPE i,
text TYPESTRING,
END OF ty_s.
TYPES: ty_t TYPESTANDARD TABLE OF ty_s WITH EMPTY KEY.
CREATE DATA lr_data TYPE ty_t.
ASSIGN lr_data->*TO<ft>.
* Needed for testing
DATA lt_table TYPE ty_t.
lt_table =VALUE #((NUMBER=1 text ='Sample text')(NUMBER=2 text ='More text')).
<ft>= lt_table.
lo_tabledescr ?= cl_abap_typedescr=>describe_by_data(<ft>).
lo_structdescr ?= lo_tabledescr->get_table_line_type().
lo_root_node_info ?= wd_context->get_node_info().
lo_root_element ?= wd_context->get_lead_selection().
lv_node_name ='DYNAMIC'.
lo_context ?= wd_context->get_context().
* remove old entry
TRY.
lo_root_node_info->if_wd_context_node_info~remove_child_node( lv_node_name ).
CATCH cx_wd_context.
ENDTRY.
lo_node_info = cl_wdr_context_node_info=>create(
NAME = lv_node_name
parent = lo_root_node_info
is_mandatory = abap_false "cardinality 0:
is_multiple = abap_true "cardinality :n
is_mandatory_selection = abap_false "selection 0:
is_multiple_selection = abap_false "selection :1
is_singleton = abap_true
is_initialize_lead_selection = abap_true
static_element_rtti = lo_structdescr ).
lo_root_node_info->if_wd_context_node_info~add_child_node(
child_info = lo_node_info
is_static = abap_false ).
lo_node = cl_wdr_context_node=>create(
node_name = lv_node_name
parent_element = lo_root_element
CONTEXT = lo_context
node_info = lo_node_info ).
* At this point, only the first line is populated with
* an element in the CL_WDR_CONTEXT_NODE->COLLECTION part of the
* lo_node instance
lo_node->bind_table(<ft>).