cancel
Showing results for 
Search instead for 
Did you mean: 

How to set lead selection in ALV

Former Member
0 Kudos

Hi All,

In my ALV, everytime an ALV event occurs, the table is refreshed and the lead selection clears out.

Now i am abe to get the index of the row for which want the lead selection but it doesnt get set.

Any help how i can set the lead selection to a perticular row in the ALV?

Thanks,

Pris.

Accepted Solutions (0)

Answers (1)

Answers (1)

amy_king
Active Contributor
0 Kudos

Hi Pris,

This is a known limitation of ALV in WDA. There's an explanation for the behavior in the ALV documentation-- see the section at the bottom labelled, Important Exception: Sorting.

You mention that you are able to get the index of the row you want to use as lead selection. You should be able to use that index  to set your local DATA node's lead selection with method set_lead_selection_index.

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

I have tried to set the lead selection of the node but it doesnt reflect on the ALV.

Should it be set in the modify view?

Is there any code i would have to set for the ALV?

Thanks,

Pris.

Former Member
0 Kudos

Hi,

For this you can explicitly call that lead selection event and set the index for the table .

   **********************************************************************
* Trigger lead seletion
**********************************************************************

  DATA: lr_param TYPE REF TO cl_salv_wd_table_lead_select,
        lr_event TYPE REF TO cl_wd_custom_event.

  CREATE OBJECT lr_event
    EXPORTING
      name = 'ON_LEAD_SELECT'.

  CREATE OBJECT lr_param.
  lr_param->set_index( 1 ).

  wd_this->alv_on_lead_select(
    r_param = lr_param
    wdevent = lr_event ).

In the method alv_on_lead_select you can set the index to the binded table.

    IF r_param->index <> 0 AND wd_this->dyn_node_items IS BOUND
    AND wd_this->dyn_node_items->get_element_count( ) >= r_param->index.
    wd_this->dyn_node_items->set_lead_selection_index( r_param->index ).

Endif.

Regards,

Lavanya.

amy_king
Active Contributor
0 Kudos

Hi Pris,

With set_lead_selection_index, I was able to set the ALV lead selection in method WDDOMODIFYVIEW, but if this doesn't work for your scenario, Lavanya's suggestion may work for you.

Cheers,

Amy

Former Member
0 Kudos

Hi Amy,

It still didnt work. When i try to set the lead selection index for ALV, i can see that the existing selection becomes unselected but doesnt show the new row as selected.

I dont get any dump or errors also. I may have to look if there is a sap note for this. We are on Ehp5 , netweaver 702.

Thanks,

Pris.

amy_king
Active Contributor
0 Kudos

Sorry I couldn't help Pris. You're on a more recent EhP level and NetWeaver release than me; maybe there's some difference in behavior. Good luck!

Cheers,

Amy