11-07-2008 11:08 AM
Subject changed to something more useful. Please do likewise in future.
HI FRIENDS,
I have a scenario like i need to print the text 'grand total' beside the grand total value in alv grid.i displayed grand total using do_sum.
thanks®ards
urmila.T
Edited by: Matt on Nov 7, 2008 1:01 PM
11-07-2008 11:14 AM
Hi........
You can not display any text with the subtotal...... calculated as this is calculated by standard sap itself.....
if you want any modifications..... then use footer concept in alv...
Thnks
Saurabh
11-07-2008 11:12 AM
Hi,,,,,, Urmila
The subtotal is generally calculated by Standard SAP automatically......
If you want any modifications or additions in that then you have to use Footer in your alv.....
in which you can display your text with the total.....
do let me know if you nedd any thing else......
Thanks
Saurabh
11-07-2008 11:14 AM
Hi,
Use this code....
CLEAR wa_event.
wa_event-name = 'TOP_OF_PAGE'.
wa_event-form = 'TOP_OF_PAGE'.
APPEND wa_event TO t_event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
* i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = l_layout
is_print = l_print
it_sort = it_sort
it_filter = it_filter
it_fieldcat = t_fieldcat[]
it_events = t_event
it_event_exit = it_event_exit
TABLES
t_outtab = it_vbap
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. " create_alv_output
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
FORM top_of_page.
DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
* get the global reference
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_grid.
* get the subtotal
DATA: it_01 TYPE REF TO data.
CALL METHOD lo_grid->get_subtotals
IMPORTING
ep_collect01 = it_01.
* change the data
FIELD-SYMBOLS: <ft_tab> TYPE ANY TABLE,
<fs_tab> TYPE ANY,
<fs_value1> TYPE ANY,
<fs_value2> TYPE ANY,
<ff_field> TYPE ANY.
ASSIGN it_01->* TO <ft_tab>.
LOOP AT <ft_tab> ASSIGNING <fs_tab>.
ASSIGN COMPONENT 'VBELN' OF STRUCTURE <fs_tab> TO <ff_field>.
<ff_field> = 'Total'.
ENDLOOP.
* Refresh the table display
CALL METHOD lo_grid->refresh_table_display
EXPORTING
i_soft_refresh = 'X'.
ENDFORM. " top_of_page
Edited by: Sukriti Saha on Nov 7, 2008 4:44 PM
11-07-2008 11:14 AM
Hi........
You can not display any text with the subtotal...... calculated as this is calculated by standard sap itself.....
if you want any modifications..... then use footer concept in alv...
Thnks
Saurabh
11-07-2008 11:17 AM
hi ,
can u plz be more clear i am using oop alv to display my grid
urmila.T
11-07-2008 11:20 AM
11-07-2008 11:25 AM
11-07-2008 11:32 AM
11-07-2008 11:45 AM
TYPES : BEGIN OF TP_SAL,
..........
TEXT TYPE CHAR40, "Field to store sub total text
TEXTT TYPE CHAR40, "Field to store grand total text
.........
end of tp_sal.
DATA : IG_SAL TYPE TABLE OF TP_SAL.
DATA : WG_SAL TYPE TP_SAL.
LOOP AT IG_SAL INTO WG_SAL.
WG_SAL-TEXTT = 'Grand Total'.
CONCATENATE 'SubTotal:' WG_SAL-VBELN INTO WG_SAL-TEXT.
MODIFY IG_SAL FROM WG_SAL.
ENDLOOP.
CLASS LCL_EVENT_HANDLER DEFINITION.
.................
HANDLE_SUBTOTAL_TEXT FOR EVENT SUBTOTAL_TEXT OF CL_GUI_ALV_GRID
IMPORTING ES_SUBTOTTXT_INFO EP_SUBTOT_LINE E_EVENT_DATA.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
................
METHOD HANDLE_SUBTOTAL_TEXT.
PERFORM SUBTOTAL_TEXT USING ES_SUBTOTTXT_INFO
EP_SUBTOT_LINE
E_EVENT_DATA.
ENDMETHOD. "HANDLE_SUBTOTAL_TEXT
FORM SUBTOTAL_TEXT USING ES_SUBTOTTXT_INFO TYPE LVC_S_STXT
EP_SUBTOT_LINE TYPE REF TO DATA
E_EVENT_DATA TYPE REF TO CL_ALV_EVENT_DATA.
FIELD-SYMBOLS: <FS> TYPE ANY.
ASSIGN E_EVENT_DATA->M_DATA->* TO <FS>.
ENDFORM. " subtotal_text1
MODULE STATUS_3000 OUTPUT.
..................
CREATE OBJECT GR_EVENT_HANDLER.
SET HANDLER GR_EVENT_HANDLER->HANDLE_SUBTOTAL_TEXT FOR GR_ALVGRID.
..........
ENDMODULE.
11-07-2008 12:06 PM
hi sreekanth,
i think its code for displaying subtotal text
urmila.T
11-07-2008 12:38 PM