10-10-2007 3:04 PM
Hi,
I am using 'ALV_GRID_DISPLAY'. i need to have a subtotal in the output based on two fields of my output (vendor and period).
any one help please
Thanks in advance.
10-10-2007 3:14 PM
Hi,
In your fieldcat add this to your fields.
i_fieldcat-col_pos = '10'. " POSITION OF THE COLUMN.
i_fieldcat-fieldname = 'LFIMG'. " FIELD FOR WHICH CATALOG ID FILLED.
i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
<b>i_fieldcat-do_sum = 'X'.</b> i_fieldcat-seltext_l = 'LFIMG'. " LONG TEXT FOR HEADER.
i_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.
i_fieldcat-ref_tabname = 'LIPS'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
append i_fieldcat to p_i_fieldcat.
In your layout write this,
i_layout-zebra = 'X'.
<b> i_layout-totals_text = 'Total'.
i_layout-subtotals_text = 'SubTotal'</b>.
i_layout-box_tabname = 'IT_FINAL'
Also add this in your sortinfo,
clear i_sortinfo.
i_sortinfo-spos = '1'.
i_sortinfo-fieldname = 'VBELN'.
i_sortinfo-tabname = 'IT_FINAL'.
i_sortinfo-up = 'X'.
i_sortinfo-group = 'UL'. " I.E UNDERLINE AFTER EVERY GROUP
<b>i_sortinfo-subtot = 'X'.</b>
Regards,
PRitha.
Reward if useful.
10-10-2007 3:11 PM
i think u can use subtotal in numeric fields not any non-numerics fields like units(kg)..
10-10-2007 3:11 PM
Use "Subtotal_text" in events table.
here GTOTAL is field in itab on which we sortindf data, and use your own field on which field u want to sort...
refresh gt_event.
clear gw_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_event.
*
Subtotal
read table gt_event with key name = slis_ev_subtotal_text into gw_event.
if sy-subrc = 0.
move 'SUBTOTAL_TEXT' to gw_event-form.
append gw_event to gt_event.
endif.
form subtotal_text using uw_subtot_line type ty_main
uv_subtottxt type slis_subtot_text. "#EC CALLED
*
if uv_subtottxt-criteria = 'GTOTAL'.
uv_subtottxt-display_text_for_subtotal = 'TOTAL'.
endif.
*
*FORM build_sort .
*
refresh gt_sort.
*
gw_sort-spos = 1.
gw_sort-fieldname = 'GTOTAL'.
gw_sort-tabname = 'GT_MAIN'.
gw_sort-up = 'X'.
gw_sort-subtot = 'X'.
APPEND gw_sort TO gt_sort.
CLEAR gw_sort.
10-10-2007 3:14 PM
Hi,
In your fieldcat add this to your fields.
i_fieldcat-col_pos = '10'. " POSITION OF THE COLUMN.
i_fieldcat-fieldname = 'LFIMG'. " FIELD FOR WHICH CATALOG ID FILLED.
i_fieldcat-tabname = 'IT_FINAL'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
i_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
<b>i_fieldcat-do_sum = 'X'.</b> i_fieldcat-seltext_l = 'LFIMG'. " LONG TEXT FOR HEADER.
i_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.
i_fieldcat-ref_tabname = 'LIPS'. " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
append i_fieldcat to p_i_fieldcat.
In your layout write this,
i_layout-zebra = 'X'.
<b> i_layout-totals_text = 'Total'.
i_layout-subtotals_text = 'SubTotal'</b>.
i_layout-box_tabname = 'IT_FINAL'
Also add this in your sortinfo,
clear i_sortinfo.
i_sortinfo-spos = '1'.
i_sortinfo-fieldname = 'VBELN'.
i_sortinfo-tabname = 'IT_FINAL'.
i_sortinfo-up = 'X'.
i_sortinfo-group = 'UL'. " I.E UNDERLINE AFTER EVERY GROUP
<b>i_sortinfo-subtot = 'X'.</b>
Regards,
PRitha.
Reward if useful.
10-10-2007 3:14 PM
DATA: lv_sort TYPE slis_sortinfo_alv,
gt_sort TYPE slis_t_sortinfo_alv,
lv_sort-fieldname = 'BUKRS'. " Sort by Co Code
lv_sort-tabname = 'GT_TRANSDT'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO gt_sort.
lv_sort-fieldname = 'BELNR'. " Sort by G/L accounts
lv_sort-tabname = 'GT_TRANSDT'.
lv_sort-subtot = 'X'.
APPEND lv_sort TO gt_sort.
pass gt_sort in the function module.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = gv_repid
i_callback_pf_status_set = gv_status
i_callback_user_command = 'F_FB03'
I_CALLBACK_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 = gs_layout
it_fieldcat = gt_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
<b> it_sort = gt_sort[]</b>
IT_FILTER =
IS_SEL_HIDE =
i_default = 'A'
i_save = gv_save
is_variant = gv_variant
it_events = gt_events[]
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 = gt_transdt_line
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.