Skip to Content

SET_LEAD_SELECTION_INDEX is not wokring when column sort in ALV

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Aug 26, 2010 at 11:19 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 22, 2013 at 07:27 AM

    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


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.