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

ALV Object Model: Sorting issue (CL_SALV_TABLE)

Former Member
0 Likes
3,095

Hi,

Scenario:

This thread is linked to the post:

The scenario is that I have an ALV grid on which I have added a button to perform the 'Refresh' operation. On pressing this button, the data is retrieved from the database and displayed back.

Issue:

The problem is that when I sort any field (by using the generic ALV sorting functionality) in ascending order and then press the "Refresh' button, the sort order is lost which I would like to avoid as this will be frustrating for the user to sort the result set after pressing the 'Refresh' button.

To give a clear picture of the issue, if you try to execute the SAP delivered program: SALV_DEMO_TABLE_REFRESH, i found that the behavior is the same.

Inputs:

As my scenario was similar to this I selected the option 'Output as Grid' on the selection screen and the number of records as 5. On the result screen, I select the field 'Occupied' and sort this in Ascending order. Now I press the button 'Double Data Records and Select Rows'. (This will refresh the grid).

Now when you get the result back, the sort order is lost and the data is displayed as it was retrieved from the database table. It does not maintain the sort order.

Kindly suggest. I fighting this issue for a long time..:(

Regards

s@k

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,589

If you have not reviewed this excellent set of articles on NetWeaver SALV, read Mr. Heilman on the subject. The article referenced below includes get_sort, set_sort methods...

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de490...

I trust this will be helpful, at least, to your problem....

Regards,

Dave

If you have not reviewed this excellent set of articles on NetWeaver SALV, read Mr. Heilman on the subject. The article referenced below includes get_sort, set_sort methods...

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de490...

I trust this will be helpful, at least, to your problem....

Regards,

Dave

3 REPLIES 3
Read only

Former Member
0 Likes
1,590

If you have not reviewed this excellent set of articles on NetWeaver SALV, read Mr. Heilman on the subject. The article referenced below includes get_sort, set_sort methods...

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de490...

I trust this will be helpful, at least, to your problem....

Regards,

Dave

Read only

Former Member
0 Likes
1,589

Dear Dave,

Thanks for your response...:)

The approach I followed is:

Before executing the 'user command' method, i have set the 'Sort' criteria using the: get_lvc_sort and set_lvc_sort methods of the class cl_salv_controller_metadata.

The sort order is retained after the Refresh button is pressed...

Regards

s@k

Read only

0 Likes
1,589

you have to clear the sort order and then refresh.

lr_sorts = gr_alv->get_sorts( ).

lr_sorts->clear( ).

gr_alv->refresh( ).