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 total or based on two key fields

Former Member
0 Likes
1,072

Hello experts,

I have ALV grid with vendor, g/l account and amount field.

I want to have sum or total of each vendor, and if vendor having mutliple g/l accounts i want to have sum for each g/l account.

ex: vendor g/l account amount.

10 aa 100

10 bb 200

11 cc 300

olp : 10 aa 100

10 bb 200

11 cc 300

ex2 : vendor g/ account amount

10 aa 100

10 aa 200

11 cc 300

o/p 10 aa 300.

11 cc 300.

Could you please help me and any suggestions

<<Text removed>>

Thanks

reddy.

Edited by: Matt on Jul 27, 2011 9:21 AM

1 ACCEPTED SOLUTION
Read only

lijisusan_mathews
Active Contributor
0 Likes
1,044

in field catalog for amount , add wa_fieldcat-do_sum = 'X'.

now in your alv, there will be a sort table it_sort.

pass values as follows into it

wa_sort-fieldname = 'VENdor fieldname'

wa_sort-subtot = 'x'.

append wa_sort to lt_sort.

wa_sort-fieldname = 'GL account'

wa_sort-subtot = 'x'.

append wa_sort to lt_sort.

Hello experts,

I have ALV grid with vendor, g/l account and amount field.

I want to have sum or total of each vendor, and if vendor having mutliple g/l accounts i want to have sum for each g/l account.

ex: vendor g/l account amount.

10 aa 100

10 bb 200

11 cc 300

olp : 10 aa 100

10 bb 200

11 cc 300

ex2 : vendor g/ account amount

10 aa 100

10 aa 200

11 cc 300

o/p 10 aa 300.

11 cc 300.

Could you please help me and any suggestions

<<Text removed>>

Thanks

reddy.

Edited by: Matt on Jul 27, 2011 9:21 AM

8 REPLIES 8
Read only

lijisusan_mathews
Active Contributor
0 Likes
1,045

in field catalog for amount , add wa_fieldcat-do_sum = 'X'.

now in your alv, there will be a sort table it_sort.

pass values as follows into it

wa_sort-fieldname = 'VENdor fieldname'

wa_sort-subtot = 'x'.

append wa_sort to lt_sort.

wa_sort-fieldname = 'GL account'

wa_sort-subtot = 'x'.

append wa_sort to lt_sort.

Read only

0 Likes
1,044

Hello,

I have tried this, It sums only on vendor, if account number is same than it does't work out.

Thanks to let me know if you have any other idea.

Thanks.

Reddy

Read only

0 Likes
1,044

have you placed the sort field for vendor first and then teh GL account.. Also include the col_pos number.. vendor should comefirst , then GL account. Is it still not sub totaling?

Read only

0 Likes
1,044

Hi,

First you need to sort vendor and GL account. Then Sum the amount. Then subtotal for both vendor and GL account.

So sort and sub total for vendor and GL accounts in the fireld catalog and then sum for amount.

hope this helps.

Thanks,

Venkatesh.

Read only

0 Likes
1,044

Hello,

Yes this has done!!! Issue is not solved.

I see the total only for vendor, But if G/l account is same than I see separate lines.

Thanks,

Reddy

Read only

0 Likes
1,044

Assuming that in the field catalog and output screen too vendor appears before GL account no.. can you try the following

Run your report and in the output and now you should be able to see the total line..

Now first select the vendor column and now select the next column ie GL account. ( so now 2 columns will be selected) now click on the Sub total button in the application tool bar. Do you now get the sub totals??/

If not yet , can you place relevant parts of your code including you r field catalog please

Read only

0 Likes
1,044

Reddy,

The solution posted bu Suzie in the first post surely works, we are using same scenarios in our codes and it works well.

Please paste your Sort and Fieldcatalog code for finding the issue.

BR,

Diwakar

Read only

Former Member
0 Likes
1,044

Hello Reddy,

Try using the sort functionality of ALV grid

CALL METHOD grid1->set_table_for_first_display

EXPORTING

i_save = 'A'

is_layout = lwa_layout

it_toolbar_excluding = i_excl_func

i_default = c_x

CHANGING

it_outtab = i_outtab[]

it_fieldcatalog = i_fieldcat[]

it_sort = li_sort[] "use this functionality as per your requirement

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

Hope this may be helpful.

Sharin