Académique Documents
Professionnel Documents
Culture Documents
In above case ZCUST_HIER_HIST is the attribute structure for the bol entity
attached to context node.
8. REFRESH: this method initializes the tree, we assign the class which was
created in step 4.
In above code we iterate through the entities in collection wrapper and then
for those entities who do not have a parent I make them a root node by
assigning the class created in step 4 in get_proxy method. This was my
requirement, one can choose the particular entities which they want and
then make them root .
Lv_root->expand_node( ): Call to expand( ) flags the node to be expanded
which during tree formation leads to call to get_children method which we will
define later.
9. This refresh method attaches the class we created in step 4 with our tree
context node, you will see the class under tree context node after activating
refresh method, if not then log off and log in to SAP.
10.Now we have two options for children to the root node, it depends on
requirement, if we need same structure for the child, then we redefine the
get_children method of the class created in step 4 as:
DATA: lv_value_node TYPE REF TO cl_bsp_wd_value_node,
lv_child
TYPE REF TO if_bsp_wd_tree_node.
lv_child = me->node_factory->get_proxy(
iv_bo = lv_value_node
iv_parent_proxy = me
iv_proxy_type = 'ZCL_EBH_ERH_HIST_TREE_PROXY' ).
lv_child->expand_node( ).
APPEND lv_child TO rt_children.
onRowSelection="select"
selectionMode="SINGLESELECT"
ajaxDeltaHandling=" "
selectedRowIndex="<%=EBHRESULT->selected_index %>"
type="COLUMN"
table="//EBHRESULT/Table"
nodeTextColumnDescription="<%= otr(CRM_IC_APPL_CH_HIST/EXPAND_TREE) %>
"
allRowsEditable="TRUE"
visibleFirstRow="<%=EBHRESULT->visible_first_row_index %>"
visibleRowCount="<%=EBHRESULT->maxRowsNumber %>"
noFrame="X"
personalizable="TRUE"/>
nodeTextColumn: it defines the first node of tree on which you want
expandd and collapse to happen.
12.
13.
Make event handler collapse and expand and add code below:
EH_ONEXPAND:
DATA: lv_tree_event
lv_tree_event ?= htmlb_event_ex.
typed_context->EBHRESULT->expand_node( lv_tree_event->row_key ).
EH_ONCOLLAPSE:
DATA: lv_tree_event
lv_tree_event ?= htmlb_event_ex.
typed_context->EBHRESULT->collapse_node( lv_tree_event->row_key ).
14.Redefine do_prepare_output
DATA: lv_index
TYPE sy-tabix.
DATA: lv_tree_node
TYPE REF TO if_bsp_wd_tree_node.
DATA: lv_proxy_node TYPE REF TO cl_bsp_wd_tree_node_proxy.
DATA: lv_n
TYPE i.
DATA: lv_r
TYPE i,
lt_ebh_hist
TYPE TABLE OF zcust_hier_hist,
ls_ebh_hist
TYPE zcust_hier_hist,
lv_iterator
TYPE REF TO if_bol_bo_col_iterator,
lv_entity
TYPE REF TO cl_crm_bol_entity.
IF lv_index < 0.
lv_index = 1.
lv_proxy_node ?= typed_context->EBHRESULT->get_node_by_index( 1 ).
IF lv_proxy_node IS BOUND.
typed_context->EBHRESULT->deselect_all( ).
lv_proxy_node->if_bsp_wd_tree_node~selected = abap_true.
ENDIF.
ENDIF.
IF typed_context->EBHRESULT->node_tab IS INITIAL.
typed_context->EBHRESULT->refresh( ).
ENDIF.
typed_context->EBHRESULT->build_table( ).
lv_index = typed_context->EBHRESULT->selected_index.
* if coming from the another page, e.g. edit mode
IF typed_context->EBHRESULT->visible_first_row_index IS INITIAL.
typed_context->EBHRESULT->visible_first_row_index = 1.
ELSE.
* if staying on the same view, e.g. position
typed_context->EBHRESULT->visible_first_row_index = lv_index.
ENDIF.
IF lv_index > typed_context->EBHRESULT->maxrowsnumber.
lv_n = lv_index DIV typed_context->EBHRESULT->maxrowsnumber.
lv_r = lv_index MOD typed_context->EBHRESULT->maxrowsnumber.
IF lv_r = 0.
lv_n = lv_n - 1.
ENDIF.
lv_n = 1 + ( lv_n * typed_context->EBHRESULT->maxrowsnumber ).
typed_context->EBHRESULT->visible_first_row_index = lv_n.
ENDIF.