cancel
Showing results for 
Search instead for 
Did you mean: 

How to present Totals and subtotals for columns of ALV

Former Member
0 Kudos

Hi Experts,

I wanted to know the practice or way of presenting totals and subtotals for a given column of an ALV.

I Know how to do total and subtotal on a particular column using Aggregate rule and sort rule.

But here in my requirement i have around 8-10 columns which can be used for Totals and subtotals.

In Dynpro ALV, we have an option of selecting a particular Column and then click button for aggregation.

Here in WDA, how to achieve such functionality.

All i want to know is how to present such functionality.

1. Either user should be able to select a column and click on aggregate button to do the total and subtota on that. ( here how to select column in WDA ,i guess there is no option for select column)

2. What is the better way of realizing this requirement as number of columns eligible for total are more.

I feel providing a custom button for each column total makes the alv look ackward, Is there a better alternative?

Any clue or help is greately appreciated.

PS: Please don't give me links to those threads on how to achieve total and subtotal. I have already done that.

regards,

Ajay

Edited by: ajay matam on Oct 12, 2009 11:18 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Check this tutorial; [Using Totals and Subtotals Feature of ALV Component in WD4A|http://www.sdn.sap.com/irj/scn/index;jsessionid=(J2EE3414900)ID2059712050DB10199088478461885793End?rid=/library/uuid/4063c42a-2549-2c10-fab6-a8c99d98b9b5&overridelayout=true]

Former Member
0 Kudos

Hi Ajay,

In the latest versions, there is option for CALCULATION under the SETTINGS. Have you gone through that option.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

In our version we don't have CALCULATION under Settings.

rgds,

Ajay

Former Member
0 Kudos

Hi,

If you want to have the custom button for totals, then you need to have custom code to achieve the functionality.

Implement the ONCLICK event of the ALV , check whether this gets triggered on cilck of any cell of that column. in this handler

write the code.

Regards,

Lekha.

Former Member
0 Kudos

Hi Radhika,

Thanks for your inputs. I have seen that thread and i know how to realize totals and subtotals.

Hi Lekha,

Thanks for your inputs.

All i wanted to know is , how do i present the feature for total on the alv tool bar?

what is the general practice?

rgds,

Ajay

Former Member
0 Kudos

Hi,

One thing , If you use the standard ones, then you have the calculation being done by framework. But, if a user either enters any value/changes any value(dropdown) , user has to hit ENTER key to get new values so that ALV gets refreshed for these totals. If you want to have some custom button and use calculate the TOTALS in that custom button, try to write the code for AGGREGATION for those columns (cl_salv_wd_field) or check ONCLICK event gets triggered if a user performs any action on cell of that column.. Hope this is clear.

what exactly you want for these totals.. can you be more clear.

Regards,

Lekha.

Edited by: Lekha on Oct 12, 2009 3:14 PM

Former Member
0 Kudos

Hi Lekha,

Here is my requirement.

I have an ALV with lots of columns of which there are 4 currency fields and 4 quantity fields which are eligible for totals and subtotals.

Now i need to provide the feature for totals and subtotals. I don't want to do it during the initialization as it is left for user's choice, if they want to do totals or not.

All these columns are display only.

Now for these 8 fields how do i give the option for totals.

One way is i can build 8 custom buttons and on clicking each one of that i can write the code for totals/subtotals on that.

two - ? i wanted to know the better way of giving this feature. This is my requirement.

How is this kind of requirement generally realized in WDA?

rgds,

Ajay

Former Member
0 Kudos

Hi,

In this case, you need to have one record added to the current table(to which the ALV is bound) for Totals.

Provide a button for Totals and you have to calculate the totals and bind the table again.

You can implement the same code in the ONCLICK event of the ALV, so that the user clicks on any cell of that column, then

based on the R_PARAM values(column name) you can calculate the total only for that column and bind the table again.

Ideally, Total should be one of the rows(records) apart from actual data.

Or

Not only during initialization you can have this Total, provide button for total in ALV toolbar, write that

Initialization peice of code here.

Is this clear.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

Thanks for yout inputs.

Well i can't have another field for totals.

I know that i can give a custom button in ALV tool bar and on clicking it i can calculate the totals.

but i have 8 such columns, do i have to have 8 buttons?

Is there any smart way so that i can avoid 8 buttons ?

Rgds,

Ajay

Former Member
0 Kudos

Hi,

Single button is suffice. In this button handler, Try to have that AGGREGATION set code.

cl_salv_wd_config_tabe(lovalue)~if_salv_wd_field_settings->get_fields. Now loop through the field and set the aggregation type.

In the ONCLICK event code, get the column name and using the above way set the agagregation only for that given column and

delete the same for other columns.

Try this out.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

I tried to implement your suggestion, but ON_CLICK is not working here as i don't have any button or linktoaction as part of the columns.

How to go about this now?

I understand that clicking on the column header is triggering a round trip. Is there an even associated with this?

Can we have any event on clicking the column heading?

Any clue is greately appreciated.

Rgds,

Ajay

Former Member
0 Kudos

How about implementing the ONDATACHECK/ONCELL ACTION check them out....

ONCELLACTION should be triggered.....Test this out , then with ONDATACHECK..

If they are not getting triggered, i guess MODIFYVIEW must be getting triggered

Edited by: Lekha on Oct 13, 2009 2:03 PM

Former Member
0 Kudos

Hi Lekha,

No luck with ON_CELL_ACTION.

and i have used ONDATACHECK to know if there are any changes to input fields of editable columns.

And the columns on which i want to do totals are not input enabled.

when i click on column header, yes WDMODIFYVIEW is getting triggered but you see i don't know which column is triggered here?

Any other way? is there any way to know SELECTED COLUMN?

rgds,

Ajay

Former Member
0 Kudos

Hi,

Then on button handler, irrespective of the column calculate the totals....

Regards,

Lekha.