2011 Jul 20 9:19 AM
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
2011 Jul 20 9:34 AM
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.
2011 Jul 20 9:34 AM
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.
2011 Jul 20 10:42 AM
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
2011 Jul 20 10:52 AM
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?
2011 Jul 20 10:58 AM
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.
2011 Jul 20 11:13 AM
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
2011 Jul 20 11:33 AM
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
2011 Jul 27 9:43 AM
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
2011 Jul 20 9:38 AM
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