Skip to Content
0
Feb 13, 2019 at 06:24 AM

Getting Column Totals in a OO ALV

39 Views

I recently created an OO ALV using cl_gui_alv_grid. I need to make it so that at run time 2 of the columns have visible totals that I can reference later as values.


I have tried adding do_sum to each field when building my field catalog but nothing seems to happen. Here is my code.

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

DATA: ls_fcat TYPE lvc_s_fcat.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZUS_PAYROLL'
i_client_never_display = 'X'
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

LOOP AT gt_fcat INTO ls_fcat.
CASE ls_fcat-fieldname.

WHEN 'CRED_AMOUNT'.
ls_fcat-outputlen = '10'.
ls_fcat-do_sum = 'X'.
MODIFY gt_fcat FROM ls_fcat TRANSPORTING do_sum.

WHEN 'DEBI_AMOUNT'.
ls_fcat-outputlen = '10'.
ls_fcat-do_sum = 'X'.
MODIFY gt_fcat FROM ls_fcat TRANSPORTING do_sum.

Please tell me what I am missing to make the totoals appear.