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: 

Subtotals/Aggregations on non-numeric fields in ALV

Former Member
0 Kudos

Is it possible to subtotal a non-numeric field in ALV reporting? 

If so, is it possible in SALV or would I have to create a classical ALV?

I'm creating a count by group, but the customer doesn't want a column with a 1 in each row -- even if the correct subtotal is showing. However adding a column like this seems to be the only solution.It seems to me you need to have the numeric data type for any and all aggregation in ALV.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Here's what I ended up doing.

I declared Survey Count a string data type of the value of 1.

I declared a new internal table that had Survey Count and Group Responsible and used the COLLECT statement to get the subtotals.

Before I appended to the field catalog, I set wa-Survey Count to '  '. I then added my entries from the collected itab to the field catalog. This allows you to show the subtotal without having to show

I saved a layout that made this look good. Because it's not pretty if you don't put group responsible and survey count anywhere else but the first 2 columns.

8 REPLIES 8

Former Member
0 Kudos

hello,

This is a very basic example of subtotal in ALV. Check it and see how you can fit your requirement in.

http://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTAL+in+ALV

best regards,

swanand

Former Member
0 Kudos

<Copy paste removed>

Moderator Message - Plagiarism is not at all tolerated in the forums. Please go through the Forum RoE before posting - .

Message was edited by: Suhas Saha

0 Kudos

Hi Indira,

I'm well familiar with that piece of code from SAPTechnical.com.

Former Member
0 Kudos

I think there's some confusion about what exactly my requirement is.

Here's my ALV output now.

Ticket #  |   Group Responsible | Survey Count | Date

              |   Group A                |       5            |

101        |                                |       1            | 10/01/2012

102        |                                |       1            | 10/02/2012

103        |                                |       1            | 10/03/2012

104        |                                |       1            | 10/04/2012

105        |                                |       1            | 10/05/2012

Here's what I'm being asked to provide

Ticket #  |   Group Responsible | Survey Count | Date

              |   Group B                |       4            |

111        |                                |                    | 10/01/2012

112        |                                |                    | 10/02/2012

113        |                                |                    | 10/03/2012

114        |                                |                    | 10/04/2012

Essentially I'm doing a row count by grouping rather than a subtotal per se. I'm being asked to hide the 1's, yet still achieve the same total at the parent/grouping level like a subtotal.

0 Kudos

Did you try to create a TECH column intger with 1 value for each line, declare it as summed, and use the method get_subtotals in event after_refresh or top_of_page to copy the total of this column to the displayed column (the one with non-displayed 0 on line items)

Regards,

Raymond

Former Member
0 Kudos

Here's what I ended up doing.

I declared Survey Count a string data type of the value of 1.

I declared a new internal table that had Survey Count and Group Responsible and used the COLLECT statement to get the subtotals.

Before I appended to the field catalog, I set wa-Survey Count to '  '. I then added my entries from the collected itab to the field catalog. This allows you to show the subtotal without having to show

I saved a layout that made this look good. Because it's not pretty if you don't put group responsible and survey count anywhere else but the first 2 columns.

0 Kudos

Hello:

If I understood, you added your collected subtotals like a data record into your ALV. Once the ALV is displayed, what about if user sort data by any field or want a different subtotal (by date for instance)?

Regards,

0 Kudos

I wanted to used SALV's standard subtotal functionality - but the client didn't want to see the 1's.

You're right though that filtering or looking for another subtotal could mess the report up. Here's what I did. I changed the PF status to limit sorting. I also created a layout that showed the group and subtotal with other information indented.