2008 Jun 10 11:41 AM
Here is how i am getting my ALV output
DATA: gt_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
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'.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZPS_NI_SAVING'
CHANGING
ct_fieldcat = gt_fieldcat.
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
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.
Structure ZPS_NI_SAVING contains
DIVISION
DIVISION_TXT
COST_CENTRE
PERNR
LEVEL
SCHEME
EES_SACRIFICE
ERS_CONTRIB
NI_SAVING
TOTAL_PEN_SAV
I want the subtotal of EES_SACRIFICE and ERS_CONTRIB for DIVISION
Please let me know how to get the subtotals
2008 Jun 10 12:11 PM
Hi,
data: gt_sort type LVC_T_SORT.
data: w_sort like line of gt_sort.
Just loop at athat fieldcat and pass the do-sum = 'X'.
Loop at gt_fieldcat into gw_fieldcat.
if gw_fieldcat-fieldname = 'DIVISION'.
gw_fieldcat-do_sum = 'X'.
modify gt_fieldcat from gw_fieldcat transportiong do_sum.
endif.
endloop.
W_SORT-FIELDNAME = 'EES_SACRIFICE'
W_SORT-UP = 'X'.
W_SORT-SUBTOT = 'X'.
APPEND W_SORT TO GT_SORT.
W_SORT-FIELDNAME = 'ERS_CONTRIB'
W_SORT-UP = 'X'.
W_SORT-SUBTOT = 'X'.
APPEND W_SORT TO GT_SORT.
Pass this gt_sort to IT_SORT in the method set_table_for_first_display.
I think it will be useful for you.
\[removed by moderator\]
Thanks & regards
Deepika
Edited by: Jan Stallkamp on Jun 10, 2008 1:42 PM
2008 Jun 10 11:59 AM
Hi,
Fill sortcat. In sortcat u wil find total .
fill total = 'X'
2008 Jun 10 12:10 PM
I have found that i need to pass internal table of the type LVC_T_SORT
in my method
can you specify what to pass for what fields of my output?
2008 Jun 10 12:11 PM
Hi,
data: gt_sort type LVC_T_SORT.
data: w_sort like line of gt_sort.
Just loop at athat fieldcat and pass the do-sum = 'X'.
Loop at gt_fieldcat into gw_fieldcat.
if gw_fieldcat-fieldname = 'DIVISION'.
gw_fieldcat-do_sum = 'X'.
modify gt_fieldcat from gw_fieldcat transportiong do_sum.
endif.
endloop.
W_SORT-FIELDNAME = 'EES_SACRIFICE'
W_SORT-UP = 'X'.
W_SORT-SUBTOT = 'X'.
APPEND W_SORT TO GT_SORT.
W_SORT-FIELDNAME = 'ERS_CONTRIB'
W_SORT-UP = 'X'.
W_SORT-SUBTOT = 'X'.
APPEND W_SORT TO GT_SORT.
Pass this gt_sort to IT_SORT in the method set_table_for_first_display.
I think it will be useful for you.
\[removed by moderator\]
Thanks & regards
Deepika
Edited by: Jan Stallkamp on Jun 10, 2008 1:42 PM
2008 Jun 10 12:15 PM
Hi,
You need to fill i_sort internal table of type LVC_T_SORT, there you can pass 'FIELDNAME' and pass 'X' to 'SUBTOT', then last pass this internal table to IT_SORT of method 'SET_TABLE_FOR_FIRST_DISPLAY'.
Before this you need to pass 'X' to the field DO_SUM of field catelog.
Check the below code.....
wa-Fieldname = 'MATNR'.
wa-SORT = 'X'.
wa-up = 'X'.
append wa to i_sort.
Rgds,
Bujji