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: 

Sorting in ALV Grid

Francis417
Participant
0 Kudos

Hi,

I've written programs which either use OOALV or the standards 'Resue_alv_*' function to display the grid. I've also make use of the parameter IS_SORT to specify some sorting conditions. It is said that by default, if I sort the ALV grid, the dupicate fields will be vertically merged.

However, in my programs the duplicated fields are not merged. I wonder what I've missed and would like to seek for some advise from you guys.

Thanks,

Francis

1 ACCEPTED SOLUTION

lijisusan_mathews
Active Contributor
0 Kudos

Just check your layout . It will have the parameter " Do not merge duplicates" chechked. Just uncheck it.

15 REPLIES 15

lijisusan_mathews
Active Contributor
0 Kudos

Just check your layout . It will have the parameter " Do not merge duplicates" chechked. Just uncheck it.

0 Kudos

Hi Suzie,

Do you mean the field 'cell_merge'?

cell_merge(1) type c, " not suppress field replication

Actually I didn't set anything in this field.

Thanks,

Francis

0 Kudos

No no. not in teh layout for the field catalog.. Yeah you can set it there too.. But I was talking of the Layout that is available at the alv display time.. Where you can add fields or delete .. etc.. in that Layout there will be a tab "Display/View' in that you can find several options ( as check boxes) Check the value there

0 Kudos

Hi Suzie,

Actually, I didn't check the 'Without cell merging during sorts' checkbox. In fact, it seems to have no effect in the ALV Grid in my program no matter I shck or uncheck this checkbox.

Also, I've also selected the 'Wit striped patt.' checkbox and it also seems doesn't work in my ALV Grid.

Thanks,

Francis

Edited by: Francis S.K. LUK on Oct 14, 2011 1:01 PM

0 Kudos

Pls send you piece of relevant code. Also can you try 1 more thing. In your output. select the fields that need to be sorted. and click on Sort button there ( ie.. try from the Sort button in the ALv toolbar)

0 Kudos

Hi Suzie,

I've attached part of the code in my previous reply. In fact, I've tried calling the ALV function without passing the parameter 'IS_SORT' and tried the SORT button in the ALV grid toolbar, and it still doesn't work, I mean the duplicate fields are not merged.

Thanks,

Francis

madhu_vadlamani
Active Contributor
0 Kudos

Hi Francis,

I did not understand the requirement.

sort the ALV grid, the dupicate fields will be vertically merged.

Please check this wiki from Hareesh.

[Sorting|sort the ALV grid, the dupicate fields will be vertically merged]

Regards,

Madhu.

0 Kudos

Hi Madhu,

What I mean is that, the ALV Grid initially look like this

Col1 Col2 Col3

ABC 123 This

ABC 456 is

ABC 456 a

ABC 789 test

Now if a sort Col1 and Col2, it will look like this

Col1 Col2 Col3

ABC 123 This

456 is

a

789 test

It is said that by default, the result will be exactly as the above, however, it dones't work in my program.

Regards,

Francis

Former Member
0 Kudos

Hi,

On the ALV output screen choose Change Layout -> Display and check if "Without cell merging during sorts" is checked or not. If checked, uncheck the same and save the layout. The cell merging should work correctly.

Let me know in case of any problem.

Regards,

Shayeree

0 Kudos

Hi Shayeree,

The checkbox is not checked initially, and it seems to have no effect no matter it is checked or not.

Thanks,

Francis

0 Kudos

Hi,

It may be possible that this issue is because of the fields that you have included as sort fields. Could you please let me know the piece of code that you are executing?

Regards,

Shayeree

0 Kudos

Hi Shayeree,

My problem is that the duplicate values of the various sort fields cannot be merged. Attached is part of the code that I'm using in my program.

.............

perform alv_sort using 1 'WERKS' space space space.

perform alv_sort using 1 'ERNAM' space space space.

perform alv_sort using 1 'BANFN' 'X' space '*'.

perform alv_sort using 1 'EBELN' space space space.

.....................

g_repid = sy-repid. "Report ID

g_layout-colwidth_optimize = 'X'. "Optimize column width

g_layout-zebra = 'X'. "Show zebra row colours

g_layout-no_totalline = 'X'. "No grand total line

g_print-no_print_listinfos = 'X'. "Don't print list info.

g_layout-box_fieldname = 'CHKBOX'.

g_layout-edit = 'X'.

g_layout-edit_mode = 'X'.

g_layout-group_change_edit = 'X'.

...................

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = g_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'ALV_COMMAND'

I_GRID_TITLE = g_title

IS_LAYOUT = g_layout

IT_FIELDCAT = it_fieldcat

IT_SORT = it_sort

I_DEFAULT = 'X'

I_SAVE = 'A'

IS_PRINT = g_print

IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

TABLES

T_OUTTAB = itab

.

FORM ALV_COL using fname ftxt fcol ftype fnoout fcurr fqty.

clear ls_fieldcat.

ls_fieldcat-fieldname = fname. "Field name

ls_fieldcat-seltext_l = ftxt. "Field label

ls_fieldcat-no_out = fnoout. "X no detail output

if fcol = 'KEY'.

ls_fieldcat-key = 'X'. "Column color as key color

else.

ls_fieldcat-emphasize = fcol. "Column color

endif.

if not ftype is initial.

ls_fieldcat-datatype = ftype.

if ftype = 'INT4'.

ls_fieldcat-do_sum = 'X'. "Sum-up total

elseif ftype = 'CURR'.

ls_fieldcat-cfieldname = fcurr. "Field to store currency

  • ls_fieldcat-decimals_out = '0'. "0 decimal place

ls_fieldcat-ctabname = 'ITAB'.

ls_fieldcat-do_sum = 'X'. "Sum-up total

elseif ftype = 'QUAN'.

ls_fieldcat-qfieldname = fqty. "Field to store UoM

ls_fieldcat-qtabname = 'ITAB'.

ls_fieldcat-do_sum = 'X'. "Sum-up total

endif.

endif.

append ls_fieldcat to it_fieldcat.

ENDFORM. "End FORM ALV_COL

Thanks,

Francis

lijisusan_mathews
Active Contributor
0 Kudos

Just comment the it_sort n layout.. and in the output.. Try giving Sort for the first field in output n c if it is merging

0 Kudos

Hi Suzie,

Thanks a lot. I found out the reason now. It is because of the statement "g_layout-edit = 'X'. Once I've commented it out, the merging works.

Thanks,

Francis

Francis417
Participant
0 Kudos

the problem is caused by the setting edit = 'X' in the layout.