Skip to Content
avatar image
Former Member

using table tree by key column UI element

hi,

I have table tree by key column and a button in my view.

i want to enable the button for the selection of only leaf elements.

i.e.in the 3 rd level i have leaf (no further sub node) elements.

i want to enable the button for these elements only.for the higher nodes i.e. for the 1st and 2 nd level i want to disable the button.

please any sample code for this?

Regards,

Lakshmi.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Sep 14, 2008 at 04:15 PM

    Hi Lakshmi,

    check this component WDT_TREE_TABLE_BY_KEY.(this is also having 3 levels with 3rd level as leaf)

    and the method GENERATE_DATA.

    Bind an attribute of type wdy_boolean to button enabled property and set the attribute value in GENERATE_DATA method by checking the conidition

    row-is_leaf = abap_true.

    Hope it helps

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      write an action on lead select of the table and check if the selected row is a leaf set enabled property to button or else disabled.

      sample code is as follows

      DATA lo_nd_table_data_source TYPE REF TO if_wd_context_node.

      DATA lo_el_table_data_source TYPE REF TO if_wd_context_element.

      DATA ls_table_data_source TYPE wd_this->element_table_data_source.

      DATA lv_is_leaf LIKE ls_table_data_source-is_leaf.

      DATA lv_enabled LIKE ls_table_data_source-enabled.

      • navigate from <CONTEXT> to <TABLE_DATA_SOURCE> via lead selection

      lo_nd_table_data_source = wd_context->get_child_node( name = wd_this->wdctx_table_data_source ).

      • @TODO handle not set lead selection

      IF lo_nd_table_data_source IS INITIAL.

      ENDIF.

      • get element via lead selection

      lo_el_table_data_source = lo_nd_table_data_source->get_element( ).

      • @TODO handle not set lead selection

      IF lo_el_table_data_source IS INITIAL.

      ENDIF.

      • alternative access via index

      • lo_el_table_data_source = lo_nd_table_data_source->get_element( index = 1 ).

      • @TODO handle non existant child

      • IF lo_el_table_data_source IS INITIAL.

      • ENDIF.

      • get single attribute

      lo_el_table_data_source->get_attribute(

      EXPORTING

      name = `IS_LEAF`

      IMPORTING

      value = lv_is_leaf ).

      if lv_is_leaf eq abap_true.

      lo_el_table_data_source->set_attribute(

      name = `ENABLED`

      value = abap_true ).

      else.

      lo_el_table_data_source->set_attribute(

      name = `ENABLED`

      value = abap_false ).

      endif.