Subtotal in hirarchical alv

Hi,
I've a header table with PERSG field and Item table with a FTE field which is numeric.
In the alv for every PERSG field for which there are multiple records in itam table I want to display subtotals.
And if there are no items for the Header Data the record should not be displayed in the Header as well.
find below is my fieldcatalog.
    W_FCAT-COL_POS = 1.
    W_FCAT-FIELDNAME = 'PERSG'.
    W_FCAT-SELTEXT_M = 'EmployeeGroup'.
    W_FCAT-TABNAME = 'WT_T501T'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 2.
    W_FCAT-FIELDNAME = 'PTEXT'.
    W_FCAT-SELTEXT_M = 'Description'.
    W_FCAT-TABNAME = 'WT_T501T'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 3.
    W_FCAT-FIELDNAME = 'PERNR'.
    W_FCAT-SELTEXT_M = 'PersonnelNo'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 4.
    W_FCAT-FIELDNAME = 'BEGDA'.
    W_FCAT-SELTEXT_M = 'StartDate'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 5.
    W_FCAT-FIELDNAME = 'ENDDA'.
    W_FCAT-SELTEXT_M = 'EndDate'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 6.
    W_FCAT-FIELDNAME = 'PERSK'.
    W_FCAT-SELTEXT_M = 'EmployeeSubgroup'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 7.
    W_FCAT-FIELDNAME = 'CTTYP'.
    W_FCAT-SELTEXT_M = 'ContractType'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 8.
    W_FCAT-FIELDNAME = 'PROZT'.
    W_FCAT-SELTEXT_M = 'WeightagePercentage'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 9.
    W_FCAT-FIELDNAME = 'ANSVH'.
    W_FCAT-SELTEXT_M = 'WorkContract'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 10.
    W_FCAT-FIELDNAME = 'ATX'.
    W_FCAT-SELTEXT_M = 'WorkContractText'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 11.
    W_FCAT-FIELDNAME = 'VORNA'.
    W_FCAT-SELTEXT_M = 'FirstName'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 12.
    W_FCAT-FIELDNAME = 'NACHN'.
    W_FCAT-SELTEXT_M = 'LastName'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 13.
    W_FCAT-FIELDNAME = 'AFTEVA'.
    W_FCAT-SELTEXT_M = 'ActiveFTE'.
    W_FCAT-DO_SUM = 'X'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
    W_FCAT-COL_POS = 14.
    W_FCAT-FIELDNAME = 'AFTEVI'.
    W_FCAT-SELTEXT_M = 'InactiveFTE'.
    W_FCAT-DO_SUM = 'X'.
    W_FCAT-TABNAME = 'WT_FINAL_TAB'.
    APPEND W_FCAT TO T_FCAT.
fs_sort_data-fieldname = 'PERSG'.
fs_sort_data-tabname = 'wt_t501t'.
fs_sort_data-spos = 1.
fs_sort_data-up = 'X'.
fs_sort_data-subtot = 'X'.
fs_sort_data-group = 'X'.
APPEND fs_sort_data TO tsort_data.
CLEAR fs_sort_data.
fs_sort_data-fieldname = 'AFTEVA'.
fs_sort_data-tabname = 'wt_final_tab'.
fs_sort_data-spos = 2.
fs_sort_data-up = 'X'.
fs_sort_data-subtot = 'X'.
APPEND fs_sort_data TO tsort_data.
CLEAR fs_sort_data.
fs_sort_data-fieldname = 'AFTEVI'.
fs_sort_data-tabname = 'wt_final_tab'.
fs_sort_data-spos = 3.
fs_sort_data-up = 'X'.
fs_sort_data-subtot = 'X'.
APPEND fs_sort_data TO tsort_data.
CLEAR fs_sort_data.
Kindly suggest.
full points rewarded for the solution
kumar

Check this sample program
  TYPE-POOLS: slis.
  DATA: BEGIN OF itab OCCURS 0,
          vbeln TYPE vbeln,
          expand,
        END OF itab.
  DATA: BEGIN OF itab1 OCCURS 0,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          matnr TYPE matnr,
          netpr TYPE netpr,
        END OF itab1.
  DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
  DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
  s_fieldcatalog-col_pos = '1'.
  s_fieldcatalog-fieldname = 'VBELN'.
  s_fieldcatalog-tabname   = 'ITAB'.
  s_fieldcatalog-rollname  = 'VBELN'.
  s_fieldcatalog-outputlen = '12'.
  APPEND s_fieldcatalog TO t_fieldcatalog.
  CLEAR: s_fieldcatalog.
  s_fieldcatalog-col_pos = '1'.
  s_fieldcatalog-fieldname = 'VBELN'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'VBELN'.
  s_fieldcatalog-outputlen = '12'.
  APPEND s_fieldcatalog TO t_fieldcatalog.
  CLEAR: s_fieldcatalog.
  s_fieldcatalog-col_pos = '2'.
  s_fieldcatalog-fieldname = 'POSNR'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'POSNR'.
  APPEND s_fieldcatalog TO t_fieldcatalog.
  CLEAR: s_fieldcatalog.
  s_fieldcatalog-col_pos = '3'.
  s_fieldcatalog-fieldname = 'MATNR'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'MATNR'.
  APPEND s_fieldcatalog TO t_fieldcatalog.
  CLEAR: s_fieldcatalog.
  s_fieldcatalog-col_pos = '4'.
  s_fieldcatalog-fieldname = 'NETPR'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'NETPR'.
  s_fieldcatalog-do_sum    = 'X'.
  APPEND s_fieldcatalog TO t_fieldcatalog.
  CLEAR: s_fieldcatalog.
  DATA: s_layout TYPE slis_layout_alv.
  s_layout-subtotals_text            = 'SUBTOTAL TEXT'.
  s_layout-key_hotspot = 'X'.
  s_layout-expand_fieldname = 'EXPAND'.
  SELECT vbeln UP TO 100 ROWS
         FROM vbak
         INTO TABLE itab.
  IF NOT itab[] IS INITIAL.
    SELECT vbeln posnr matnr netpr
           FROM vbap
           INTO TABLE itab1
           FOR ALL ENTRIES IN itab
           WHERE vbeln = itab-vbeln.
  ENDIF.
  DATA: v_repid TYPE syrepid.
  v_repid = sy-repid.
  DATA: s_keyinfo TYPE slis_keyinfo_alv.
  s_keyinfo-header01 = 'VBELN'.
  s_keyinfo-item01   = 'VBELN'.
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
       EXPORTING
            i_callback_program = v_repid
            is_layout          = s_layout
            it_fieldcat        = t_fieldcatalog
            i_tabname_header   = 'ITAB'
            i_tabname_item     = 'ITAB1'
            is_keyinfo         = s_keyinfo
       TABLES
            t_outtab_header    = itab
            t_outtab_item      = itab1
       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.

Similar Messages

  • Subtotal in Blocked ALV

    Hi All,
    I am facing the problem in displaying the subtotal in Blocked ALV.
    My requirement is, I need to display the subtotals in 3 lines like below.
    for ex:
    subtotal:          7 <above total>
                          (5)<coming from someother field>
                           2
    from the above: 7 is total of that column.
                              5 is coming from some other field.
                              2 is substraction of above 2.
    Could anyone please help me in the above.
    Many thanks in advance.
    Regards,
    venkat.

    Hi Vaibhav,
    Thanks for your response.
    and one thing here in my above example is,  the value  5 is neither total nor subtotal. its just a different value coming from some other field.
    only the 7 is total of that column.
    and if I write that logic manually, It may not able display as the position of that column is around 500. because write statment may display upto 252nd position in the output, I guess.
    thank you very much.
    Regards,
    Venkat.
    Edited by: venkat reddy on Jan 18, 2010 8:45 PM

  • How to get subtotal value in ALV list display

    Hi all,
    How to give condition on the value of subtotal line in ALV list display,
    i.e.if value of subtotal of plan quantity = actual quantity (in red oval) it should show the message
    'ON TIME DELIVERY' else it should not show messagee.In my case(shown in red oval) its
    showing for each subtotal value. I know how to change the subtotal text but i want to change
    with respect to value of the subtotal.(plz refer attachment)
    Any input regard to this will be achieved great.
    Many thanks in advance.
    samadhan shinde.

    Hi Samadhan,
    I am awaiting for solution for this problem.....but as i think dynamically displaying sub total based on
    matching actual quantity and planned quantity is bit complicated.
    My idea is to display matched quantities in one block and unmatched  quantities in another. I mean using blocked list.
    awaiting suggestions.
    regards,

  • How to display a row after a subtotal field in ALV Grid

    Hi All,
    My requirement is to print a extra row with values and constant text after printing subtotal values in ALV Grid.
    e.g.      TOTAL      12.23       ---> Subtotal field
                 Tax            5.2         ---> extra row after subtotal field.
    Please help me....
    Thanks in advance.
    Regards
    Ajay

    Hi
    You can try using INSERT <WA> OR INSERT INITIAL LINE .
    fill the wa with tax value.
    INSERT  <wa> into table < internal table > 
    A row will be inserted into internal table with the values.
    Try this  and let me know.
    Thanks
    Hariharan

  • SUBTOTAL TEXT IN ALV GRID

    HI ALL,
    could any one  send me how to display the subtotal Text  in ALV grid output with code sample.
    with thanks.
    kannan

    hi,
    means u want to print some text instead of star ( coming in subtotal) ?
    If so than try like,
    *& Report  ZALV_LIST
    REPORT  zalv_list.
    TABLES : mseg.
    TYPE-POOLS : slis.
    DATA : BEGIN OF itab OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab.
    DATA : BEGIN OF itab1 OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab1.
    DATA : t_fcat TYPE slis_t_fieldcat_alv,
           t_eve TYPE slis_t_event,
           t_subtot TYPE slis_t_sortinfo_alv,
           subtot LIKE LINE OF t_subtot,
           wa_fcat LIKE LINE OF t_fcat,
           gd_layout    TYPE slis_layout_alv.
    DATA : gt_menge LIKE mseg-menge,
           st_menge LIKE mseg-menge.
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : doc FOR mseg-mblnr.
    SELECTION-SCREEN : END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cat USING t_fcat.
      PERFORM build_eve.
      PERFORM build_layout.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM display.
    *&      Form  build_cat
          text
         -->TEMP_FCAT  text
    FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-seltext_m = 'Material Doc.'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MENGE'.
      wa_fcat-seltext_m = 'Quantity'.
    wa_fcat-do_sum = 'Y'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    subtot-spos = 1.
    subtot-fieldname = 'MBLNR'.
    subtot-tabname = 'ITAB'.
    subtot-up = 'X'.
    subtot-group = 'X'.
    subtot-subtot = 'X'.
    subtot-expa = 'X'.
    APPEND subtot TO t_subtot.
    ENDFORM.                    "build_cat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA : wa_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        EXCEPTIONS
          list_type_wrong = 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.
      READ TABLE t_eve WITH KEY name =  slis_ev_top_of_page
                             INTO wa_eve.
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE' TO wa_eve-form.
        APPEND wa_eve TO t_eve.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  build_layout
          text
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-info_fieldname =      'LINE_COLOR'.
      gd_layout-subtotals_text = 'Sub Total'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  get_data
          text
    FORM get_data.
      SELECT mblnr matnr werks menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
      WHERE mblnr IN doc.
      SORT itab BY mblnr.
      LOOP AT itab.
        AT NEW mblnr.
          LOOP AT itab WHERE mblnr = itab-mblnr.
            st_menge = st_menge + itab-menge.
            itab1-mblnr = itab-mblnr.
            itab1-matnr = itab-matnr.
            itab1-werks = itab-werks.
            itab1-menge = itab-menge.
            APPEND itab1.
          ENDLOOP.
          itab1-mblnr = 'Sub_Total'.
          itab1-matnr = ''.
          itab1-werks = ''.
          itab1-menge = st_menge.
          itab1-line_color = 'C710'.
          APPEND itab1.
          itab1-line_color = ''.
          CLEAR st_menge.
        ENDAT.
      ENDLOOP.
      LOOP AT itab.
        gt_menge = gt_menge + itab-menge.
      ENDLOOP.
      itab1-mblnr = 'Total'.
      itab1-matnr = ''.
      itab1-werks = ''.
      itab1-menge = gt_menge.
      itab1-line_color = 'C310'.
      APPEND itab1.
    ENDFORM.                    "get_data
    *&      Form  display
          text
    FORM display.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = 'ZALV_LIST'
         is_layout                      = gd_layout
         it_fieldcat                    = t_fcat
        it_sort                        = t_subtot
         it_events                      = t_eve
        TABLES
          t_outtab                       = itab1
    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
    *&      Form  top_of_page
          text
    FORM top_of_page.
      WRITE:/ 'Data'.
    ENDFORM.                    "top_of_page
    reward if useful....
    Edited by: Dhwani shah on Dec 20, 2007 1:20 PM

  • To activate total & subtotal button in ALV by class

    Hi,
    Kindly suggest how to activate total & subtotal button in ALV by class. I have used layout configuration by lvc_s_layo.
    gs_layout type lvc_s_layo.
    Ashutosh Kumar

    Dears,
    Do_SUM is not available in gs_layout type lvc_s_layo.
    Its working only in function module REUSE_ALV_LIST_DISPLAY.
    How to use in class ALV.
    FORM SUB_CREATE_FIELDCATALOG .
    THIS BELOW FIELD IS EDITABLE
    PERFORM APPEND_FIELDCAT USING:'MATNR'
                                  'Material No.'
                                  'CHAR'
                                  '30'
    PERFORM APPEND_FIELDCAT USING:'MATKL'
                                  'DOCUMENT TYPE'
                                  'CHAR'
                                  '10'
    PERFORM APPEND_FIELDCAT USING:''
                                  'CHAR'
                                  '4'
                                  'C610'
          PERFORM APPEND_FIELDCAT USING:'NTGEW'
                                  'NET WT'
                                  'P'
                                  '10'
                                  'C610'
                                  'X'.
        PERFORM APPEND_FIELDCAT USING:'VOLTO'
                                  'VOLUME'
                                  'P'
                                  '10'
                                  'C610'
                                  'X'.
         PERFORM APPEND_FIELDCAT USING:'VPREH'
                                  'COST'
                                  'P'
                                  '10'
                                  'C610'
    ENDFORM.                    " SUB_CREATE_FIELDCATALOG
    *&      FORM  APPEND_FIELDCAT
          TEXT
         -->P_0116   TEXT
         -->P_0117   TEXT
         -->P_0118   TEXT
         -->P_0119   TEXT
         -->P_0120   TEXT
         -->P_10     TEXT
    FORM APPEND_FIELDCAT  USING    P_114
                                   P_115
                                   P_116
                                   P_117
                                   P_118
                                   P_119.
      CLEAR GT_FIELDCAT_LVC.
      GT_FIELDCAT_LVC-FIELDNAME = P_114.
      GT_FIELDCAT_LVC-COLTEXT = P_115.
      GT_FIELDCAT_LVC-DATATYPE = P_116.
      GT_FIELDCAT_LVC-OUTPUTLEN    = P_117.
      GT_FIELDCAT_LVC-EMPHASIZE = P_118.
      GT_FIELDCAT_LVC-do_sum = P_119.
       append gt_fieldcat_lvc.

  • Subtotal in Dynamic ALV

    Hi,
    Please tell how to perform Subtotal in dynamic ALV Report.
    Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
    Thanks.

    Hi,
    Please tell how to perform Subtotal in dynamic ALV Report.
    Normal Subtotal functionality(the one which is used for static ALV report ) is not working for that.
    Thanks.

  • Reg: Subtotal text in alv grid.

    Hi All,
    I need to display the subtotal text in ALV.
    If:
    data: i_layout type slis_layout_alv.
    Then, we can used
    i_layout-subtotal_text = ‘my subtotal text’.
    But my declaration is :
    Data: ls_layout   type lvc_s_layo.
    This dosnt have subtotaltext.
    I have tried the method:
    method subtotal_text.
        perform event_subtotal_text using es_subtottxt_info
                                          ep_subtot_line
                                          e_event_data.
    and also used the handle.
    as per the coding in : BCALV_TEST_GRID_EVENTS
    Still its not working.
    Waiting for your valuable inputs.
    Thanks & Regards,
    Anjali

    Hi Anjali,
    Try this sample code.
    REPORT z_demo_alv_sort.
    TABLES : vbak.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECT-OPTIONS :
      s_vkorg FOR vbak-vkorg,              " Sales organization
      s_kunnr FOR vbak-kunnr,              " Sold-to party
      s_vbeln FOR vbak-vbeln.              " Sales document
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
    PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    DATA:
      BEGIN OF gt_vbak OCCURS 0,
        vkorg LIKE vbak-vkorg,             " Sales organization
        kunnr LIKE vbak-kunnr,             " Sold-to party
        vbeln LIKE vbak-vbeln,             " Sales document
        netwr LIKE vbak-netwr,             " Net Value of the Sales Order
        waerk LIKE vbak-waerk,             " Document currency
      END OF gt_vbak.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
         Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak
                 UP TO p_max ROWS
              WHERE kunnr IN s_kunnr
                AND vbeln IN s_vbeln
                AND vkorg IN s_vkorg.
    ENDFORM.                               " F_READ_DATA
         Form  f_display_data
    FORM f_display_data.
      DEFINE m_fieldcat.
        add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname   = &1.
        ls_fieldcat-ref_tabname = 'VBAK'.
        ls_fieldcat-do_sum      = &2.
        ls_fieldcat-cfieldname  = &3.
        append ls_fieldcat to lt_fieldcat.
      END-OF-DEFINITION.
      DEFINE m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up        = 'X'.
        ls_sort-subtot    = &2.
        append ls_sort to lt_sort.
      END-OF-DEFINITION.
      DATA:
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,
        lt_sort     TYPE slis_t_sortinfo_alv,
        ls_sort     TYPE slis_sortinfo_alv,
        ls_layout   TYPE slis_layout_alv.
      m_fieldcat 'VKORG' ''  ''.
      m_fieldcat 'KUNNR' ''  ''.
      m_fieldcat 'VBELN' ''  ''.
      m_fieldcat 'NETWR' 'X' 'WAERK'.
      m_fieldcat 'WAERK' ''  ''.
      m_sort 'VKORG' 'X'.                  " Sort by vkorg and subtotal
      m_sort 'KUNNR' 'X'.                  " Sort by kunnr and subtotal
      m_sort 'VBELN' ''.                   " Sort by vbeln
      ls_layout-cell_merge = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           TABLES
                t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA
    Hope this helps,
    Thanks,
    Priya.

  • Displaying subtotal text in alv using the fm reuse_alv_grid_display

    Hi,
    Can someone help me with this, I am having some problem in displaying the subtotal text in subtotal field in alv. I tried populating the layout of the alv with the text that will be displayed on the output but nothing happens. Is is possible to display the subtotal text in alv using the fm reuse_alv_grid_display? If so, what are the things that I must consider to display the subtotal text in alv output.
    Please help me with this. I promise to give you points if you resolve this problem.
    Thanks,
    Gie

    Hi ,
         Make it use in your code and let me know if u have any concerns...
        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.
    Reward points once its useful..

  • Filter data on any one of the field in Hirarchical ALV?

    Hi,
    Can any one tell me if I am using Hirarchical ALV for outputting the data, and I have to filter out the output  data on any one of the column in the Hirarchical ALV, Is it possible ?
    Can we filter out the data on the basis of field which is not the key field in the Hirarchical ALV?
    Mrunal

    Try using IT_FILTER...SLIS_T_FILTER_ALV...I guess...
    santhosh

  • Reg subtotal text in ALV

    Hi,
    How to change the subtotal text in ALV grid display using classes.

    i think if you refresh the grid the subtotals will be refreshed
    CALL METHOD gr_alvgrid->REFRESH_TABLE_DISPLAY.

  • Subtotal text in ALV using OO ALV

    HI All,
    How to display subtotal text in ALV using OO ALV?
    My output of ALV should be as follows
    COL1    COL2   COL3
    ABC      900       M1
    PQR      100       M1
    M1 Subtotal 1000
    XYZ      2100    M2    
    M2 Subtotal 2100
    I could put the subtotal, but couldnu2019t add subtotal text.
    My code
      TRY.
          CALL METHOD cl_salv_table=>factory
            IMPORTING
              r_salv_table   = g_alv
            CHANGING
              t_table        = gt_report
        CATCH cx_salv_msg .
      ENDTRY.
    u2026u2026
    *Display the table.
      g_alv->display( ).

    Hi
    REPORT  z_alv_demo_total_text.
    Type declaration for final table to display the output
    TYPES: BEGIN OF ty_mara,
            srno TYPE char40, " Storing the total text
            matnr TYPE matnr, " Material
            ersda TYPE ersda, " Creation date
            ernam TYPE ernam, " Created by
            laeda TYPE laeda, " Last change date
            aenam TYPE aenam, " Last change by
            vpsta TYPE vpsta, " Maintenance status
            brgew TYPE brgew, " Gross weight
            ntgew TYPE ntgew, " Net weight
            gewei TYPE gewei, " Weight Unit
           END OF ty_mara.
    Type declaration for table storing temp. data
    TYPES: BEGIN OF ty_mara_tmp,
            matnr TYPE matnr, " Material
            ersda TYPE ersda, " Creation date
            ernam TYPE ernam, " Created by
            laeda TYPE laeda, " Last change date
            aenam TYPE aenam, " Last change by
            vpsta TYPE vpsta, " Maintenance status
            brgew TYPE brgew, " Gross weight
            ntgew TYPE ntgew, " Net weight
            gewei TYPE gewei, " Weight Unit
          END OF ty_mara_tmp.
    Internal table for storing final data
    DATA: i_mara TYPE STANDARD TABLE OF ty_mara INITIAL SIZE 0.
    Work area for final table
    DATA: w_mara TYPE ty_mara.
    Internal table for storing temp. data
    DATA: i_mara_tmp TYPE STANDARD TABLE OF ty_mara_tmp INITIAL SIZE 0.
    Work area for temp. table
    DATA: w_mara_tmp TYPE ty_mara_tmp.
    Object variable for ALV grid
    DATA: oref1 TYPE REF TO cl_gui_alv_grid.
    Field catalog table for ALV grid
    DATA: fieldcat TYPE  lvc_t_fcat.
    Workarea for field catalog table
    DATA: w_field TYPE lvc_s_fcat.
    Internal table for storing info. for ALV grid
    data: i_sort2 TYPE STANDARD TABLE OF lvc_s_sort INITIAL SIZE 0.
    Workarea for sort table
    DATA: wa_sort2      TYPE  lvc_s_sort.
    Workarea for ALV layout
    data: wa_layout     TYPE  lvc_s_layo.
    START-OF-SELECTION.
    Fetch data
    SELECT  matnr   " Material
            ersda   " Creation date
            ernam   " Created by
            laeda   " Last change date
            aenam   " Last change by
            vpsta   " Maintenance status
            brgew   " Gross weight
            ntgew   " Net weight
            gewei   " Weight Unit
      FROM mara
      INTO TABLE i_mara_tmp
      UP TO 100 ROWS.
      CHECK sy-subrc = 0.
    Populate final table
      LOOP AT i_mara_tmp INTO w_mara_tmp.
      Storing the Total text need to be displayed in
      ALV
        w_mara-srno = 'Total weight (Gross & Net)'.
        w_mara-matnr = w_mara_tmp-matnr.
        w_mara-ersda = w_mara_tmp-ersda.
        w_mara-ernam  = w_mara_tmp-ernam .
        w_mara-laeda = w_mara_tmp-laeda.
        w_mara-aenam = w_mara_tmp-aenam.
        w_mara-vpsta = w_mara_tmp-vpsta.
        w_mara-brgew = w_mara_tmp-brgew.
        w_mara-ntgew = w_mara_tmp-ntgew.
        w_mara-gewei = w_mara_tmp-gewei.
        APPEND w_mara TO i_mara.
      ENDLOOP.
    Calling the screen to display ALV
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          Display ALV report
    MODULE status_0100 OUTPUT.
      IF oref1 IS INITIAL.
      Create ALV grid object
      In this case we have not created any custom container in the screen,
      Instead of that dummy container name is passed
      ADVANTAGE: we can run this report in background without any problem
        CREATE OBJECT oref1
          EXPORTING
            i_parent          = cl_gui_custom_container=>screen0
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5
        CHECK sy-subrc = 0.
      Preparing the field catalog
      ZDEMO: Defined in DDIC, it's structure is same as TYPE ty_mara
      defined in the program
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_structure_name       = 'ZDEMO'
          CHANGING
            ct_fieldcat            = fieldcat
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc = 0.
          LOOP AT fieldcat INTO w_field.
            IF w_field-fieldname = 'BRGEW' OR
              w_field-fieldname = 'NTGEW'.
            Summation for Gross & Net weight
              w_field-do_sum = 'X'.
              MODIFY fieldcat FROM w_field TRANSPORTING do_sum.
            ENDIF.
            IF w_field-fieldname = 'SRNO'.
            Hide this field so that it can display it's content i.e.
            Total text in Subtotal level
              w_field-tech = 'X'.
              w_field-no_out = 'X'.
              MODIFY fieldcat FROM w_field TRANSPORTING tech no_out.
            ENDIF.
            CLEAR w_field.
          ENDLOOP.
        ENDIF.
      Populate Sort table with SRNO field so that we can display the total
      text in it's subtotal level
        wa_sort2-spos = 1.
        wa_sort2-fieldname = 'SRNO'.
        wa_sort2-up = 'X'.
        wa_sort2-subtot = 'X'.
        APPEND wa_sort2 TO i_sort2.
      Hide the total line
        wa_layout-no_totline = 'X'.
      Display the ALV grid
        CALL METHOD oref1->set_table_for_first_display
          EXPORTING
            is_layout                     = wa_layout
          CHANGING
            it_outtab                     = i_mara[]
            it_fieldcatalog               = fieldcat
            it_sort                       = i_sort2
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc <> 0.
        ENDIF.
      Set the focus on the grid
        CALL METHOD cl_gui_alv_grid=>set_focus
          EXPORTING
            control           = oref1
          EXCEPTIONS
            cntl_error        = 1
            cntl_system_error = 2
            OTHERS            = 3.
        IF sy-subrc <> 0.
        ENDIF.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    These will defintely help  in u displaying subtotal text check it
    thanks

  • Subtotal Text in Subtotal row  in ALV using LIst dispaly

    Hi pals,
                I am facing problem with subtotal Text in subtotal row in ALV .Please guide me.
    i am sending sample program..
    it is getting terminated.  I am using SAP ECC 6.0  version SAP.
    Thank you.
    Balaji
    REPORT  ztestbdcbk10                            .
    TYPE-POOLS: slis.
    DATA: x_fieldcat TYPE slis_fieldcat_alv,
          it_fieldcat TYPE slis_t_fieldcat_alv,
          l_layout TYPE slis_layout_alv,
          x_events TYPE slis_alv_event,
          it_events TYPE slis_t_event.
    data: lv_string(20) type c.
    DATA: BEGIN OF itab OCCURS 0,
          vbeln LIKE vbak-vbeln,
          posnr LIKE vbap-posnr,
          zmeng LIKE vbap-zmeng,
         END OF itab.
    SELECT
           vbeln
           posnr
           zmeng
           FROM vbap
           UP TO 20 ROWS
           INTO TABLE itab.
    LOOP AT itab.
      itab-zmeng = sy-tabix .
      MODIFY itab INDEX sy-tabix.
    ENDLOOP.
    x_fieldcat-fieldname = 'subtotal'.
    x_fieldcat-outputlen = 10.
    x_fieldcat-col_pos = 0.
    append x_fieldcat to it_fieldcat.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    *x_fieldcat-outputlen = 10.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'ZMENG'.
    x_fieldcat-seltext_l = 'ZMENG'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-do_sum = 'X'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    DATA: sort TYPE slis_sortinfo_alv,
          it_sort TYPE  slis_t_sortinfo_alv.
    sort-fieldname = 'VBELN'.
    sort-spos = 2.
    sort-up = 'X'.
    sort-subtot = 'X'.
    APPEND sort TO it_sort.
    l_layout-totals_text = 'total text'.
    l_layout-subtotals_text = 'Subtotal'.
    CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME               =
       IS_LAYOUT                      = l_layout
       IT_FIELDCAT                    = it_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       IT_SORT                        = it_sort
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
       IT_EVENTS                      = 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
      IR_SALV_LIST_ADAPTER           =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        t_outtab                       =  itab
    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.

    hi,
    chk this...
    TYPE-POOLS: slis.
    DATA: x_fieldcat TYPE slis_fieldcat_alv,
    it_fieldcat TYPE slis_t_fieldcat_alv,
    l_layout TYPE slis_layout_alv,
    x_events TYPE slis_alv_event,
    it_events TYPE slis_t_event.
    data: lv_string(20) type c.
    DATA: BEGIN OF itab OCCURS 0,
    vbeln LIKE vbak-vbeln,
    posnr LIKE vbap-posnr,
    zmeng LIKE vbap-zmeng,
    END OF itab.
    DATA: sort TYPE slis_sortinfo_alv,
    it_sort TYPE slis_t_sortinfo_alv.
    *x_fieldcat-fieldname = 'subtotal'.
    *x_fieldcat-outputlen = 10.
    *x_fieldcat-col_pos = 0.
    *append x_fieldcat to it_fieldcat.
    *CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'ZMENG'.
    x_fieldcat-seltext_l = 'ZMENG'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-do_sum = 'X'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    refresh it_sort.  clear it_sort.
    sort-fieldname = 'VBELN'.
    sort-spos = 3.
    sort-up = 'X'.
    sort-subtot = 'X'.
    APPEND sort TO it_sort.
    clear sort.
    l_layout-subtotals_text = 'Subtotal'.
    l_layout-totals_text = 'total text'.
    start-of-selection.
    SELECT
    vbeln
    posnr
    zmeng
    FROM vbap
    UP TO 20 ROWS
    INTO TABLE itab.
    end-of-selection.
    sort itab.
    LOOP AT itab.
    itab-zmeng = sy-tabix .
    MODIFY itab INDEX sy-tabix.
    ENDLOOP.
    *data: v_repid type sy-repid.
    *v_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             = I_BYPASSING_BUFFER
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             = sy-repid
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               = 'ITAB'
       IS_LAYOUT                      = l_layout
       IT_FIELDCAT                    = IT_FIELDCAT[]
      IT_EXCLUDING                   = IT_EXCLUDING
      IT_SPECIAL_GROUPS              = IT_SPECIAL_GROUPS
       IT_SORT                        = IT_SORT
      IT_FILTER                      = IT_FILTER
      IS_SEL_HIDE                    = IS_SEL_HIDE
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     = IS_VARIANT
      IT_EVENTS                      = IT_EVENTS
      IT_EVENT_EXIT                  = IT_EVENT_EXIT
      IS_PRINT                       = IS_PRINT
      IS_REPREP_ID                   = IS_REPREP_ID
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
      IR_SALV_LIST_ADAPTER           = IR_SALV_LIST_ADAPTER
      IT_EXCEPT_QINFO                = IT_EXCEPT_QINFO
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        = E_EXIT_CAUSED_BY_CALLER
      ES_EXIT_CAUSED_BY_USER         = ES_EXIT_CAUSED_BY_USER
      TABLES
        t_outtab                       = itab
    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.
    do reward if it helps,
    priya.

  • Field should not display in the subtotal row in ALV report after sorting .

    we have a requirement, after sorting and subtotaling, the output in ALV is -
    vbeln        amount1  amount2  amount3
    123           11              12            13
    123           12             13             14
    123           23             25             27 
    133           11              12            13
    133           12             13             14
    133           23             25             27
    Now the customer wants the ALV outpput in this fashion -
    123           11              12            13
    123           12             13             14
                     23             25             27    --->123 (vbeln) should not come in subtotaling row
    133           11              12            13
    133           12             13             14
                      23             25             27--->133(vbeln) should not come in subtotaling row

    Hi,
    if it helps you could create a hierachy. In this way you can define the field catalog for the lines and for the subtotal columns. The only thing is that you would always show the subtotal rows.
    You have references of hierachy alvs in
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f
    ALV Hierarchy
    alv hierarchy
    In this case it also sorts
    Sorting for ALV hierarchy
    I hope it helps.
    Edited by: Oscar Pecharroman on Aug 2, 2010 1:13 PM

  • Short dump while doing subtotal in the ALV report

    Hi All,
    I am getting run time error while doing the sub total and total in the ALV .
    error is "MESSAGE_TYPE_X" and
    discription is  "The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X)."
    Can anyone help me regarding this.
    My alv field catog is like below
      DATA: ls_fieldcat TYPE slis_fieldcat_alv,
            ls_sort     TYPE SLIS_SORTINFO_ALV.
      CLEAR:ls_fieldcat,
            ls_sort.
      REFRESH ot_fieldcat.
      ls_fieldcat-FIELDNAME   = 'LEASE_NUMBER'.
      ls_fieldcat-SELTEXT_M   = 'Lease Number'(001).
      ls_fieldcat-COL_POS     = 0.
      ls_fieldcat-OUTPUTLEN   = 10.
      ls_fieldcat-DO_SUM      = 'X'.
      ls_fieldcat-KEY         = 'X'.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'LEASE_TYPE'.
      ls_fieldcat-SELTEXT_M   = 'Lease Type'(002).
      ls_fieldcat-COL_POS     = 1.
      ls_fieldcat-OUTPUTLEN   = 5.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'LEGACY_NUM'.
      ls_fieldcat-SELTEXT_M   = 'Legacy Contract No'(003).
      ls_fieldcat-COL_POS     = 2.
      ls_fieldcat-OUTPUTLEN   = 10.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'CUSTOMER'.
      ls_fieldcat-SELTEXT_M   = 'Customer'(004).
      ls_fieldcat-COL_POS     = 3.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'STATUS'.
      ls_fieldcat-SELTEXT_M   = 'Status'(017).
      ls_fieldcat-COL_POS     = 16.
      ls_fieldcat-OUTPUTLEN   = 10.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'GATEIN_DT'.
      ls_fieldcat-SELTEXT_M   = 'Gate In Date'(018).
      ls_fieldcat-COL_POS     = 17.
      ls_fieldcat-OUTPUTLEN   = 10.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
      ls_fieldcat-FIELDNAME   = 'SVALUE'.
      ls_fieldcat-COL_POS     = 18.
      ls_fieldcat-DO_SUM      = 'X'.
      ls_fieldcat-OUTPUTLEN   = 12.
      APPEND ls_fieldcat TO ot_fieldcat.
      CLEAR  ls_fieldcat.
    DATA SORTING AND SUBTOTAL
      CLEAR ls_sort.
      ls_sort-FIELDNAME = 'LEASE_NUMBER'.
      ls_sort-SPOS      = 0.
      ls_sort-UP        = 'X'.
      ls_sort-SUBTOT    = 'X'.
      APPEND ls_sort TO GT_SORT.
    If i coment the code relate dto 'SVALUE' i am getting output without sub total and total.
    if i uncomment the same then I am getting short dump.

    Hi,
    Try this coding,
    TYPE-POOLS: SLIS.                      " ALV GLOBAL TYPES
    *      FORM  F_READ_DATA
    FORM F_READ_DATA.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_VBAK
               FROM VBAK
                 UP TO P_MAX ROWS
              WHERE KUNNR IN S_KUNNR
                AND VBELN IN S_VBELN
                AND VKORG IN S_VKORG.
    ENDFORM.                               " F_READ_DATA
    *      FORM  F_DISPLAY_DATA
    FORM F_DISPLAY_DATA.
      DEFINE M_FIELDCAT.
        ADD 1 TO LS_FIELDCAT-COL_POS.
        LS_FIELDCAT-FIELDNAME   = &1.
        LS_FIELDCAT-REF_TABNAME = 'VBAK'.
        LS_FIELDCAT-DO_SUM      = &2.
        LS_FIELDCAT-CFIELDNAME  = &3.
        APPEND LS_FIELDCAT TO LT_FIELDCAT.
      END-OF-DEFINITION.
      DEFINE M_SORT.
        ADD 1 TO LS_SORT-SPOS.
        LS_SORT-FIELDNAME = &1.
        LS_SORT-UP        = 'X'.
        LS_SORT-SUBTOT    = &2.
        APPEND LS_SORT TO LT_SORT.
      END-OF-DEFINITION.
      DATA:
        LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
        LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
        LT_SORT     TYPE SLIS_T_SORTINFO_ALV,
        LS_SORT     TYPE SLIS_SORTINFO_ALV,
        LS_LAYOUT   TYPE SLIS_LAYOUT_ALV.
      M_FIELDCAT 'VKORG' ''  ''.
      M_FIELDCAT 'KUNNR' ''  ''.
      M_FIELDCAT 'VBELN' ''  ''.
      M_FIELDCAT 'NETWR' 'X' 'WAERK'.
      M_FIELDCAT 'WAERK' ''  ''.
      M_SORT 'VKORG' 'X'.                  " SORT BY VKORG AND SUBTOTAL
      M_SORT 'KUNNR' 'X'.                  " SORT BY KUNNR AND SUBTOTAL
      M_SORT 'VBELN' ''.                   " SORT BY VBELN
      LS_LAYOUT-CELL_MERGE = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                IS_LAYOUT   = LS_LAYOUT
                IT_FIELDCAT = LT_FIELDCAT
                IT_SORT     = LT_SORT
           TABLES
                T_OUTTAB    = GT_VBAK.
    ENDFORM.                               " F_DISPLAY_DATA
    Regards,
    Nikhil.

Maybe you are looking for