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

Group Sort ALV

Former Member
0 Likes
1,306

Hi,

Is it possible to group sort on ALV?

it seems we are able to merge together several rows via sort but only on its field level. is it possible to be a group field level?

example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO. Can we make the PO number as the first priority sorting without changing the position of the fields?

Hi,

Is it possible to group sort on ALV?

it seems we are able to merge together several rows via sort but only on its field level. is it possible to be a group field level?

example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO. Can we make the PO number as the first priority sorting without changing the position of the fields?

2 REPLIES 2
Read only

Former Member
0 Likes
681

It isn't a very tidy solution but I have achieved this by adding a sort field as the first field in the alv table. Concatenate the values into the sort field and sort using this. The field can then be hidden so it is not output.

Not very tidy I know, maybe someone has a better solution? I would be interested if so.

Read only

rajesh_paruchuru
Active Participant
0 Likes
681

Hi,

>

> Is it possible to group sort on ALV?

>

> it seems we are able to merge together several rows via sort but only on its field level. is it possible to be a group field level?

>

> example if i sort PO number first and vendor second it will have individual PO and the vendor field is merge together if it is the same with a different PO. Can we make the PO number as the first priority sorting without changing the position of the fields?

If I have understood your requirement correctly, group sorting should be as simple as filling up the 'IT_SORT' parameter(REUSE_ALV_GRID_DISPLAY/REUSE_ALV_LIST_DISPLAY/CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY)

as shown below: (please let me know if I have misunderstood your requirement).

ls_sort-spos = '1'.
  ls_sort-fieldname = 'FIELD1'.
  ls_sort-up = 'X'.
  APPEND ls_sort TO it_sort.
  CLEAR ls_sort.

  ls_sort-spos = '2'.
  ls_sort-fieldname = 'FIELD2'.
  ls_sort-up = 'X'.
  APPEND ls_sort TO it_sort.
  CLEAR ls_sort.

Even after displaying the ALV, columns can be group sorted by selecting all of them together(by dragging the cursor over all the columns that need to be sorted)

-Rajesh.