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

Similar Messages

  • 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.

  • Subtotal Text in ALV Grid and hiding empty row

    Hello,
    ive got a ALV-Grid with a few fields .. Total on one field subtotal on VKORG, category or some other fields .
    after subtotal of one of the 2 named fields i'm reading the literal to the given fields and writing them in the table which is displayed and do a refresh.
    i can show the field literal in the alv by adding it into the field cat but than its displayed even if its not filled.
    i just want to display that column after filling it - the subtotal of the 2 columns.
    and i want to add the text of  the literal to the subtotal line. so if the alv grid is closed to display the totals. i want to see what the subtotal is for.
    for displaying i use        
    CALL METHOD lcl_alv_grid->set_table_for_first_display
          EXPORTING
            is_layout            = gs_layout
            is_variant           = gs_variant
            it_toolbar_excluding = gt_exclude
            i_save               = x_save
            i_default            = 'X'
          CHANGING
            it_outtab            = it_alvlist[]
            it_fieldcatalog      = gt_field_cat.
    for refresh 
        lv_lvc_s_stbl-row = 'X'.
        lv_lvc_s_stbl-col = 'X'.
        lv_soft_refresh = 'X'.
        CALL METHOD lcl_alv_grid->refresh_table_display
          EXPORTING
            is_stable      = lv_lvc_s_stbl
            i_soft_refresh = lv_soft_refresh
          EXCEPTIONS
            finished       = 1
            OTHERS         = 2.
    get the selected column to read literal
    CALL METHOD lcl_alv_grid->get_selected_columns
        IMPORTING
          et_index_columns = it_col_tab
        EXCEPTIONS
          OTHERS           = 1.
    Hope you can help me and understand my problem

    Hi,
    Use the No_out from Reusable types of fieldcat..For example.
    IF it_final-field is initial.
            READ TABLE IT_FIELDCAT5 WITH KEY FIELDNAME = 'BCD'.
            IF SY-SUBRC EQ 0.
              IT_FIELDCAT5-NO_OUT = 'X'.
              MODIFY IT_FIELDCAT5 INDEX SY-TABIX TRANSPORTING NO_OUT.
            ENDIF.
    else.
            READ TABLE IT_FIELDCAT5 WITH KEY FIELDNAME = 'BCD'.
            IF SY-SUBRC EQ 0.
              IT_FIELDCAT5-NO_OUT = ' '.
              MODIFY IT_FIELDCAT5 INDEX SY-TABIX TRANSPORTING NO_OUT.
            ENDIF.
    ENDIf.
    Cheers,
    Syed Maheboob.

  • Insert subtotal text in alv grid using fm REUSE_ALV_EVENTS_GET

    Hi guys,
    i'm using the FM REUSE_ALV_EVENTS_GET modifying the event table where the name is equal to 'SUBTOTAL_TEXT'. But then, the program doesn't start the form SUBTOTAL_TEXT.
    The code is below:
    DATA:  i_event TYPE slis_t_event,
               wa_events TYPE slis_alv_event.
    CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
    DATA: l_s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    Subtotal
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO l_s_event-form.
        MODIFY i_event FROM l_s_event TRANSPORTING form
                         WHERE name = slis_ev_subtotal_text.
      ENDIF.
    And this is the form:
          P_total  Total
          p_subtot_text Subtotal text info
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    *DATA: p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'VKBUR'.
        p_subtot_text-display_text_for_subtotal
        = 'test1'(009).
      ENDIF.
    Plant level sub total
      IF p_subtot_text-criteria = 'KUNNR'.
        p_subtot_text-display_text_for_subtotal = 'test2'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text

    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..

  • 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.

  • 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

  • How to get Grand Total Text in ALV GRID

    Hi Folks,
    I am able to get the SUBTOTAL TEXT .....But i need...
    How to get Grand Total Text in ALV GRID Display...
    Can any one give a Solution for this...

    Hi Surendar,
    Check out this code.. this is showing Total Text in Toal line in the very first column.
    REPORT  zsales_ord_det_1                        .
    TABLES: ztable_10.
    TYPE-POOLS: slis.
    DATA: BEGIN OF it OCCURS 0,
    srno(6) type c,
    name LIKE ztable_10-name,
    age LIKE ztable_10-age,
    END OF it.
    DATA : BEGIN OF it_temp OCCURS 0,
    name LIKE ztable_10-name,
    age LIKE ztable_10-age,
    END OF it_temp.
    DATA: i_fieldcat  TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE  slis_fieldcat_alv.
    DATA: v_repid LIKE sy-repid,
           i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
           gs_layout TYPE slis_layout_alv,
           gd_layout TYPE slis_layout_alv,
           i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    START-OF-SELECTION.
      v_repid = sy-repid.
      SELECT * FROM ztable_10 INTO TABLE it_temp.
      LOOP AT it_temp .
        it-srno = 'Total'.
        it-name = it_temp-name.
        it-age = it_temp-age.
        APPEND  it.
      ENDLOOP.
    END-OF-SELECTION.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name               = v_repid
         i_internal_tabname           = 'IT'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         i_inclname                   = v_repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = i_fieldcat[]
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    wa_fieldcat-row_pos = 1.
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-fieldname = 'SRNO'.
    wa_fieldcat-tabname = it.
    append wa_fieldcat to i_fieldcat.
      LOOP AT i_fieldcat INTO wa_fieldcat.
        IF wa_fieldcat-fieldname = 'AGE'.
          wa_fieldcat-do_sum = 'X'.
          MODIFY i_fieldcat FROM wa_fieldcat.
        ENDIF.
       IF wa_fieldcat-fieldname = 'SRNO'.
         Hide this field so that it can display it's content i.e.
            Total text in Subtotal level
        wa_fieldcat-tech = 'X'.
          wa_fieldcat-no_out = 'X'.
          MODIFY i_fieldcat FROM wa_fieldcat TRANSPORTING tech no_out.
       ENDIF.
      ENDLOOP.
    wa_sort-spos = 1.
    wa_sort-fieldname = 'SRNO'.
    wa_sort-up = 'X'.
    wa_sort-subtot = 'X'.
    APPEND wa_sort TO i_sort.
      gd_layout-no_totalline = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                       = ' '
         i_callback_program                        = v_repid
      I_CALLBACK_PF_STATUS_SET     = ' '
    i_callback_user_command                = '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                                      = gd_layout
         it_fieldcat                                      = i_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
         it_sort                           = i_sort
      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
       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.
    Regards,
    Seema

  • 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

  • How to get a Footer text in alv grid?

    Hi,
    am using RESUE_ALV_COMMENTARy_write... it is getting only on top of page..
    suggest me to get Footer text in ALV GRiD.
    Regards,
    sodanapalli
    Moderator message: please do more research before asking, all points removed (both replies were copy/pasted anyway)
    Edited by: Thomas Zloch on May 19, 2011 5:41 PM

    Step1: Populate the ALV event table with 'END_OF_LIST' event
    Step2: Populate the footer text in to an internal table which is of type
    slis_t_listheader.
    Step3: Create a subroutine with name 'END_OF_LIST' and with in this form we have to call the function module u2018REUSE_ALV_COMMENTARY_WRITEu2019.
    Step4: Now call the function module REUSE_ALV_GRID_DISPLAYu2019 to display the ALV report. Whenever u2018END_OF_LIST' event is get fired it executes the subroutine END_OF_LIST and displays the text into the footer of the ALV GRID.
    Code:
    *& Report Z_TEST_ALV
    REPORT z_test_alv.
    TYPE-POOLS: slis.
    DATA: i_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0,
                i_events TYPE slis_t_event,
                i_end_of_page TYPE slis_t_listheader,
                w_events TYPE slis_alv_event,
                v_repid LIKE sy-repid.
    START-OF-SELECTION.
    SELECT * FROM
    mara INTO TABLE i_mara
    UP TO 100 ROWS.
    CHECK sy-subrc = 0.
    PERFORM populate_alv_event.
    PERFORM comment_build USING i_end_of_page[].
    PERFORM display_grid.
    *& Form POPULATE_ALV_EVENT
    FORM populate_alv_event .
    Populate event table
    w_events-name = 'END_OF_LIST'.
    w_events-form = 'END_OF_LIST'.
    APPEND w_events TO i_events.
    ENDFORM. " POPULATE_ALV_EVENT
    *& Form COMMENT_BUILD
    FORM comment_build USING p_i_end_of_page TYPE slis_t_listheader.
    DATA: ls_line TYPE slis_listheader.
    REFRESH p_i_end_of_page.
    CLEAR ls_line.
    ls_line-typ = 'H'.
    ls_line-info = 'This is end of list'(001).
    APPEND ls_line TO p_i_end_of_page.
    ENDFORM. " COMMENT_BUILD
    *& Form end_of_list
    FORM end_of_list.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_end_of_page.
    ENDFORM. "end_of_list
    *& Form DISPLAY_GRID
    FORM display_grid .
    v_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    i_structure_name = 'MARA'
    it_events = i_events
    TABLES
    it_outtab = i_mara
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    ENDFORM. " DISPLAY_GRID
    Check the output  where footer will be displayed as 'THIS IS END OF LIST'

  • Long text in alv grid

    Hi ,
    I wanted to display a long text in my grid. Suppose I have a field's  long text having field length 3000.
    It is varying for other fields.
    Anybody will tell me how to display the whole long text in alv grid.

    hi,
    if it is a heading then in the field catlog u can do it.
    i don know th length limitation.
    fieldcatalog-fieldname   = 'EBELP'.
    <b>  fieldcatalog-seltext_m   = 'PO Item'.
    fieldcatalog-seltext_s   = 'PO Item'.
    fieldcatalog-seltext_l   = 'PO Item'.</b>
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
    rgds
    Anver

  • 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..

  • Display additional Text in ALV Grid

    Hello,
    I have an ALV Grid display and need to display additional information on the top of the list. I have used the grid-title, but the field is defined as 70 characters and thats not enough.
    Is it possible to display more text with alv grid?
    Regards Michael

    Hi Ravi,
    I´m creating my alv object orientated and I don´t know, how to manage that now. Can You explain me, where and how I have to do it?
    My Dynpro has one custom container and I´m calling the method SET_TABLE_FOR_FIRST_DISPLAY in PBO.
    And I need the comment to be printed with the ALV by pressing the print button in the toolbar of the ALV
    Thank You!
    Message was edited by: Michael Schmidt

  • Regarding user interface in subtotal line of ALV grid, ensure points

    Hi,
    I have 3 fields,
    A= vendor , B = freight , C = Cost PMT
    When the vendor get changed, My Grid is showing subtotal of B i.e freight.
    Now my requirement is, in the same subtotal line, I want average of C (Cost PMT) field.
    So how we can interact with the subtotal line of the ALV grid.
    Pleas reply!!!!   & have ur points.
    cheers

    Read the documentation of FM ICON_CREATE, the purpose of the Function module is entirely different from what you are using it for.
    To print Icons in ALV (Using FMs ) all you need to do is to send the Icon name in the field.
    Also parameters TEXT and INFO of FM ICON_CREATE seem to be flags, that are appended to the icon name so that when you set it on the screen the appropriate info or Text is shown.

  • Subtotal Text in ALV

    Hi all,
    I wanted to display subtotal and total text in the output.
    I searched in SDN and specified subtotal_text in Layout.
    But still i am not getting the subtotal Text in  output.
    Here is my code.....
    Please help me , where i did wrong?
    REPORT  YTEST_ALV.
    Tables VBAK.
    Type-pools: slis.
    INITIALIZATION.
    Types: Begin of TY_VBAK,
             vbeln type vbak-vbeln,
             ERDAT TYPE VBAK-ERDAT,
             ERNAM TYPE VBAK-ERNAM,
             NETWR TYPE VBAK-NETWR,
             WAERK TYPE VBAK-WAERK,
             VKORG TYPE VBAK-VKORG,
           End Of TY_VBAK.
    DATA: IT_VBAK TYPE STANDARD TABLE OF TY_VBAK,
          IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FLDCAT LIKE LINE OF IT_FLDCAT,
          GD_LAYOUT TYPE STANDARD TABLE OF SLIS_LAYOUT_ALV WITH HEADER LINE,
    *TO DISPLAY THE LIST BY SORTING A PARTICULAR COLUMN
          it_sortcat   type slis_sortinfo_alv occurs 1,
          wa_sort like line of it_sortcat.
    START-OF-SELECTION.
    SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN.
    PERFORM DATA_RETRIEVAL.
    PERFORM BUILD_FLDCAT.
    PERFORM BLD_LAYOUT.
    PERFORM BUILD_SORTCAT.
    PERFORM DISPLAY_LIST.
    PERFORM TOP_OF_PAGE.
    *&      Form  DATA_RETRIEVAL
          text
    -->  p1        text
    <--  p2        text
    form DATA_RETRIEVAL .
    SELECT vbeln
           ERDAT
           ERNAM
           NETWR
           WAERK
           VKORG
           FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN S_VBELN.
    endform.                    " DATA_RETRIEVAL
    *&      Form  BUILD_FLDCAT
          text
    -->  p1        text
    <--  p2        text
    form BUILD_FLDCAT .
    WA_FLDCAT-FIELDNAME = 'VBELN'.
    WA_FLDCAT-SELTEXT_L = 'Sales Order No'.
    *WA_FLDCAT-EMPHASIZE = 'C013'.
    WA_FLDCAT-COL_POS = 0.
    APPEND WA_FLDCAT TO IT_FLDCAT.
    WA_FLDCAT-FIELDNAME = 'ERDAT'.
    WA_FLDCAT-SELTEXT_L = 'Date'.
    WA_FLDCAT-COL_POS = 1.
    APPEND WA_FLDCAT TO IT_FLDCAT.
    WA_FLDCAT-FIELDNAME = 'ERNAM'.
    WA_FLDCAT-SELTEXT_L = 'UserName'.
    WA_FLDCAT-COL_POS = 2.
    APPEND WA_FLDCAT TO IT_FLDCAT.
    WA_FLDCAT-FIELDNAME = 'NETWR'.
    WA_FLDCAT-SELTEXT_L = 'Amount'.
    WA_FLDCAT-COL_POS = 3.
    WA_FLDCAT-DO_SUM = 'X'.
    APPEND WA_FLDCAT TO IT_FLDCAT.
    WA_FLDCAT-FIELDNAME = 'WAERK'.
    WA_FLDCAT-SELTEXT_L = 'Currency'.
    WA_FLDCAT-COL_POS = 4.
    APPEND WA_FLDCAT TO IT_FLDCAT.
    WA_FLDCAT-FIELDNAME = 'VKORG'.
    WA_FLDCAT-SELTEXT_L = 'Sales Organisation'.
    WA_FLDCAT-COL_POS = 5.
    APPEND WA_FLDCAT TO IT_FLDCAT.
    endform.                    " BUILD_FLDCAT
    FORM BLD_LAYOUT.
    GD_LAYOUT-NO_INPUT = 'X'.
    GD_LAYOUT-TOTALS_TEXT = 'Total'.
    GD_LAYOUT-subtotals_text = 'SubTotal'.
    APPEND GD_LAYOUT.
    ENDFORM.
    *&      Form  DISPLAY_LIST
          text
    -->  p1        text
    <--  p2        text
    form DISPLAY_LIST .
    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            = '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                         = GD_LAYOUT
       IT_FIELDCAT                        = IT_FLDCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
       IT_SORT                           = it_sortcat
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
       I_SAVE                            = 'X'
      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
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        t_outtab                          = IT_VBAK.
    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_LIST
    *&      Form  TOP_OF_PAGE
          text
    -->  p1        text
    <--  p2        text
    form TOP_OF_PAGE .
    DATA: IT_HEADER TYPE SLIS_T_LISTHEADER,
          WA_HEADER TYPE SLIS_LISTHEADER.
          WA_HEADER-TYP = 'H'.
          WA_HEADER-INFO = 'WELCOME HEADER'.
          APPEND WA_HEADER TO IT_HEADER.
          WA_HEADER-TYP = 'S'.
          WA_HEADER-KEY = 'REPORT'.
          WA_HEADER-INFO = SY-REPID.
          APPEND WA_HEADER TO IT_HEADER.
          WA_HEADER-TYP = 'S'.
          WA_HEADER-KEY = 'DATE'.
          CONCATENATE SY-DATUM6(2) '/'  SY-DATUM4(2) '/' SY-DATUM+0(4)       inTO WA_HEADER-INFO.
         WA_HEADER-INFO = SY-DATUM.
          APPEND WA_HEADER TO IT_HEADER.
          CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
            EXPORTING
              it_list_commentary       = IT_HEADER.
            I_LOGO                   =
            I_END_OF_LIST_GRID       =
            I_ALV_FORM               =
    endform.                    " TOP_OF_PAGE
    *TO DISPLAY THE LIST BY SORTING A PARTICULAR COLUMN
    *&      Form  BUILD_SORTCAT
          text
    -->  p1        text
    <--  p2        text
    form BUILD_SORTCAT .
      wa_sort-spos      = 1.
      wa_sort-fieldname = 'ERDAT'.
      wa_sort-SUBTOT    = 'X'. "subtotals any totals column by this field
      APPEND wa_sort TO it_sortcat.
    endform.                    " BUILD_SORTCAT

    Hi Elan,
    *& Report  Z_ALV_SUBTOTAL
    REPORT z_alv_subtotal.
    *& Table declaration
    TABLES: ekko.
    *& Type pool declaration
    TYPE-POOLS: slis. " Type pool for ALV
    *& Selection screen
    SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
    *& Type declaration
    * Type declaration for internal table to store EKPO data
    TYPES: BEGIN OF x_data,
           ebeln  TYPE char30,  " Document no.
           ebelp  TYPE ebelp,   " Item no
           matnr  TYPE matnr,   " Material no
           matnr1 TYPE matnr,   " Material no
           werks  TYPE werks_d, " Plant
           werks1 TYPE werks_d, " Plant
           ntgew  TYPE entge,   " Net weight
           gewe   TYPE egewe,   " Unit of weight                          
           END OF x_data.
    *& Internal table declaration
    DATA:
    * Internal table to store EKPO data
      i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
    * Internal table for storing field catalog information
      i_fieldcat TYPE slis_t_fieldcat_alv,
    * Internal table for Top of Page info. in ALV Display
      i_alv_top_of_page TYPE slis_t_listheader,
    * Internal table for ALV Display events
      i_events TYPE slis_t_event,
    * Internal table for storing ALV sort information
      i_sort TYPE  slis_t_sortinfo_alv,
      i_event TYPE slis_t_event.
    *& Work area declaration
    DATA:
      wa_ekko TYPE x_data,
      wa_layout     TYPE slis_layout_alv,
      wa_events         TYPE slis_alv_event,
      wa_sort TYPE slis_sortinfo_alv.
    *& Constant declaration
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    *& Start-of-selection event
    START-OF-SELECTION.
    * Select data from ekpo
      SELECT ebeln " Doc no
             ebelp " Item
             matnr " Material
             matnr " Material
             werks " Plant
             werks " Plant
             ntgew " Quantity
             gewei " Unit
             FROM ekpo
             INTO TABLE i_ekpo
             WHERE ebeln IN s_ebeln
             AND ntgew NE '0.00'.
      IF sy-subrc = 0.
        SORT i_ekpo BY ebeln ebelp matnr .
      ENDIF.
    * To build the Page header
      PERFORM sub_build_header.
    * To prepare field catalog
      PERFORM sub_field_catalog.
    * Perform to populate the layout structure
      PERFORM sub_populate_layout.
    * Perform to populate the sort table.
      PERFORM sub_populate_sort.
    * Perform to populate ALV event
      PERFORM sub_get_event.
    END-OF-SELECTION.
    * Perform to display ALV report
      PERFORM sub_alv_report_display.
    *&      Form  sub_build_header
    *       To build the header
    *       No Parameter
    FORM sub_build_header .
    * Local data declaration
      DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE char10,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    * Title  Display
      l_r_line-typ = c_header.               " header
      l_title = 'Test report'(001).
      l_r_line-info = l_title.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR l_r_line.
    * Run date Display
      CLEAR l_date.
      l_r_line-typ  = c_item.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'(002).
      l_r_line-info = l_date.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.
    ENDFORM.                    " sub_build_header
    *&      Form  sub_field_catalog
    *       Build Field Catalog
    *       No Parameter
    FORM sub_field_catalog .
    *  Build Field Catalog
      PERFORM sub_fill_alv_field_catalog USING:
         '01' '01' 'EBELN' 'I_EKPO' 'L'
         'Doc No'(003) ' ' ' ' ' ' ' ',
         '01' '02' 'EBELP' 'I_EKPO' 'L'
         'Item No'(004) 'X' 'X' ' ' ' ',
         '01' '03' 'MATNR' 'I_EKPO' 'L'
         'Material No'(005) 'X' 'X' ' ' ' ',
         '01' '03' 'MATNR1' 'I_EKPO' 'L'
         'Material No'(005) ' ' ' ' ' ' ' ',
         '01' '04' 'WERKS' 'I_EKPO' 'L'
         'Plant'(006) 'X' 'X' ' ' ' ',
         '01' '04' 'WERKS1' 'I_EKPO' 'L'
         'Plant'(006) ' ' ' ' ' ' ' ',
         '01' '05' 'NTGEW' 'I_EKPO' 'R'
         'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.
    ENDFORM.                    " sub_field_catalog
    *&     Form  sub_fill_alv_field_catalog
    *&     For building Field Catalog
    *&     p_rowpos   Row position
    *&     p_colpos   Col position
    *&     p_fldnam   Fldname
    *&     p_tabnam   Tabname
    *&     p_justif   Justification
    *&     p_seltext  Seltext
    *&     p_out      no out
    *&     p_tech     Technical field
    *&     p_qfield   Quantity field
    *&     p_qtab     Quantity table
    FORM sub_fill_alv_field_catalog  USING  p_rowpos    TYPE sycurow
                                            p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_tabnam    TYPE tabname
                                            p_justif    TYPE char1
                                            p_seltext   TYPE dd03p-scrtext_l
                                            p_out       TYPE char1
                                            p_tech      TYPE char1
                                            p_qfield    TYPE slis_fieldname
                                            p_qtab      TYPE slis_tabname.
    * Local declaration for field catalog
      DATA: wa_lfl_fcat    TYPE  slis_fieldcat_alv.
      wa_lfl_fcat-row_pos        =  p_rowpos.     "Row
      wa_lfl_fcat-col_pos        =  p_colpos.     "Column
      wa_lfl_fcat-fieldname      =  p_fldnam.     "Field Name
      wa_lfl_fcat-tabname        =  p_tabnam.     "Internal Table Name
      wa_lfl_fcat-just           =  p_justif.     "Screen Justified
      wa_lfl_fcat-seltext_l      =  p_seltext.    "Field Text
      wa_lfl_fcat-no_out         =  p_out.        "No output
      wa_lfl_fcat-tech           =  p_tech.       "Technical field
      wa_lfl_fcat-qfieldname     =  p_qfield.     "Quantity unit
      wa_lfl_fcat-qtabname       =  p_qtab .      "Quantity table
      IF p_fldnam = 'NTGEW'.
        wa_lfl_fcat-do_sum  = 'X'.
      ENDIF.
      APPEND wa_lfl_fcat TO i_fieldcat.
      CLEAR wa_lfl_fcat.
    ENDFORM.                    " sub_fill_alv_field_catalog
    *&      Form  sub_populate_layout
    *       Populate ALV layout
    *       No Parameter
    FORM sub_populate_layout .
      CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col width
    ENDFORM.                    " sub_populate_layout
    *&      Form  sub_populate_sort
    *       Populate ALV sort table
    *       No Parameter
    FORM sub_populate_sort .
    * Sort on material
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    * Sort on plant
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    *&      Form  sub_get_event
    *       Get ALV grid event and pass the form name to subtotal_text
    *       event
    *       No Parameter
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
    'SUBTOTAL_TEXT'.
      DATA: l_s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    * Subtotal
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " sub_get_event
    *&      Form  sub_alv_report_display
    *       For ALV Report Display
    *       No Parameter
    FORM sub_alv_report_display .
      DATA: l_repid TYPE syrepid .
      l_repid = sy-repid .
    * This function module for displaying the ALV report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          it_sort = i_sort
          it_events                = i_event
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = i_ekpo
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
    *    MESSAGE i000 WITH 'Error in ALV report display'(055).
      ENDIF.
    ENDFORM.                    " sub_alv_report_display
    *       FORM sub_alv_top_of_page
    *       Call ALV top of page
    *       No parameter
    FORM sub_alv_top_of_page.                                   "#EC CALLED
    * To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_alv_top_of_page.
    ENDFORM.                    "alv_top_of_page
    *&      Form  subtotal_text
    *       Build subtotal text
    *       P_total  Total
    *       p_subtot_text Subtotal text info
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    * Material level sub total
      IF p_subtot_text-criteria = 'MATNR'.
        p_subtot_text-display_text_for_subtotal
        = 'Material level total'(009).
      ENDIF.
    * Plant level sub total
      IF p_subtot_text-criteria = 'WERKS'.
        p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text
    If found helpfull do reward.
    Regards.
    Eshwar.

  • Total/Subtotal Icon in ALV GRID

    Hi;
    i have an ALV GRID that is already sorted and data is shown ordered in the grid:
    Sort Documento
      wa_sort-spos = '1' .
      wa_sort-fieldname = 'MBLNR'.
      wa_sort-tabname = 'ITAB'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    But, i need to subtotal by a column and i do this:
      gt_fieldcat-seltext_l = 'Cant_entregada'.
      gt_fieldcat-fieldname = 'MENGE'.
      gt_fieldcat-ref_tabname = 'itab'.
      gt_fieldcat-outputlen = 14.
      gt_fieldcat-do_sum = 'X'.
      APPEND gt_fieldcat. CLEAR gt_fieldcat.
    Menge is data type Integer because the Key User doesn´t want decimal places.
    And ,
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
         i_callback_program                = g_repid
         is_layout                         = gs_layout
         it_fieldcat                       = gt_fieldcat[]
          it_sort                          = i_sort
          i_default                        = 'X'
          i_save                           = 'A'
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = itab
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2
    So data in the grid is ordered by Document number, but the total/subtotal button is not displayed.
    i've been lookin other posts about the same, but i don´t see any difference with my code.
    Any help.
    David Fúnez
    Tegucigalpa, Honduras

    i found the answer..jus added this line :   gt_fieldcat-datatype = 'INT4'.
    gt_fieldcat-seltext_l = 'Cant_entregada'.
      gt_fieldcat-fieldname = 'MENGE'.
      gt_fieldcat-ref_tabname = 'itab'.
      gt_fieldcat-outputlen = 14.
      gt_fieldcat-do_sum = 'X'.
      gt_fieldcat-datatype = 'INT4'.
      APPEND gt_fieldcat. CLEAR gt_fieldcat.
    Now buttons are displayed...

Maybe you are looking for

  • Trouble with my Multicam clip

    I'm trying to synchornize my two camera shots using the multicam button.  All is well in making the clip; however, i notice then when the created multi cam clip is in the timeline it is displaying in a linear fasion with the second camera clips ahead

  • Adapter vs. Adapter Engine

    What is the distinction between an adapter versus the adapter engine?  How are the 2 related? Also, what is the process flow of a message? Step 1. Adapter Step 2. Integration Engine Step 3. Adapter What are the steps in between?  I am trying to put t

  • Invalid web.xml

    I am having a problem within Tomcat (v. 3.3 or 4.0) where the web.xml for the webapps.war file give an error. The error is: At Invalid element 'servlet' in content of 'web-app', expected elements '[error-page, taglib, resource-ref, security-onstraint

  • How to read a time stamp from the db without ".0" at the end

    Hi All, I have code that is saving the results of a query in a result set. When ever i read a time stamp from the db (mysql 4) it always adds ".0" to the end of it. I tried using the getTimeStamp, getDate, getString methods for result sets and was no

  • Websites show white screen when visited

    When I visit some websites, I see just a white screen with nothing on it - No text, no images, no spot nothing - just white. Please note that I have tried the following things and none has worked for me. 1) I have reset Firefox - But no changes. 2) I