cancel
Showing results for 
Search instead for 
Did you mean: 

CL_GUI_ALV_GRID Calculate Subtotals

Former Member
0 Kudos
566

The Client wants to get the Totals of a column without pressing the Sub-totals-icon within the menu bar.

How can i solve this problem.

There is an attribute "cl_gui_alv_grid=>mc_fc_subtot"

but i didnt find a method to invoke it.

Thank you very in advance

Michael

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Class cl_gui_alv_grid

method set_table_for_first_display

Parameter LVC_T_SORT (Table)

set the sort sequence in this table (SPOS)

put the fieldname in this table (FIELDNAME)

sort type (UP, DOWN)

add this record in LVC_T_SORT table and pass LVC_T_SORT table to set_table_for_first_display.

Former Member
0 Kudos

Hello Subramanian,

Thank You for Your prompt reply,

My be there is a missunderstanding.

i don't have to sort the grid-table.

What i have to do is to invoke the calculate method

after first disaplay.

Do You know a solution?

Best regards

Michael

Former Member
0 Kudos

Hi Michael,

According to SAP understanding and my understanding is we calculate sub totals based on a particular member of a group.

Assume , a XYZ company sells soaps, perfumes and magazines.

January February March

Soaps 20 30 10

Perfumes 10 30 60

Magazines 100 150 90

Assuming all these numbers as quantities, if you want to know how many soaps , perfumes and magazines were sold, then sorting category would be type of product and subtotal will be obtained.

In order to obtain subtotal, sort category is required.

I hope I am making it clear to you.

Former Member
0 Kudos

As in your first post you have mentioned that, you want a subtotal of a column, you put the fieldname of the column in FIELDNAME of LVC_T_SORT table and in SUBTOT you need to put 'X'. This should solve your problem.

Subramanian V.

Former Member
0 Kudos

Hello Subramanian,

Sorry for my late answer, but i was on holliday

First: I tried Your solution, but it doesn't work in the way the client want.

I have defined a table (LVC_T_SORT) with all Columns and

marked the SubTotals == 'X'.

Afterward i call the method hnd_grid_tc->set_sort_criteria

But the Total-Line doesnt appear in the grid.

The user must press the Icon for calculating the totals manually.

But the client wants to calculate the totals during

displaying the grid the first time!

So what i was looking for is a method, which invokes the calculation.

Do You have any ideas, how it could work ?

Thank's a lot for Your help

BR

Michael

Former Member
0 Kudos

Additionally you have to set the field DO_SUM to 'X' in the fieldcatalogue for the columns, in which you want to see the sum.

With kind regards

André

Former Member
0 Kudos

Hello Andre,

Hello Subramanian,

Many thanks to you.

It works perfectly.

BR

Michael

ssimsekler
Active Contributor
0 Kudos

Hi Michael

There is a new trend to thank people who help solving your problem. You can reward points to them. For more information, visit:

https://www.sdn.sap.com/sdn/index.sdn?page=crp_prize2.htm

*--Serdar

Former Member
0 Kudos

Hi Serdar,

I know, that i can reward points, but i dont know how

exactly to do that. I suupose, that if i mark a request as solved, the points will be given automatically. Am i right?

BR Michael.

ssimsekler
Active Contributor
0 Kudos

Hi Michael

That's what I haven't done yet, either. But there is a big star sign right at the post's header. Click on that sign and go on.

However, as far as I can see there have been points rewarded to Andre and Subramanian. So, I guess you've figured out how to do.

Hope I haven't disturbed...

*--Serdar

Former Member
0 Kudos

The alv grid still not displaying or breaking up the values by displaying the subtotals,

i have specified the LVC_T_SORT and set the relevant attributes and i have specified DO_SUM = 'X' in the fieldcatalog.

But it is still not displaying

Answers (0)