Application Development and Automation 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: 
Read only

ALV Grid sub total issue

Former Member
0 Likes
1,265

Hi SAP Experts,

Currently I have ALV Grid table as below as example :

FIELD1

FIELD2

Account

Amount

-


1. Rev

1.Rev

Acct1

100.00

1. Rev

1.Rev

Acct2

50.00

-


Subtotal FIELD2 (1.Rev)

150.00

Subtotal FIELD1 (1.Rev)

150.00

-


2. Cost

2.1 Cost1

Acct3

100.00

2. Cost

2.1 Cost1

Acct4

75.00

-


Subtotal FIELD2 (2.1 Cost1)

175.00

-


2. Cost

2.2 Cost2

Acct5

25.00

-


Subtotal FIELD2 (2.2 Cost 2)

25.00

-


| Subtotal FIELD1 (2.Cost) | 200.00 |

-


I have 2 questions.

First, as you can see, I have 2 subtotal for 1.Rev eventhough 1.Rev actually only need one subtotal because there is no subgroup for 1.Rev. Is it possible to have only one subtotal for this 1.Rev but I still maintained 2 subtotal for 2.Cost because 2.Cost has subgroup?

My 2nd issue is I need to insert another row exactly below Subtotal FIELD1 (2.Cost) row like this:

-


Gross Margin

(Some formula)

-


This row does not come from any sub total. The problem is I can not just insert this column and put Gross Margin description in FIELD1 because I will have 3 row like below :

-


Gross Margin

(Formula)

-


Subtotal FIELD2 (blank)

(Formula) sub total

Subtotal FIELD1 (Gross Margin)

(Formula) sub total

-


Is there any way I can insert Gross Margin Row without creating new subtotal for it so it will only have one line in the ALV Grid table? Please help. Thank you.

Regards,

Abraham

Hi SAP Experts,

Currently I have ALV Grid table as below as example :

FIELD1

FIELD2

Account

Amount

-


1. Rev

1.Rev

Acct1

100.00

1. Rev

1.Rev

Acct2

50.00

-


Subtotal FIELD2 (1.Rev)

150.00

Subtotal FIELD1 (1.Rev)

150.00

-


2. Cost

2.1 Cost1

Acct3

100.00

2. Cost

2.1 Cost1

Acct4

75.00

-


Subtotal FIELD2 (2.1 Cost1)

175.00

-


2. Cost

2.2 Cost2

Acct5

25.00

-


Subtotal FIELD2 (2.2 Cost 2)

25.00

-


| Subtotal FIELD1 (2.Cost) | 200.00 |

-


I have 2 questions.

First, as you can see, I have 2 subtotal for 1.Rev eventhough 1.Rev actually only need one subtotal because there is no subgroup for 1.Rev. Is it possible to have only one subtotal for this 1.Rev but I still maintained 2 subtotal for 2.Cost because 2.Cost has subgroup?

My 2nd issue is I need to insert another row exactly below Subtotal FIELD1 (2.Cost) row like this:

-


Gross Margin

(Some formula)

-


This row does not come from any sub total. The problem is I can not just insert this column and put Gross Margin description in FIELD1 because I will have 3 row like below :

-


Gross Margin

(Formula)

-


Subtotal FIELD2 (blank)

(Formula) sub total

Subtotal FIELD1 (Gross Margin)

(Formula) sub total

-


Is there any way I can insert Gross Margin Row without creating new subtotal for it so it will only have one line in the ALV Grid table? Please help. Thank you.

Regards,

Abraham

7 REPLIES 7
Read only

Former Member
0 Likes
1,216

Check the UI Programming Sticky Thread for sample codes. or search the forum for More sample codes.

Read only

0 Likes
1,216

Hi Vijay.

I'm not posting this before I search everywhere and this is not the first time I post in this forum so I know what I should do before posting. If I miss something, maybe you can give me at least a hint whether it can be done or not.

This report that I am using is ALV Grid using REUSE_ALV_GRID_DISPLAY function module and not OOP using dialog module. I never said I need sample code because I only want to know is there a way to do that using ALV Grid which until now I will say that SAP ALV grid has this limitation where you can not insert row without including it in the subtotal.

So, I would be very thankful if someone can give me some clarity on this thing and Vijay, if you really don't know what is the answer, I really appreciate if you can hold your self from making that kind of reply. It does not need experienced ABAP Consultant to write such remarks. Thanks.

Regards,

Abraham

Read only

0 Likes
1,216

To make my question more clear, FIELD1 and FIELD2 already has do_sum in their field catalog, that's why it is sub-totaled. What I want to do is insert an independent row that is not affected by this sub-total where as of now I can not do that using ALV Grid.

Read only

Former Member
0 Likes
1,216

Insted of using subtotal functionality of alv , u just loop thrue your internal table and do subtotal manualy , by this u can insert the extra row where ever u want

Read only

0 Likes
1,216

Hi Rakash,

thanks for the answer. This is also one of the option that came up when I first heard about the requirement. The problem with this option is user can not collapse and expand like what subtotal function has and when it is exported to excel also will not have the collapse and expand function in Excel.

Regards,

Abraham

Read only

Former Member
0 Likes
1,216

Not resolved

Read only

Former Member
0 Likes
1,216

implement this logic

data: sum type i.

sum = sum + tb_itab-netwr (field name)