Skip to content

Instantly share code, notes, and snippets.

@svict4
Last active January 17, 2018 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svict4/2d71ee1e05d48c7cf186564ec07c2316 to your computer and use it in GitHub Desktop.
Save svict4/2d71ee1e05d48c7cf186564ec07c2316 to your computer and use it in GitHub Desktop.
ABAP SAP CRM - Create a Tree Table

Your context node class’ inheritance must be changed to: CL_BSP_WD_CONTEXT_NODE_TREE.

image

You then must redefine the “Refresh” method and write similar code to the following:

DATA: lr_value_node TYPE REF TO cl_bsp_wd_value_node,
      lr_iterator TYPE REF TO if_bol_bo_col_iterator,
      lr_root     TYPE REF TO if_bsp_wd_tree_node.

lr_iterator = me->collection_wrapper->get_iterator( ).
lr_value_node ?= lr_iterator->get_first( ).

WHILE lr_value_node IS BOUND.

  lr_root = me->node_factory->get_proxy(
            iv_bo         = lr_value_node
            iv_proxy_type = 'PROXY CLASS HERE' ).

  lr_root->node_key = add_root_node( lr_root ).
  lr_root->expand_node( ).
  lr_value_node ?= lr_iterator->get_next( ).
ENDWHILE.

The proxy class is a class inheriting from: CL_BSP_WD_TREE_NODE_PROXY. In the GET_CHILDREN method is where you throw your logic. Remember to (if you want recursion) call the same proxy class for each node in that method:

me->node_factory->get_proxy(
                   iv_bo         = lr_value_node
                   iv_proxy_type = 'PROXY CLASS HERE' ).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment