cancel
Showing results for 
Search instead for 
Did you mean: 

Row default selection rather than set_lead_selection_index.

Pratik2228
Participant
0 Kudos

Hi Frnds,

I have one alv report IN which it has multiple rows,

my issue is that when user select any row it should get selected as default like(set_lead_selection_index(1)).

but it should not get selected by its index as user can sort it ascending & descending.

Please help me to solve this issue,i have searched for it and can get anything..

It will be a great help.

Thanks..

Rohan

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member184958
Active Participant
0 Kudos

Hi,

If you want to get the selected value, go through the below code,

Data lv_index type sy-index.

Read the node, then do the below,

lo_el_node = wdevent->get_context_element('CONTEXT_ELEMENT').

lv_index = lo_el_node->get_index().

now set the lead selection to that variable.

Hope this will helpful to you.

Regards,

John.

Former Member
0 Kudos

Hello,

as John said use the Context element thing this will give you row on which u r working without lead selection.

Same kind of discussion is there in the http://scn.sap.com/thread/3412183 . so u can read this also.

.. Chandra

former_member217916
Participant
0 Kudos

Hi Rohan,

One possible way to achieve the required functionality could be to save the primary key of selected row in a variable or structure instead of using the selected index since users could sort the internal table.

Just like you have used set_lead_selection_index( ), you can still use this but just get the index from the selected primary key of the row.

You could use the following logic:

get_index_selected_row(

                EXPORTING

                    primary_key_selected_row           "This would be key of the selected row

               IMPORTING

                    index_selected).

lo_ref_node->set_lead_selection_index( index_selected ).

According the above logic your set lead selection is based on primary key of row selected by the user which would remain the same even after sorting the ALV table.


Regards,

Karan Ranawat

Pratik2228
Participant
0 Kudos

hi, karan

is not working with it, can u explain clear

former_member217916
Participant
0 Kudos

Could you explain your requirement is little bit more in detail? What do mean by when user select any row it should get selected as default ?


Regards,

Karan Ranawat

Pratik2228
Participant
0 Kudos

hi karan

ook explain in brief about issue..

take a alv report suppose it has 4 rows,and a edit button, when i select 3 row and click on edit button a new window opens and in that window selected rows column get display and their i edit particular column and when i select save it goes to my 1 view,their i want the row i selected to be lead_set

when i click save the view in alv gets change and index of it also changes so i want to set_lead_selection to value of row i select..

former_member217916
Participant
0 Kudos

Hi Rohan,

This seems to be a context mapping issue in this case.

If you map the nodes of the 1st View to the component controller nodes your row selection will be remembered even if you go to some other view and come back.

Following is the general understanding about context scopes:

Component Controller Context - Global scope

     View 1 Context - Local scope to view 1

     View 2 Context - Local scope to view 2

Now for your inital ALV which appears in View 1, Add the same node structure of this ALV to component Component Controller context.

Map the newly added node in to Component Controller context to the context node in View 1.

By doing the above, the application remembers your selection of a particular row in ALV present in View 1 even when you navigate to some other view(/window) and come back to View 1.

I think this should solve your issue.

Regards,

Karan

0 Kudos

Hi Rohan,

You are saying the row has to selected as lead selection, but also saying that it will be sorted .

Can you please explain in detail? Do you have any action ?