cancel
Showing results for 
Search instead for 
Did you mean: 

SET_LEAD_SELECTION_INDEX is not wokring when column sort in ALV

0 Kudos

Dear Experts,

I am using ALV to display data - single selection mode, first row should be selected after data is refreshed.

This works if I dont have column sort in ALV view settings.

As soon as I customize default ALV view to have sort (in Sort tab), the first row is not selected and lead section of node is not done. Also using SET_LEAD_SELECTION_INDEX of IF_WD_CONTEXT_NODE laso does not work when ALV have sort (though it works when ALV does not have subtotals).

Moreover if I use ALV view without sort and refresh data (using bind_table method) then lead selection is fine. But after I select ALV view with sort (with the same data) - the lead selection is lost (simpply because of selecting another ALV view)!!!

We have 7.01 (EP1).

Thanks.

Edited by: Dmitry Kalmykov on Aug 26, 2010 11:38 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member187651
Active Participant
0 Kudos

Hello Dmitry,

Of course Mr.Thomas is write that after getting sorted Webdynpro ALV component temporarily takes control of the internal data table and invalidates the corresponding context node of your application during this time.

And this is the main reason we did not get the row selected after sorting done.

But, we have the way to achieve the solution for this issue.

Please follow the logic below:

After Binding your ITAB to the ALV context node: Write the code below

*************Refresh the SALV_WD_TABLE with*******************************************
*DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
DATA: ls_in TYPE if_salv_wd_table=>s_type_param_refresh_in.
  ls_in-dummy = '01'"all

lo_INTERFACECONTROLLER =   wd_this->wd_cpifc_xyz( ). "xyz is the component created for ALV

   lo_interfacecontroller->refresh(
    in =         ls_in                      " if_salv_wd_table=>s_type_param_refresh_in
   ).

Note: this code will execute the WDDOMODIFY method to SALV_WD_TABLE before we select the row. This is the refresh method of ALV interface controller.

Now use the method:

set_lead_selection_index)  : to select the row.

Here you can just pass the '1' to select the first row of your ALV alway.

Regards,

Chandan


Former Member
0 Kudos

Hi,

your Coding works if i put it in the Method: WDDOMODIFYVIEW of my View,

but this cant be use in productiv using.

it is possible to trigger the sort klick, by using the Event ON_STD_FUNCTION_AFTE of my alv component. But if put your coding in it, i seams not to work anymore.

if i use other events i can not trigger the sort klick of column header.

is the a tip for this problem?

i dont understand how do people use the alv table with this big sort bug..

kind regards

tobias

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

From the online help

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/42/b9ea094f4a3118e10000000a1553f7/frameset.htm

Important Exception: Sorting

Here ALV has to use the entire dataset so that the data records can be arranged in the new order. For this purpose, the ALV component temporarily takes control of the internal data table and invalidates the corresponding context node of your application during this time. This ensures that the application cannot access the context node while the ALV component is editing the internal data table.

Once the internal data table has been resorted, ALV rebuilds the context node, releases it again for the application, and displays the data accordingly.

This ensures that the internal data table is never copied. This is important because large volumes of data would considerably impact performance and memory space.

When you are planning your application, note the following side-effects of this mechanism:

● When the context node is invalidated, information about current selections, and in particular the lead selection, is lost.

● If your application has created subnodes for the context node, (master-detail scenario), these subnodes are lost as soon as the ALV component invalidates the context node. If the application then tries to access the subnodes, a runtime error occurs.

0 Kudos

Dear Thomas,

thank you very much for your prompt reply.

After ALV rebuids context node it does not select first row. that is the problem. I dont need to select particular row, I want the first row to be selected.

I have Text propertry of Text_View elements bound to that context note (lead selection). Also I have set cardinality 1..n and selection 1...1 and Initialization Lead Selection 'X'. So when there is no lead selection it gives this:

Adapter error in TEXT_VIEW "SELCTED_COUNTRY" of view "Y_ESTIMATE_OVIEW.MAIN": Context binding of property TEXT cannot be resolved: Lead selection not set for context node MAIN.1.OVERVIEW_TABLE

Is there a way to force ALV to select first (selectable) row with ALV sort view?

Regards

former_member187651
Active Participant
0 Kudos

Hello Thomas,

I am also going through the same problem. My requirement is to select the ALV row dynamically with the business logic. I need to select the row based on one unique key value of context node attribute mapped for ALV. Even I am able to do so when there is no sorting at the ALV setting (GUI level).

But fails when sorting is done.

I am selecting the row by getting the index for that unique attribute value for ALV. and passing the same to method:

set_lead_selection_index

Please let me know, is there any process where we can select the row dynamically with my unique attribute key value.

Its urgent and very much required for me. Please help.

former_member187651
Active Participant
0 Kudos

Hello all,

Problem Resolved....

Thanks to all...