Application Development 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: 

alv sorting

Former Member
0 Kudos

hi

need to sort alv data, but the entries are like header and item

means first line is of header data and if has items then

the items will be displayed starting from second line but some columns for all items

will be empty (means header data at the top line refers)

now second header data comes and then its items.

in such case how to sort the ALV basing on the header number.

while sorting all the items are going at the bottom since it has no header number in its line

and header items are coming at the top

how to sort these entries correctly

7 REPLIES 7

Former Member
0 Kudos

Hi ajay r

Its not possible in normal ALV. Either you go for alv tree or handle the requirement programatically by writting the functionality of sort in your user command.

Venkat.

former_member376453
Contributor
0 Kudos

I didn't get your requirement properly. But if you have multiple header, then you can have a try with Block ALV, to accommodate multiple ALV in a single window, where you can sort ALV individually.

Kuntal.

Former Member
0 Kudos

Hi Ajay,

It is not possible. Instead you can do like this. Add one indicator field to your alv populating internal table. for the header information, give the indicator as 'H'. Then populate the sorting filed and correspondinging item details immediately.

I hope you need not populate the value (Sorting field value) as it is same for the line items also.

Other wise you can even use At new statement and populate the header and line items immediately.

In either of the ways you can do.

Regards,

Santosh Kumar Mukka.

Former Member
0 Kudos

GO for Heiarrchial / tree alv.

0 Kudos

hi can u send some sample easy hierarchial alv/tree avl

i think if i can color the text for items same as background color of alv cells then the standard sorting can be used without change

How to color the text rather than cell coloring

Former Member
0 Kudos

Hi,

Try this

DATA : gt_sort TYPE slis_t_sortinfo_alv,

wa_sort TYPE slis_sortinfo_alv.

PERFORM fill_sort. " Filling sort of REUSE_ALV_GRID_DISPALY

FORM fill_sort .

wa_sort-fieldname = 'MATNR'.

wa_sort-up = c_x.

APPEND wa_sort TO gt_sort.

CLEAR wa_sort.

ENDFORM. " FILL_SORT

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = g_repid

i_grid_title = text-012

is_layout = wa_slis_layout

it_sort = gt_sort[]

it_fieldcat = gt_fieldcat[]

i_save = 'A'

TABLES

t_outtab = <fs_table>

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Former Member
0 Kudos

Hi try using this .

wa_sort type lvc_s_sort,

lt_sort type lvc_t_sort.

wa_sort-fieldname = 'SFLAG'.

wa_sort-subtot = 'X'.

append wa_sort to lt_sort.

clear wa_sort.

Regards