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: 

subtotal in alv report

Former Member
0 Kudos

how to create subtotals in alv report. I am useing

func module 'alv_list_display'.

5 REPLIES 5

Former Member
0 Kudos

If you can give inputs to the SORT table of the REUSE_ALV_LIST_DISPLAY and also activate the DO_SUM in the field catalog for the fields which you want to total up, the subtotal can be done.

See this thread for sample code

Regards,

Ravi

Note : Please mark all the helpful answers

Message was edited by: Ravikumar Allampallam

0 Kudos

Hi,

I think below threads will solve your problem:

Former Member
0 Kudos

Hi Charles,

In order to do the sub-total the main total has to be calculated and then the sub-total process can be performed.

In the main fieldcat mark this field

wa_line_fieldcat-fieldname = 'VALUE'.

wa_line_fieldcat-tabname = 'I_OUTPUT'.

wa_line_fieldcat-reptext = text-021.

<b>wa_line_fieldcat-do_sum = 'X'.</b>

APPEND wa_line_fieldcat TO i_fieldcat.

this will do the main total part.

<b>Sub-total:</b>

you will have to create an internal table sort

CLEAR struct_sort.

struct_sort-spos = 1.

struct_sort-fieldname = 'VALUE'.

struct_sort-up = 'X'.

<b>struct_sort-subtot = 'X'.</b>

APPEND struct_sort TO i_sort.

Now pass these two internal tables to the display

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

........

<b>IT_SORT = i_sort</b>

TABLES

<b>t_outtab = I_OUTPUT</b>

Hope this solves ur issue.

Reward if helpful.

Regards,

Tushar

Message was edited by: Tushar Marshall Dass

Former Member
0 Kudos

Hi,

In the FM module 'reuse_alv_list_display', there will be export parameter called IT_SORT[]. To hich you have to prepare the data and pass.

(Example)

DATA: lt_sort type SLIS_T_SORTINFO_ALV,

ls_sort type slis_sortinfo_alv.

ls_sort-fieldname = 'XXX'. "Column name for subtotal

ls_sort-tabname = '<ITAB>'.

ls_sort-up = 'X'.

ls_sort-subtotal = 'X'.

append ls_sort to lt_sort.

Now pass this table lt_sort to "'reuse_alv_list_display".

Regs,

Venkat Ramanan N

Former Member
0 Kudos

Hai Charles

Check the following Example Codes

Refer to this similar thread.

for sub totals you have to use

sort table.

sort-fieldname = 'VBELN'.

sort-tabname = 'ITAB'.

sort-up = 'X'.

sort-subtot = 'X'.

append sort to it_sort.

Or

Define SORT table and FIELDCATALOG table .

Data :i_field type slis_t_fieldcat_alv,

w_field like line of i_field,

i_sort type slis_t_sortinfo_alv,

w_sort like line of i_sort.

2.Grand Total

While buildingfieldcatalog,We have to set DO_SUM = 'X' for quantity field .

ex.

w_field-fieldname = 'MENGE'.

w_field-tabname = 'I_TAB'.

w_field-DO_SUM = 'X'.

append w_field to i_field.

clear w_field.

3.Subtotal

Whenever WERKS is changed Subtotal is displayed .

Build sort table .

Clear: w_sort,i_sort[].

w_sort-spos = 1.

w_sort-fieldname = 'WERKS'.

w_sort-up = 'X'.

w_sort-subtot = 'X'.

append w_sort to i_sort.

clear w_sort.

4.

Pass this I_SORT table thru REUSE_ALV_LIST_DISPLAY function module ..like fieldcatalog table.

Or

For sub totals you need to sort and pass the sort table to FM.

But for total you need to pass to field catalog like below

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'. "Display column total

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

Thanks & regards

Sreeni