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: 

Regarding the 'TOTALS' in ALV's

Former Member
0 Kudos

Hi friends,

I have a doubt in ALV while displaying totals.

How can we display the "totals" immediately when the ALV output is displayed. I tried many ways but when im clicking on the 'Summation' symbol in the output of the ALV then only the 'Totals' or 'Subtotals' are being displayed.

Please give me some helpfull tips...

Regards

Pradeep Goli

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check these examples for displaying TOTAL in ALV.

How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

Hope this will help you to get the idea of how to display Totals in ALV.

ashish

3 REPLIES 3

Former Member
0 Kudos

hi,

take reference of this exp...

********************************************************************

*FORM FOR DISPLAY DATA

********************************************************************

FORM display_data.

PERFORM fill_layout_structure.

PERFORM fill_field_catalog_table.

PERFORM get_event USING it_event.

PERFORM fill_listheader USING it_listheader.

PERFORM call_alv_function.

ENDFORM. "display_data

********************************************************************

*FORM FOR ALV LAYOUT STRUCTURE

********************************************************************

FORM fill_layout_structure.

CLEAR st_layout.

  • st_layout-colwidth_optimize = 'X'.

st_layout-zebra = 'X'.

st_layout-f2code = '&ETA'.

st_layout-detail_popup = 'X'.

st_layout-colwidth_optimize = 'X'.

ENDFORM. "fill_layout_structure

********************************************************************

*FORM FOR ALV FIELD CATALOG TABLE

********************************************************************

FORM fill_field_catalog_table .

PERFORM fill_field_catalog USING :

'SAKNR' 'G/L Account No' 15 'IT_DATA' 'X' space,

'TXT50' 'A/C Description' 50 'IT_DATA' space space,

'BO' 'BO' 15 'IT_DATA' space 'X',

'FACT' 'Factories' 15 'IT_DATA' space 'X',

'TOTAL_BO' 'BO Total' 15 'IT_DATA' space 'X'.

ENDFORM. "fill_field_catalog_table

********************************************************************

*FORM FOR FILLING FIELD CATALOG

********************************************************************

FORM fill_field_catalog USING f d l t p s.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

STATICS v_pos TYPE i VALUE 1.

wa_fieldcat-row_pos = 1.

wa_fieldcat-col_pos = v_pos.

wa_fieldcat-fieldname = f.

wa_fieldcat-seltext_m = d.

wa_fieldcat-tabname = t.

wa_fieldcat-outputlen = l.

wa_fieldcat-fix_column = p.

wa_fieldcat-do_sum = s.

APPEND wa_fieldcat TO it_fieldcat.

v_pos = v_pos + 1.

ENDFORM. "fill_field_catalog

********************************************************************

*FORM FOR ALV FUNCTIONS

********************************************************************

FORM call_alv_function.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = st_layout

it_fieldcat = it_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

it_events = it_event[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_data[]

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "call_alv_function

Former Member
0 Kudos

Hi Pradeep

In your fieldcatalog add

FIELDCATALOG-DO_SUM = 'X'.

APPEND FIELDCATALOG.

NIKHIL

Former Member
0 Kudos

Hi,

Check these examples for displaying TOTAL in ALV.

How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

Hope this will help you to get the idea of how to display Totals in ALV.

ashish