06-10-2008 1:52 PM
Hi,
Is it possible to calculate subtotals using reuse_alv_list_display instead of using reuse_alv_grid_display.
Also i want to print sub-headings using ALV.
Ex:
Under the column Mark
i want the subject names as sub_heading.
_______________________________________________
MARKS
ENG HINDI MATHS SCIENCE
________________________________________________
Like this i want output.
Thanx in advance.
06-10-2008 1:55 PM
Hi Anitha,
WELCOME TO SDN!!!
Please check this link
http://www.saptechnical.com/Tutorials/ALV/Subtotals/Define.htm
Best regards,
raam
06-10-2008 2:26 PM
HI Anitha
Initially you need to have the following coloumns in your internal table
CLASS
ROLL NO.
ENG
HINDI
MATHS
SCIENCE
Populate the internal table with values.
Please refer for ALV output
http://www.sap-partner.hu/ABAP_HELP_INFO/An%20Easy%20Reference%20for%20ALV%20Grid%20Control.pdf
Code for your ALV
CALL SCREEN 100.
* SCREEN PROGRAM SHOULD CONTAIN
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE create_alv.
*
PROCESS AFTER INPUT.
MODULE user_command_0100.
* DOUBLE CLICK ON THESE MODULES AND DO THE FOLLOWING CODE
MODULE status_0100 OUTPUT.
* DOUBLE CLICK ON 'S_LIST1' AND CREATE PF-STATUS
SET PF-STATUS 'S_LIST1'.
SET TITLEBAR 'T1'.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE create_alv OUTPUT.
DATA: alv_dock TYPE REF TO cl_gui_docking_container,
alv_grid TYPE REF TO cl_gui_alv_grid,
gt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat,
it_sort TYPE lvc_t_sort,
wa_sort TYPE lvc_s_sort,
CLEAR wa_fieldcat.
wa_fieldcat-tabname = ITAB
wa_fieldcat-fieldname = 'CLASS'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = ITAB
wa_fieldcat-fieldname = 'ID'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = ITAB
wa_fieldcat-fieldname = 'MATHS'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = ITAB
wa_fieldcat-fieldname = 'SCI'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = ITAB
wa_fieldcat-fieldname = 'SOCIAL'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-tabname = ITAB
wa_fieldcat-fieldname = 'ENG'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO gt_fieldcat.
wa_layout-grid_title = sy-title.
wa_layout-zebra = 'X'.
wa_layout-cwidth_opt = 'X'.
wa_layout-sel_mode = 'A'.
wa_layout-info_fname = 'COLOR'.
LOOP AT gt_fieldcat INTO wa_fieldcat.
CASE wa_fieldcat-fieldname.
WHEN 'CLASS' OR 'ID'.
WHEN OTHERS.
wa_fieldcat-do_sum = 'X'.
MODIFY gt_fieldcat FROM wa_fieldcat.
ENDCASE.
ENDLOOP.
wa_sort-fieldname = 'CLASS'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-down = space.
APPEND wa_sort TO it_sort.
CHECK alv_dock IS INITIAL.
CREATE OBJECT alv_dock
EXPORTING
extension = 1200
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0 AND sy-batch IS INITIAL.
MESSAGE a016(pn) WITH 'Unable to create output area'(e01).
ENDIF.
CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_dock
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0 AND sy-batch IS INITIAL.
MESSAGE a016(pn) WITH 'Unable to create output area'(e01).
ENDIF.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZPS_NI_SAVING'
is_layout = wa_layout
* it_toolbar_excluding = t_ui_functions
CHANGING
it_outtab = it_output
it_fieldcatalog = gt_fieldcat
it_sort = it_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE.
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
CALL METHOD: alv_grid->free, alv_dock->free.
FREE: alv_grid, alv_dock.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT