Hi Fnd, There is no special function module for subtotal.we have to make some calculations on field_caltalog fieds. I will send some code.That must be very much helpful for u.plz copy the below code and execute ur problem is solved..
code:
*----------------------------------------------------------------------* * Type Pools *----------------------------------------------------------------------* TYPE-POOLS:slis.
*----------------------------------------------------------------------* * Global Variable *----------------------------------------------------------------------* data: w_var type i. *----------------------------------------------------------------------* * Global Data *----------------------------------------------------------------------* DATA:it_fieldcat TYPE slis_t_fieldcat_alv, wa_fieldcat TYPE slis_fieldcat_alv, it_sortcat TYPE slis_t_sortinfo_alv, wa_sortcat LIKE LINE OF it_sortcat.
*----------------------------------------------------------------------* * Internal Table *----------------------------------------------------------------------* data: BEGIN OF it_salesorder OCCURS 0,
vbeln LIKE vbak-vbeln, " Sales Document Number posnr like vbap-posnr, " Sales Doc Item netwr like vbap-netwr, " Net Value
END OF it_salesorder.
*----------------------------------------------------------------------* * SELECT OPTIONS *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document Number. SELECTION-SCREEN END OF BLOCK b1.
*----------------------------------------------------------------------* * Initialization *----------------------------------------------------------------------* INITIALIZATION. PERFORM initialization. *&---------------------------------------------------------------------* *& Form initialization *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form initialization . s_vbeln-sign = 'I'. s_vbeln-option = 'BT'. s_vbeln-low = '4969'. s_vbeln-high = '5000'. APPEND s_vbeln. endform. " initialization
*----------------------------------------------------------------------* * Start Of Selection *----------------------------------------------------------------------* START-OF-SELECTION. PERFORM field_catalog. "For Structure Creation PERFORM fetch_data. "Get the Data From DB Table PERFORM sorting USING it_sortcat.
*----------------------------------------------------------------------* * End Of Selection *----------------------------------------------------------------------* END-OF-SELECTION. perform display_data.
*&---------------------------------------------------------------------* *& Form field_catalog *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form field_catalog .
wa_fieldcat-col_pos = w_var. " Column Position Variable wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name wa_fieldcat-fieldname = 'VBELN'. " Field Name wa_fieldcat-key = 'X'. " Blue Color wa_fieldcat-ref_tabname = 'VBAK'. " Table Name wa_fieldcat-ref_fieldname = 'VBELN'. " Field Name wa_fieldcat-seltext_m = 'Sales Doc No'. " Display Text In Screen APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. ADD 1 TO w_var.
wa_fieldcat-col_pos = w_var. " Column Position Variable wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name wa_fieldcat-fieldname = 'POSNR'. " Field Name wa_fieldcat-ref_tabname = 'VBAP'. " Table Name wa_fieldcat-ref_fieldname = 'POSNR'. " Field Name wa_fieldcat-seltext_m = 'Sales Doc Item'. " Display Text In Screen APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. ADD 1 TO w_var.
wa_fieldcat-col_pos = w_var. " Column Position Variable wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name wa_fieldcat-fieldname = 'NETWR'. " Field Name wa_fieldcat-ref_tabname = 'VBAP'. " Table Name wa_fieldcat-ref_fieldname = 'NETWR'. " Field Name wa_fieldcat-do_sum = 'X'. " Sum wa_fieldcat-seltext_m = 'Net Value'. " Display Text In Screen APPEND wa_fieldcat TO it_fieldcat. CLEAR wa_fieldcat. ADD 1 TO w_var. endform. " field_catalog *&---------------------------------------------------------------------* *& Form sorting *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_IT_SORTCAT text *----------------------------------------------------------------------* form sorting using p_it_sortcat TYPE slis_t_sortinfo_alv. wa_sortcat-fieldname = 'VBELN'. wa_sortcat-up ='X'. wa_sortcat-subtot = 'X'. APPEND wa_sortcat TO p_it_sortcat. endform. " sorting *&---------------------------------------------------------------------* *& Form display_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form display_data . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' I_CALLBACK_PROGRAM = SY-REPID * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * 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 = IT_FIELDCAT = it_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = IT_SORT = it_sortcat * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' * I_SAVE = ' ' * IS_VARIANT = * IT_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 = it_salesorder 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. " display_data *&---------------------------------------------------------------------* *& Form fetch_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form fetch_data . select a~vbeln posnr b~netwr from vbak as a inner join vbap as b on a~vbeln = b~vbeln into table it_salesorder where a~vbeln in s_vbeln.
What are the function modules used to get sub totals in ALV'S?
Profile Answers by charath Questions by charath
Questions by charath