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

CL_SALV_TABLE sort issue

ralf_wenzel_heuristika
Active Participant
0 Likes
4,028

I am using a CL_SALV_TABLE in fullscreen mode. The ALV is displayed fine.

But:

* I mark a column and the standard sort button of CL_SALV_TABLE, the row order changes

* I press a custom button

* In the eventhandler method for added_function, the table (the ALV is based on) has NOT been sorted

* After coming back to the ALV, the list is UNsorted again, but the column shows the red indicator for "sorted by this column"

  (the ALV seems to be thinking, that the table has been sorted, but it isn't)

The problem is, that I don't know which row the user has marked. If he marks the third row after sorting the grid, the read table ... index ... finds the row, which was the third BEFORE sorting (which is another row). The displayed ALV has another order than the itab, the third row in ALV is NOT the third row in the itab, the ALV is based on.

I've tried anything:

* GET_GLOBALS_FROM_SLVC_FULLSCR with check_changed_data

* refresh( refresh_mode = if_salv_c_refresh=>full )

* get_metadata( )

Nothing helped

example:

A         B        C

200     100     200

100     200     100

300     300     300

A shows the ALV after method 'display', B shows the sorted ALV list, C shows the itab. Of course, the user only can see B and want to mark the second row ('200'). In the event handler method for added_function I can see, that the second row has been marked - but based on the unsorted list (which means, I operate with '100' instead of '200')

What can I do?

7 REPLIES 7
Read only

former_member184158
Active Contributor
0 Likes
1,935

Hallo Ralf,

as you mentioned, B is sorted table, when sort the table, the backend and the frontend will be changed, so in this metod, we have changing paramter, because the table will be changed.

if you have ITAB, lt_ITAB,

you can assign the global table to you ITAB,

lt_ITAB = gt_conn.

then you will get the sorted table ( B )

.

CALL METHOD cl_salv_table=>factory

     IMPORTING

       r_salv_table = r_alv_table

     CHANGING

       t_table      = gt_conn.


Try this demo


SALV_DEMO_TABLE_SELECTIONS


Regards

Ibr



Read only

0 Likes
1,935

Hi,

Make sure that you do not recreate the cl_salv_table on each PBO.

in SALV_DEMO_TABLE_SELECTIONS you can see that all the code is

conditioned by if gr_container is not bound.

Regards.

Read only

0 Likes
1,935

Fullscreen -> no container

Read only

0 Likes
1,935

I do not have a local itab. There is just one itab and this is global.

Edit: I was wrong. I used a sorted itab in the whole program and copied it into a standard itab (because SALV does not work with sorted itabs). I always looked into the sorted itab (and of course, a sorted itab can not be sorted).

Message was edited by: Ralf Wenzel for providing the solution

Read only

0 Likes
1,935

Hi,

SALV_DEMO_TABLE_SELECTIONS have also form display_fullscreen .

Check it out .

Regards.

Read only

0 Likes
1,935

Hi Ralf,

could you assign this table to a ref data.

     data lr_data_Tab type ref to data.

      FIELD-SYMBOLS:

       <lt_data> TYPE STANDARD TABLE,

       <ls_data> TYPE ANY.

   GET REFERENCE OF ITAB INTO lr_data_tab.

         ASSIGN lr_data_tab->* TO <lt_data>.


Ps: I have tried in my test program but I can not get you problem, I get them with same index, before sorting and after sorting

Regards

Ibrahim

Read only

0 Likes
1,935

The index was the same, but at that index, in the sorted (displayed) table contents another row than the unsorted table in memory.

But I posted the solution, I had two itabs.