cancel
Showing results for 
Search instead for 
Did you mean: 

Confusion of method GET_LEAD_SELECTION_INDEX

Former Member
0 Kudos

Hi experts,

Recently, I am working on multi-selection in table rows. When selected one line, then I pressed CTRL and de-selected it. Then I got index = 2- by method GET_LEAD_SELECTION_INDEX. Here I found when the node selection mode is not 1..1, it will lead to some unpredictable result.

Here comes the question:

1 what does Get lead selection mean? What does 'LEAD' mean?

2 Why I got the index = -2, what does it mean? Any other result that could be returned?

Thanks for reading.

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello Yichao,

-2 means there is no selection. in the sense there are no lead selected element in that context. you refer the constant IF_WD_CONTEXT_NODeE-> NO_SELECTION.

GET_LEAD_SELECTION_INDEX method will return -2 if there is no lead selected element otherwise it will return the index of the lead selected element.

BR, Saravanan

Former Member
0 Kudos

Hi,

Lead select means the cuurent line item selected. This method returns the index of the lineitem your selec ted.

Former Member
0 Kudos

Thanks both!

But vinoth rajendran, when selection is more than 1 lines for the context node, and I select several lines with CTRL or de-select line with CTRL, what will happen?

For example, I made a test, the 1st, 2nd , 3rd line were selected, and I de-selected the 1st line, the index of lead selection is 2.

former_member199125
Active Contributor
0 Kudos

I am not sure, but i think it means, first selected row. thats y it giving value 2. Try some other and check and verify.

Regards

Srinivas

Answers (2)

Answers (2)

Former Member
0 Kudos

I think the leading selection means the 1st selected row. When the selection mode is 1..1, this is which row selected currently. When the mode is 0...n, I think it is the 1st row you selected. All the rest rows will be found in method get_selected_elements().

And I guess, I did not put it into practice, when you set the selectionMode in VIEW UI editor as mutiple line without lead, all the selected rows will be found in get_leading_elements().

So in conclude, the leading selection is for the 1st selected row.

The below link can be referred:

http://help.sap.com/saphelp_nw70/helpdata/en/38/c5bacc91a345eda17f2903491c391d/content.htm

Thanks for the help of all of you! I close the topic now.

ChandraMahajan
Active Contributor
0 Kudos

> Here comes the question:

> 1 what does Get lead selection mean? What does 'LEAD' mean?

> 2 Why I got the index = -2, what does it mean? Any other result that could be returned?

1. Refer

2. getting negative index means there is no row selected.

for e.g. in bleow code, i am setting lead seletion as -1 , it means when the ALV is displayed, 1st row will not be selected.

  • get element via lead selection

lo_el_node_alv_output = lo_nd_node_alv_output->get_element( ).

lo_nd_node_alv_output->set_lead_selection_index( -1 ).

lo_nd_node_alv_output->bind_table( it_alv[] ).

then if user selects mutiple rows using cntrl key, you can use below coding to read those selected entries,

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

lo_nd_node_alv_output = wd_context->get_child_node( name = wd_this->wdctx_node_alv_output ).

  • Get element via lead selection

lo_el_node_alv_output = lo_nd_node_alv_output->get_element( ).

lt_element = lo_nd_node_alv_output->get_selected_elements( ).

I hope this will help you.

Thanks,

Chandra

Former Member
0 Kudos

Hi Chandrashekhar Mahajan , thanks for you reply.

I found soome sample in standard program. It use get leading element plus selected elements to retrive all the selected elements. The method get_selected_elements will return a table without the leading element.