How my tables in WDA kept losing Lead Selection
More than once I got myself on the same scenario when developing an Web Dynpro ABAP application.
I would create a standard WD Table element and proceed to bind it to a context node and create a onLeadSelection method.
Except that when I selected a table row, instantly the screen would try to call my onLeadSelection method and fail, returning to select the first row instead.
Twice, on different applications, I had the same behavior. And it took me the same amount of time to discover what it was causing this.
The issue was very simple: I was re-binding the context node of the table!
On the onLeadSelection method, I was trying to update the table data, but the result of this is that the table resets the Lead Selection.
So, next time you cannot change the Lead Selection of a WDA table, try checking if your onLeadSelection method is not modifying the context node of the table in any way. Such as methods:
lo_node->bind_table( new_items = itab ).
other methods of if_wd_context_node (bind_element, bind_structure, clear_selection,… )