Skip to Content
0
Former Member
Dec 11, 2013 at 10:50 AM

Totals and subtotals in alv grid

24 Views


Hi,

I want to display total in alv output. Am using do_sum = X in my fieldcatalog, but the total does not appear untill i press the summation icon.

Can anyone help me in this.

I want the subtotals too.

my fieldcatalog :

CLEAR: gs_field_catalog.
* gs_field_catalog-col_pos = '20'.
gs_field_catalog-fieldname = 'INVOICE_AMOUNT'.
* gs_field_catalog-ref_fieldname = 'WRBTR'.
* gs_field_catalog-ref_tabname = 'BSID'.
* gs_field_catalog-cfieldname = 'WAERS'.
gs_field_catalog-tabname = 'LT_INVOICE'.
gs_field_catalog-seltext_m = 'Invoice Amount'.
* gs_field_catalog-datatype = 'CURR'.
* gs_Field_catalog-inttype = 'P'.
* gs_field_catalog-do_sum = 'X'.
APPEND gs_field_catalog TO gt_field_catalog.

CLEAR: gs_field_catalog.
* gs_field_catalog-col_pos = '21'.
gs_field_catalog-fieldname = 'OPEN_AMOUNT'.
* gs_field_catalog-ref_fieldname = 'WRBTR'.
* gs_field_catalog-ref_tabname = 'BSID'.
* gs_field_catalog-cfieldname = 'WAERS'.
gs_field_catalog-tabname = 'LT_INVOICE'.
gs_field_catalog-seltext_m = 'Open Amount'.
* gs_field_catalog-datatype = 'CURR'.
* gs_Field_catalog-inttype = 'P'.
* gs_field_catalog-do_sum = 'X'.
APPEND gs_field_catalog TO gt_field_catalog.

CLEAR: gs_field_catalog.
* gs_field_catalog-col_pos = '22'.
gs_field_catalog-fieldname = 'PAID_AMOUNT'.
* gs_field_catalog-ref_fieldname = 'WRBTR'.
* gs_field_catalog-ref_tabname = 'BSID'.
* gs_field_catalog-cfieldname = 'WAERS'.
gs_field_catalog-tabname = 'LT_INVOICE'.
gs_field_catalog-seltext_m = 'Paid Amount'.
* gs_field_catalog-datatype = 'CURR'.
* gs_Field_catalog-inttype = 'P'.
* gs_field_catalog-do_sum = 'X'.
APPEND gs_field_catalog TO gt_field_catalog.

CLEAR: gs_field_catalog.
* gs_field_catalog-col_pos = '23'.
gs_field_catalog-fieldname = 'RESERVED_AMOUNT'.
* gs_field_catalog-ref_fieldname = 'WRBTR'.
* gs_field_catalog-ref_tabname = 'BSID'.
gs_field_catalog-tabname = 'LT_INVOICE'.
* gs_field_catalog-cfieldname = 'WAERS'.
gs_field_catalog-seltext_m = 'Reserved Amount'.
* gs_field_catalog-datatype = 'CURR'.
* gs_Field_catalog-inttype = 'P'.
* gs_field_catalog-do_sum = 'X'.
APPEND gs_field_catalog TO gt_field_catalog.

CLEAR: gs_field_catalog.
* gs_field_catalog-col_pos = '24'.
gs_field_catalog-fieldname = 'CURRENCY'.
* gs_field_catalog-ref_tabname = 'BSID'.
* gs_field_catalog-ref_fieldname = 'WAERS'.
gs_field_catalog-tabname = 'LT_INVOICE'.
* gs_field_catalog-reptext_ddic = 'Currency'.
gs_field_catalog-seltext_m = 'Currency'.
APPEND gs_field_catalog TO gt_field_catalog.

my data declaration :

TYPES : BEGIN OF ty_invoice,
partner LIKE zoam_invoice-partner,
alt_payee LIKE zoam_invoice-alt_payee,
owner LIKE VIBPOBJREL-partner,
sgenr LIKE zoam_invoice-sgenr,
swenr LIKE zoam_invoice-swenr,
zzfl_unit_no LIKE zoam_invoice-zzfl_unit_no,
RECNNR LIKE zoam_invoice-RECNNR,
ALLOC_FACTOR LIKE ZOAM_INVOICE-ALLOC_FACTOR,
ref_inv_no LIKE zoam_invoice-ref_inv_no,
reversed LIKE zoam_invoice-reversed,
cust_inv_num LIKE zoam_invoice-cust_inv_num,
inv_type LIKE zoam_invoice-inv_type,
invt_Des LIKE ZOAM_INV_TYPE_T-INV_TYPE_DESC,
invoice_no LIKE zoam_invoice-invoice_no,
gjahr LIKE zoam_invoice-gjahr,
blart LIKE zoam_invoice-blart,
bldat LIKE zoam_invoice-bldat,
inv_due_date LIKE zoam_invoice-inv_due_date,
curr_due_date LIKE zoam_invoice-curr_due_date,
penalty_cal_date LIKE zoam_invoice-penalty_cal_date,
invoice_Amount LIKE zoam_invoice-invoice_amount ,
open_amount LIKE bsid-wrbtr,
paid_amount LIKE bsid-wrbtr,
reserved_Amount LIKE bsid-wrbtr,
currency LIKE bsid-waers,
waers TYPE waers,
END OF ty_invoice,

Sort for subtotals

wa_sort-spos = 1.
wa_sort-fieldname = 'SGENR'.
wa_sort-tabname = 'LT_INVOICE'.
wa_sort-up = 'X'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.

wa_sort-spos = 1.
wa_sort-fieldname = 'ZZFL_UNIT_NO'.
wa_sort-tabname = 'LT_INVOICE'.
wa_sort-up = 'X'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.