Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to sort by column click using CL_SALV_TABLE API

Former Member
0 Likes
2,210

Hi folks,

I am creating an ALV display for the user by using the new OOPS API (CL_SALV_TABLE class). I want to provide the functionality of sorting the columns when the user clicks on the column headers.

According to the documentation the class CL_SALV_FUNCTIONAL_SETTINGS has a method called SET_SORT_ON_HEADER_CLICK. I have used this method in my program, but it is not working for me. Has anyone used this functionality in their reports, if yes please advise me how to do it. I can't figure out what I am doing wrong. I don't want to use events here.

Thanks in advance.

Hi folks,

I am creating an ALV display for the user by using the new OOPS API (CL_SALV_TABLE class). I want to provide the functionality of sorting the columns when the user clicks on the column headers.

According to the documentation the class CL_SALV_FUNCTIONAL_SETTINGS has a method called SET_SORT_ON_HEADER_CLICK. I have used this method in my program, but it is not working for me. Has anyone used this functionality in their reports, if yes please advise me how to do it. I can't figure out what I am doing wrong. I don't want to use events here.

Thanks in advance.

8 REPLIES 8
Read only

Former Member
0 Likes
1,590

Hi,

Check this [link|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de4908a6]

regards,

Advait

Read only

0 Likes
1,590

Hi,

I already have this document, but it does not explain about the functionality that I want.

Read only

naimesh_patel
Active Contributor
1,590

The effect of this method SET_SORT_ON_HEADER_CLICK is only restricted to the GRID output, not the full screen nor the List.

Try this way before calling the DISPLAY method:


  data: lr_functional_settings type ref to cl_salv_functional_settings.
  lr_functional_settings = gr_table->get_functional_settings( ).
  lr_functional_settings->SET_SORT_ON_HEADER_CLICK( 'X' ).

Regards,

Naimesh Patel

Read only

0 Likes
1,590

Hi,

I have already written that piece of code, but it is not working.

Read only

0 Likes
1,590

Can you show your code of the FACTORY mehtod call of the CL_SALV_TABLE ?

Regards,

Naimesh Patel

Read only

0 Likes
1,590

Here it is,

TRY.
      CALL METHOD cl_salv_table=>factory
*   EXPORTING
*     list_display   = IF_SALV_C_BOOL_SAP=>FALSE
*     r_container    =
*     container_name =
        IMPORTING
          r_salv_table   = g_alv
        CHANGING
          t_table        = gt_report
          .
    CATCH cx_salv_msg .
  ENDTRY.

Read only

Former Member
0 Likes
1,590

Hi,

Did anyone find the issue here. I am also facing the same problem.

Read only

0 Likes
1,590

According to the class documentation, this method only works in the grid control in the container, not in the fullscreen or classic list display of your output table.

cl_salv_table=>factory(

     EXPORTING

       r_container = ob_container

        container_name = 'CONTAINER'

    IMPORTING

        r_salv_table = gr_salv_table

    CHANGING

        t_table = int_tab ).