sapdev logo background
sapdev logo sapdev logo
Comments

Get selected row of ABAP web dynpro table




It is very simple to set a specific table row as selected (highlighted) within your SAP ABAP web dynpro application. You simply need to use the set_lead_selection_index method of the context variable (i.e. type ref to if_wd_context_node) directly after you have populated it using the bind_table method.

Note this also works for the wdp tree structure but be aware that the row you need to assign is the position it is in the actual table irrespective of where and if it ends up being displayed in the tree output.

To implement this you first need to create a basic web dynpro application which contains a table


The ABAP code to set the default selected row
Simply add the following code to your application anywhere after you have bound the data to your table UI element i.e. after the context_node->bind_table( it_tab ) statement.

data: context_node   type ref to if_wd_context_node,
      ld_index       type i.

* replace CARRIERS with the name of context element assigned to table
  context_node = wd_context->get_child_node( name = 'CARRIERS').
  context_node->set_lead_selection_index( index = 3 ).

* Not really required but just shows you how to capture which row is selected
  ld_index = context_node->GET_LEAD_SELECTION_INDEX( ).

See all Methods of IF_WD_CONTEXT_NODE interface




comments powered by Disqus