Skip to Content
1

Merge Column Cells alv - using cl_gui_alv_grid

May 08, 2017 at 05:48 AM

866

avatar image
Former Member

Hi

I want to merge below highlighted column and need to include a text in the merged column. Kindly suggest.

Thanks in advance.

Regards,

Abirami

merge-column.png (10.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

7 Answers

Best Answer
Sandra Rossi May 09, 2017 at 06:38 AM
0

To span one cell over 2 rows and 2 columns, do as follows with the code of @enno.wulff (http://www.tricktresor.de/blog/zellen-verbinden/) :

" span over 2 rows (outputlen must be the number of rows)
wa_col_merge-col_id = 1.
wa_col_merge-outputlen = 2.
APPEND wa_col_merge TO it_col_merge.
CALL METHOD g_alv_grid->z_set_merge_vert EXPORTING row = 1
CHANGING tab_col_merge = it_col_merge.

" span over 2 columns (outputlen must be the number of the last column to merge)
wa_col_merge-col_id = 1.
wa_col_merge-outputlen = 2.
APPEND wa_col_merge TO it_col_merge.
CALL METHOD g_alv_grid->z_set_merge_vert EXPORTING row = 1
CHANGING tab_col_merge = it_col_merge.


kwima.png (16.8 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 08, 2017 at 11:35 AM
-1

Hi Sandra,

I copied the same class and also the demonstrated prog:

demonstrated prog: http://www.tricktresor.de/wp-content/downloads/ALV/zz_alv_merge_cells.abap.txt

But I am getting below output. I am unable to find the column merged.

Could you please suggest on this, as the logic will work perfectly for the column merge or not?

Thanks in Advance!

Regards,


col-merge.png (13.2 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Abirami,

Can you please share class methods-> attributes. I tried to create class but unable to find the attributes of its methods.

Thanks

0
Sascha Wächter May 08, 2017 at 06:17 AM
0

Hi Abirami,

as far as I know it is not possible to merge column cells in ALV Grid. If you sort the table for example, then same cells are automatically merged if merging is allowed, But you can't control the mergering on your own.

Regards

Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sascha,

I could find a answer in the below link.. but it is not clear. Could you please check the below link and let me know your suggestion.

http://www.tricktresor.de/blog/zellen-verbinden/

Regards,

0

Yes this seems to be interesting, but it also says that there is no possibillity in standard ALV Grid to do that. But in this example they manipulate the ALV Grid class and enhance the ALV Grid by a subclass and implement the functionality in the subclass itself so that you can use it in your program.

Maybe you can try it with the example coding. But it also says that there are limitations in your ALV if you implement this functionality.

0

It also seems to me that there is a lot of code missing from this as well.

Rich

0

I just tried it, there is no missing code. You have to double click every method to get the whole code, + the demo program (there's just one syntax error "ZCL_GUI_ALV_GRID_MERGE not found", replace it with ZCL_GUI_ALV_GRID)

0

Ok, thanks Sandra

0
Sandra Rossi May 08, 2017 at 07:50 AM
0

Well done, Abirami. It's the first time I see that it's possible to do it (although not supported by SAP i.e. no guarantee to be maintained). Could you tell us where is your issue with the solution provided by Enno Wulff at http://www.tricktresor.de/blog/zellen-verbinden/ ?

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sandra,

I copied the same class and also the demonstrated prog:

demonstrated prog: http://www.tricktresor.de/wp-content/downloads/ALV/zz_alv_merge_cells.abap.txt

But I am getting below output. I am unable to find the column merged.

Could you please suggest on this, as the logic will work perfectly for the column merge?

Thanks in Advance!

Regards,

col-merge.png (13.2 kB)
0

I guess you changed the demo, because what I tried was beautiful. In your example, I see 3 merged cells (TRICKTRESOR, HC in column "P", and HC in column "K").

Isn't it what you're trying to achieve? Please explain carefully as I don't understand what your issue is.

0
avatar image
Former Member May 09, 2017 at 05:16 AM
0

Hi Sandra,

Currently the 3 merged cells are merged by only rows.. I want the column also to be merged.

ex: as highlighted below : along with TRICKTRESOR the corresponding column has to be merged.

In your demo is the column getting merged? it will be good if you share me your output snap shot.. for my better understanding.

I do no where im getting failed in archiving the column merge.. Kindly share me..

Regards,


col.png (13.9 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Abhi..

Can you explain me how do we achieve merging of alv cells dynamically same as column P in the above pic..

0

What is your issue with the solution provided by Enno Wulff at http://www.tricktresor.de/blog/zellen-verbinden/ ?

0
avatar image
Former Member May 09, 2017 at 08:20 AM
0

Hi

Thanks for in details..

I just made a mistake while creating a class.. I am getting now the perfect output..

Thanks for all the support.

Regards,

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 10, 2017 at 06:46 AM
0

Hi Sandra,

I am trying to merge the highlighted rows

code used:

But the 2nd colunm is getting affected.

Kindly suggest on this to archeive, thanks

Regards,


ver.png (7.8 kB)
code.png (3.9 kB)
affect.png (6.9 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

I don't think it's related to only the code you show. Maybe you didn't clear the internal table it_col_merge, or you have an extra code you didn't show, or things like that.

Your code should have no effect as you merge a cell to itself (with Y/Z_SET_MERGE_VERT, outputlen is the total number of rows to merge from a given cell, including this cell). You should use outputlen = 3 (and correct some other code for cell R3C2).

0