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

Sortable alv

Former Member
0 Likes
587

Hi,

When i clicked on a column of the alv grid(on header of the grid), it should be sorted based on the clicked column.

It is available in sost transaction etc, how can i do this?

Thanks.

deniz.

5 REPLIES 5
Read only

Former Member
0 Likes
566

hi,

Build Sort Catalog as below , For example to subtotal at MATNR

And Show only subtotal line

data gt_sort type slis_t_sortinfo_alv. "sort catalog

data sort type slis_sortinfo_alv.

  • Pass Sort sequence as below.

clear sort.

sort-fieldname = 'MATNR'.

sort-tabname = 'INTERNAL TABLE NAME'

sort-up = 'X'.

SORT-SUBTOT = 'X'.

SORT-EXPA = 'X'. " This will hide details lines

append sort to t_sort.

clear sort.

Pass This t_sort ITAB in FM REUSE_ALV_GRID_DISPLAY as

it_sort = t_sort[]

Otherwise, at output screen, Click the column you wish to sort and then click Sort Icon ( at the top header level above your column names) to arrange the column in ascending or decending order.

Read only

former_member242255
Active Contributor
0 Likes
566

when click on the header of the column and u have to hit the sort button ascending or descing accordingly..

Read only

Former Member
0 Likes
566

chk this link

Read only

Former Member
0 Likes
566

Hi,

Declare the I_sort internal table.

1) I_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.

Assign the field to b sorted according to.

2) I_SORT-SPOS = 1.

I_SORT-FIELDNAME = 'MATDES'.

I_SORT-TABNAME = 'ITAB'.

I_SORT-UP = 'X'.

I_SORT-SUBTOT = 'X'.

APPEND I_SORT.

CLEAR I_SORT.

Assign sort table as follows-

3) CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

IT_FIELDCAT = FIELDCATALOG[]

I_DEFAULT = 'X'

I_SAVE = 'A'

IS_LAYOUT = I_LAYOUT

IT_EVENTS = EVENTS[]

IT_SORT = I_SORT[]

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

Read only

Former Member
0 Likes
566

Dear,

check this code

SORT ITAB BY PARAMETER_CODE.

In the:

FORM F9002_MODIFY_FIELD_CAT TABLES P_FIELDCAT STRUCTURE LVC_S_FCAT.

FIELD-SYMBOLS : <LFS_FIELDCAT> TYPE LVC_S_FCAT.

LOOP AT P_FIELDCAT ASSIGNING <LFS_FIELDCAT>.

CASE <LFS_FIELDCAT>-FIELDNAME.

WHEN 'PARAM_CODE'.

<b> <LFS_FIELDCAT>-NO_OUT = 'X'.</b>

ENDCASE.

ENDLOOP.

ENDFORM.

Cheers

fareed