Get selected row of ABAP web dynpro table
Once you have added a table to your web dynpro for ABAP application you may need to find out which row has been selected by the user
inorder to perform further processing. These two methods assume lead selection is being used, if lead selection is not active on
your table element then you will need to use the GET_SELECTED_ELEMENTS method
to retrieve the selected rows.
Data: context_node type ref to if_wd_context_node.
Data: it_scarr type STANDARD TABLE OF if_view1=>element_CARRIERS,
wa_scarr like line of it_scarr.
data: ld_element type ref to if_wd_context_element.
context_node = wd_context->get_child_node( name = 'CARRIERS').
ld_element = context_node->get_lead_selection( ).
if not ld_element is INITIAL.
ld_element->get_static_attributes( IMPORTING
static_attributes = wa_scarr ).
endif.
* Data of selected row is now contained in wa_scarr
Data: context_node type ref to if_wd_context_node.
Data: it_scarr type STANDARD TABLE OF if_view1=>element_CARRIERS,
wa_scarr like line of it_scarr.
DATA: ld_index type i.
*NEW_LEAD_SELECTION should be an importing parameter of the method which was auto created
*There should also be an OLD_LEAD_SELECTION showing the previous selected row!
ld_index = NEW_LEAD_SELECTION->GET_INDEX( ). "get index of row selected
context_node = wd_context->get_child_node( name = 'CARRIERS').
refresh: it_scarr.
* Get data contained within ABAP web dynpro table
context_node->get_static_attributes_table(
importing
table = it_scarr ).
* Get data contained in currently selected row of an ABAP web dynpro table
context_node->GET_STATIC_ATTRIBUTES(
exporting index = ld_index
importing STATIC_ATTRIBUTES = wa_scarr ).
Set all Methods of IF_WD_CONTEXT_NODE interface |
||||