ALV Sub total texts. displayed in list not in grid.

Hi,
I am displaying data using alv and sub-totals on a particular column.
i am getting the sub-totals but i am not getting the sub-total texts when i am displaying data in a grid.
'REUSE_ALV_GRID_DISPLAY'.
i am getting subtotals and subtotal texts when i am diSplAying in list.
'REUSE_ALV_LIST_DISPLAY'.
but i want to get subtotal texts using alv grid, is it possible, if so please send me the code.
Any help in this regard is highly appreciated.
Thanks in advance for your help.

Hi,
Actually i have wriitten the same code, in the alv. I am using Function modules. for the same code the sub-total and total text is appearing in the list output. but not in the grid output.
code.
  wa_layout-zebra          = 'X'.
  wa_layout-subtotals_text = 'Total'.
  wa_layout-totals_text    = 'Sum of Marks'.
alv statement.
     is_layout = wa_layout
Declaration.
DATA : wa_layout type slis_layout_alv.
for the same declarations (Above) list is showing the texts but not the grid.
Any help in this regard is highly appreciated.

Similar Messages

  • Sub total text is not working

    Dear experts,
    I am working on ALV report. I need to maintain Sub total text but its not working with the below code.
    Can you please tell me whats wrong with this code.
    FORM f_display_alv_output .
      DATA: loc_repid TYPE sy-repid.
      CLEAR: loc_repid.
      loc_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = loc_repid
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   i_callback_top_of_page            = 'F_ALV_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                         = fs_layout
       it_fieldcat                       = itab_fieldcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = itab_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
       i_default                         = 'X'
       i_save                            = 'A'
    *   IS_VARIANT                        =
       it_events                         = itab_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                          = itab_output
    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.                    " F_DISPLAY_ALV_OUTPUT
    *&      Form  F_POPULATE_SORT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_populate_sort .
      CLEAR: fs_sort.
      REFRESH: itab_sort.
    * Sort by Account Manager
      fs_sort-spos = '01' .
      fs_sort-fieldname = 'ACT_MANAGER'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Sales Office
      fs_sort-spos = '02' .
      fs_sort-fieldname = 'VKBUR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Customer
      fs_sort-spos = '03' .
      fs_sort-fieldname = 'KUNNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Material
      fs_sort-spos = '04' .
      fs_sort-fieldname = 'MATNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    ENDFORM.                    " F_POPULATE_SORT
    *&      Form  F_GET_EVENT
    *  Handle events for the list
    *  -->  p1        text
    *  <--  p2        text
    FORM f_get_event .
      REFRESH: itab_events.
      CLEAR: fs_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = itab_events
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
      CLEAR: fs_events.
      READ TABLE itab_events INTO fs_events WITH KEY name = slis_ev_top_of_page.
      IF sy-subrc EQ 0.
        MOVE 'F_ALV_TOP_OF_PAGE' TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
      CLEAR fs_events.
      READ TABLE itab_events  INTO fs_events WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE wl_formname_subtotal_text TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " F_GET_EVENT
    *&      Form  SUBTOTAL_TEXT_form
    *       text
    FORM subtotal_text_form USING p_subtot_text TYPE slis_subtot_text.
      IF p_subtot_text-criteria = 'ACT_MANAGER'.
        p_subtot_text-display_text_for_subtotal = 'Account Manager Level Subtotal'(020).
      ENDIF.
    ENDFORM.                    "SUBTOTAL_TEXT
    *&      Form  f_alv_top_of_page
    *       text
    FORM f_alv_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = itab_top_of_page.
    ENDFORM.                    "F_ALV_TOP_OF_PAGE
    Edited by: Rajesh Tummala on Apr 7, 2009 4:16 PM

    Here's the code below. Sub total text event is not working but top of page is working fine.
    *&      Form  F_POPULATE_SORT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f_populate_sort .
      CLEAR: fs_sort.
      REFRESH: itab_sort.
    * Sort by Account Manager
      fs_sort-spos = '01' .
      fs_sort-fieldname = 'ACT_MANAGER'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Sales Office
      fs_sort-spos = '02' .
      fs_sort-fieldname = 'VKBUR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Customer
      fs_sort-spos = '03' .
      fs_sort-fieldname = 'KUNNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    * Sort by Material
      fs_sort-spos = '04' .
      fs_sort-fieldname = 'MATNR'.
      fs_sort-tabname = 'ITAB_OUTPUT'.
      fs_sort-up = 'X'.
      fs_sort-subtot = 'X'.
      APPEND fs_sort TO itab_sort .
      CLEAR fs_sort.
    ENDFORM.                    " F_POPULATE_SORT
    *&      Form  F_GET_EVENT
    *  Handle events for the list
    *  -->  p1        text
    *  <--  p2        text
    FORM f_get_event .
      REFRESH: itab_events.
      CLEAR: fs_events.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = itab_events
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
      CLEAR: fs_events.
      READ TABLE itab_events INTO fs_events WITH KEY name = slis_ev_top_of_page.
      IF sy-subrc EQ 0.
        MOVE 'F_ALV_TOP_OF_PAGE' TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
      CLEAR fs_events.
      READ TABLE itab_events  INTO fs_events WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE wl_formname_subtotal_text TO fs_events-form.
        MODIFY itab_events FROM fs_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " F_GET_EVENT
    *&      Form  F_DISPLAY_ALV_OUTPUT
    *   Display the list output
    *  -->  p1        text
    *  <--  p2        text
    FORM f_display_alv_output .
      DATA: loc_repid TYPE sy-repid.
      CLEAR: loc_repid.
      loc_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = loc_repid
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   i_callback_top_of_page            = 'F_ALV_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                         = fs_layout
       it_fieldcat                       = itab_fieldcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = itab_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
       i_default                         = 'X'
       i_save                            = 'A'
    *   IS_VARIANT                        =
       it_events                         = itab_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                          = itab_output
    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.                    " F_DISPLAY_ALV_OUTPUT
    *&      Form  SUBTOTAL_TEXT_form
    *       text
    FORM subtotal_text_form USING p_subtot_text TYPE slis_subtot_text.
      IF p_subtot_text-criteria = 'ACT_MANAGER'.
        p_subtot_text-display_text_for_subtotal = 'Account Manager Level Subtotal'(020).
      ENDIF.
    ENDFORM.                    "SUBTOTAL_TEXT
    *&      Form  f_alv_top_of_page
    *       text
    FORM f_alv_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = itab_top_of_page.
    ENDFORM.                    "F_ALV_TOP_OF_PAGE

  • How to print sub total text in ALV

    Hi All,
       I have a prblem in printing sub total text in ALV. I am passing the text for sub total in ALV layout to the field SUBTOTALS_TEXT. Even then the text is not displayed where as this is working for TOTAL with the field TOTALS_TEXT.
       Could any one provide me the solution please?
    Thanks & Regards,
    S.Lakshmi

    Hi Lakshmi,
    Please refer to the following code :
    report zalv10.
    type-pools: slis.
    data: g_repid like sy-repid,
    gs_print type slis_print_alv,
    gt_list_top_of_page type slis_t_listheader,
    gt_events type slis_t_event,
    gt_sort type slis_t_sortinfo_alv,
    gs_layout type slis_layout_alv,
    gt_fieldcat type slis_t_fieldcat_alv,
    fieldcat_ln like line of gt_fieldcat,
    col_pos type i.
    data: begin of itab,
    field1(5) type c,
    field2(5) type c,
    field3(5) type p decimals 2,
    end of itab.
    data: begin of itab1 occurs 0.
    include structure itab.
    data: end of itab1.
    data: begin of itab_fieldcat occurs 0.
    include structure itab.
    data: end of itab_fieldcat.
    Print Parameters
    parameters:
    p_print as checkbox default ' ', "PRINT IMMEDIATE
    p_nosinf as checkbox default 'X', "NO SELECTION INFO
    p_nocove as checkbox default ' ', "NO COVER PAGE
    p_nonewp as checkbox default ' ', "NO NEW PAGE
    p_nolinf as checkbox default 'X', "NO PRINT LIST INFO
    p_reserv type i. "NO OF FOOTER LINE
    initialization.
    g_repid = sy-repid.
    perform print_build using gs_print. "Print PARAMETERS
    start-of-selection.
    TEST DATA
    move 'TEST1' to itab1-field1.
    move 'TEST1' to itab1-field2.
    move '10.00' to itab1-field3.
    append itab1.
    move 'TEST2' to itab1-field1.
    move 'TEST2' to itab1-field2.
    move '20.00' to itab1-field3.
    append itab1.
    do 50 times.
    append itab1.
    enddo.
    end-of-selection.
    perform build.
    perform eventtab_build changing gt_events.
    perform comment_build changing gt_list_top_of_page.
    perform call_alv.
    form build.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    data: fieldcat_in type slis_fieldcat_alv.
    clear fieldcat_in.
    fieldcat_ln-fieldname = 'FIELD1'.
    fieldcat_ln-tabname = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT = 'X'. "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    fieldcat_ln-key = ' '. "SUBTOTAL KEY
    fieldcat_ln-no_out = ' '.
    fieldcat_ln-seltext_l = 'HEAD1'.
    append fieldcat_ln to gt_fieldcat.
    clear fieldcat_in.
    fieldcat_ln-fieldname = 'FIELD2'.
    fieldcat_ln-tabname = 'ITAB1'.
    fieldcat_ln-no_out = 'X'.
    fieldcat_ln-seltext_l = 'HEAD2'.
    append fieldcat_ln to gt_fieldcat.
    clear fieldcat_in.
    fieldcat_ln-fieldname = 'FIELD3'.
    fieldcat_ln-tabname = 'ITAB1'.
    fieldcat_ln-ref_fieldname = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    fieldcat_ln-ref_tabname = 'MSEG'. "<- REF TABLE IN THE DICTIONNARY
    fieldcat_ln-no_out = ' '.
    fieldcat_ln-do_sum = 'X'. "SUM UPON DISPLAY
    append fieldcat_ln to gt_fieldcat.
    DATA SORTING AND SUBTOTAL
    data: gs_sort type slis_sortinfo_alv.
    clear gs_sort.
    gs_sort-fieldname = 'FIELD1'.
    gs_sort-spos = 1.
    gs_sort-up = 'X'.
    gs_sort-subtot = 'X'. ***CRUCIAL STATEMENT****
    append gs_sort to gt_sort.
    clear gs_sort.
    gs_sort-fieldname = 'FIELD2'.
    gs_sort-spos = 2.
    gs_sort-up = 'X'.
    *GS_SORT-SUBTOT = 'X'. **THIS SHOULD NOT BE UNCOMENTED*
    append gs_sort to gt_sort.
    endform.
    form call_alv.
    ABAP List Viewer
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    i_callback_program = g_repid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ITAB1'
    is_layout = gs_layout
    it_fieldcat = gt_fieldcat[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    it_sort = gt_sort[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    it_events = gt_events[]
    IT_EVENT_EXIT =
    is_print = gs_print
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab1
    exceptions
    program_error = 1
    others = 2.
    endform.
    HEADER FORM
    form eventtab_build changing lt_events type slis_t_event.
    constants:
    gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
    data: ls_event type slis_alv_event.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = lt_events.
    read table lt_events with key name = slis_ev_top_of_page
    into ls_event.
    if sy-subrc = 0.
    move gc_formname_top_of_page to ls_event-form.
    append ls_event to lt_events.
    endif.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
    INTO LS_EVENT.
    IF SY-SUBRC = 0.
    MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
    APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    endform.
    form comment_build changing gt_top_of_page type slis_t_listheader.
    data: gs_line type slis_listheader.
    clear gs_line.
    gs_line-typ = 'H'.
    gs_line-info = 'HEADER 1'.
    append gs_line to gt_top_of_page.
    clear gs_line.
    gs_line-typ = 'S'.
    gs_line-key = 'STATUS 1'.
    gs_line-info = 'INFO 1'.
    append gs_line to gt_top_of_page.
    gs_line-key = 'STATUS 2'.
    gs_line-info = 'INFO 2'.
    append gs_line to gt_top_of_page.
    CLEAR GS_LINE.
    GS_LINE-TYP = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO GT_TOP_OF_PAGE.
    endform.
    form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = gt_list_top_of_page.
    write: sy-datum, 'Page No', sy-pagno left-justified.
    endform.
    form end_of_page.
    write at (sy-linsz) sy-pagno centered.
    endform.
    PRINT SETTINGS
    form print_build using ls_print type slis_print_alv.
    ls_print-print = p_print. "PRINT IMMEDIATE
    ls_print-no_print_selinfos = p_nosinf. "NO SELECTION INFO
    ls_print-no_coverpage = p_nocove. "NO COVER PAGE
    ls_print-no_new_page = p_nonewp.
    ls_print-no_print_listinfos = p_nolinf. "NO PRINT LIST INFO
    ls_print-reserve_lines = p_reserv.
    endform.
    <b>Please reward points if helpful.</b>
    Regards,
    Amit Mishra

  • Alv sub total problem

    hi,
    in alv i want sub total text for purchase order.
    can you check my code . i am not getting.
    TYPE-POOLS: slis.
    TABLES: ekko,ekpo,eket.
    TYPES: BEGIN OF ty_ekko,
            lifnr TYPE elifn,
            ebeln TYPE ebeln,
            ebeln1 TYPE ebeln,
            bsart TYPE esart,
            ekorg TYPE ekorg,
            ekgrp TYPE bkgrp,
            ernam TYPE ernam,
           END OF ty_ekko,
           BEGIN OF ty_ekpo,
            ebeln TYPE ebeln,
            matnr TYPE matnr,
            ebelp TYPE ebelp,
            ebelp1 TYPE ebelp,
            menge TYPE bstmg,
            meins TYPE bstme,
            netpr TYPE bprei,
            werks TYPE ewerk,
           END OF ty_ekpo,
           BEGIN OF ty_eket,
            ebeln TYPE ebeln,
            ebelp TYPE ebelp,
            etenr TYPE eeten,
            eindt TYPE eindt,
           END OF ty_eket,
           BEGIN OF ty_final,
            slno TYPE sy-dbcnt,
            lifnr TYPE elifn,
            ebeln TYPE ebeln,
            ebeln1 TYPE ebeln,
            bsart TYPE esart,
            ekorg TYPE ekorg,
            ekgrp TYPE bkgrp,
            ernam TYPE ernam,
            matnr TYPE matnr,
            ebelp TYPE ebelp,
            ebelp1 TYPE ebelp,
            menge TYPE bstmg,
            meins TYPE bstme,
            netpr TYPE bprei,
            werks TYPE ewerk,
            eindt TYPE eindt,
           END OF ty_final.
    DATA: it_ekko TYPE STANDARD TABLE OF ty_ekko,
          it_ekpo TYPE STANDARD  TABLE OF ty_ekpo,
          it_eket TYPE STANDARD  TABLE OF ty_eket,
          it_final TYPE STANDARD TABLE OF ty_final,
          it_fieldcat TYPE slis_t_fieldcat_alv,
          it_alv_top_of_page TYPE slis_t_listheader,
          it_sort TYPE  slis_t_sortinfo_alv,
          it_event TYPE slis_t_event,
          l_repid TYPE syrepid,
          slno TYPE i VALUE 1.
    DATA: wa_ekko TYPE ty_ekko,
          wa_ekpo TYPE ty_ekpo,
          wa_eket TYPE ty_eket,
          wa_final TYPE ty_final,
          wa_fieldcat TYPE slis_fieldcat_alv,
          wa_alv_top_of_page TYPE slis_listheader,
          wa_sort TYPE  slis_sortinfo_alv,
          wa_layout   TYPE slis_layout_alv.
         wa_event TYPE slis_alv_event.
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_aedat FOR ekko-aedat.
    SELECTION-SCREEN END OF BLOCK blk.
    START-OF-SELECTION.
    PERFORM validation.
      PERFORM retrive_data.
      PERFORM sub_build_header.
      PERFORM sub_field_catalog.
      PERFORM sub_populate_layout.
      PERFORM sub_populate_sort.
      PERFORM sub_get_event.
    *END-OF-SELECTION.
    Perform to display ALV report
      PERFORM sub_alv_report_display.
    *FORM validation .
    SELECT SINGLE * FROM ekko WHERE aedat IN s_aedat .
    IF sy-subrc <> 0.
       MESSAGE e001(zram).
    ENDIF.
    *ENDFORM.                    " validation
    FORM retrive_data .
      SELECT lifnr
             ebeln
             ebeln
             bsart
             ekorg
             ekgrp
             ernam FROM ekko INTO TABLE it_ekko
            INTO CORRESPONDING FIELDS OF TABLE it_ekko
             WHERE aedat IN s_aedat .
      IF it_ekko[] IS NOT INITIAL.
        SELECT ebeln
               ebelp
               ebelp
               matnr
               menge
               meins
               netpr
               werks FROM ekpo
               INTO corresponding fields of  TABLE it_ekpo
               FOR ALL ENTRIES IN it_ekko
               WHERE ebeln = it_ekko-ebeln .
          if sy-subrc = 0.
             SELECT ebeln
               ebelp
               etenr
               eindt
               FROM eket INTO  TABLE it_eket
               FOR ALL ENTRIES IN it_ekpo
               WHERE ebeln = it_ekpo-ebeln .
            endif.
      ENDIF.
    ENDIF.
      LOOP AT it_ekko INTO wa_ekko.
        READ TABLE it_ekpo INTO wa_ekpo
                              WITH KEY ebeln = wa_ekko-ebeln.
        READ TABLE it_eket INTO wa_eket
                                WITH KEY ebeln = wa_ekpo-ebeln.
        wa_final-slno  =  slno.
        wa_final-lifnr = wa_ekko-lifnr.
        wa_final-ebeln = wa_ekko-ebeln.
        wa_final-bsart = wa_ekko-bsart.
        wa_final-ekgrp = wa_ekko-ekgrp.
        wa_final-ekorg = wa_ekko-ekorg.
        wa_final-ernam = wa_ekko-ernam.
        wa_final-ebelp = wa_ekpo-ebelp.
        wa_final-matnr = wa_ekpo-matnr.
        wa_final-menge = wa_ekpo-menge.
        wa_final-meins = wa_ekpo-meins.
        wa_final-netpr = wa_ekpo-netpr.
        wa_final-werks = wa_ekpo-werks.
        wa_final-eindt = wa_eket-eindt.
        slno = slno + 1.
        APPEND wa_final TO it_final.
      ENDLOOP.
    ENDFORM.                    " retrive_data
    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 it_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 it_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.
    ENDFORM.                    " sub_build_header
    FORM sub_field_catalog .
      REFRESH it_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '01'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'SLNO'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'SLNo'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '4'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '02'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'LIFNR'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'Supplier Name'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '12'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '03'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'EBELN'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'PO No'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '15'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '03'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'EBELN1'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'PO No'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = 'X'.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
    ENDFORM.                    " sub_field_catalog
    FORM sub_populate_layout .
      CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col width
    ENDFORM.                    " sub_populate_layout
    FORM sub_populate_sort .
    Sort on material
      wa_sort-spos      = '01' .
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname   = 'IT_FINAL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    Sort on plant
      wa_sort-spos      = '02'.
      wa_sort-fieldname = 'EBELP'.
      wa_sort-tabname   = 'IT_FINAL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
                                                      'SUBTOTAL_TEXT'.
      data : wa_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = it_event
        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.
    Subtotal
      READ TABLE it_event  INTO wa_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO wa_event-form.
        MODIFY it_event FROM wa_event  INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " sub_get_event
    FORM sub_alv_report_display .
      l_repid = sy-repid .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = l_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
         i_callback_top_of_page            = 'SUB_ALV_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                         = wa_layout
       it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      i_default                         = 'X'
      i_save                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         = i_event
      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_final
    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.                    " sub_alv_report_display
    FORM sub_alv_top_of_page.                                   "#EC CALLED
    To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_alv_top_of_page.
    ENDFORM.                    "alv_top_of_page
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'EBELN'.
        p_subtot_text-display_text_for_subtotal
        = 'The Nett price of PO No'(009).
      ENDIF.
    Plant level sub total
      IF p_subtot_text-criteria = 'EBELP'.
        p_subtot_text-display_text_for_subtotal = 'Total Purchase Order value placed'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text

    hi ,
    try the given below code ...
    "*************INTERNAL TABLE FR SORTING***********************
    DATA: it_sort TYPE slis_t_sortinfo_alv.
    "******** WORK AREA FR FIELD CATALOG *************************
    DATA: wa_sort TYPE slis_sortinfo_alv.
       wa_sort-fieldname = 'EBELN'."field name
      wa_sort-tabname = 'IT_TAB'."internal table name
      wa_sort-up = 'X'.
      wa_sort-subtot ='X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    it_sort                           = it_sort
    ENDFORM.                    "alv
    hope this helps
    Regards
    RItesh J

  • How to display sub total text in ALV grid display reporting

    Hi,
    I want to display a text 'SUB TOTAL'  in Sub total  row  of an ALV report.
    Presently I am getting the name of the field used in sorting to get sub totals. But I required to display own text. Could you please give me solution.
    Thanks
    Giridhar Karnam

    For doing this u need to simply modify the layout properties, please award points if found helpful
    DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV.
    L_LAYOUT-SUBTOTALS_TEXT = 'GEN SUBTOT'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_FINAL
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.

  • Sub total text in ALV report

    Hi,
    I need to do subtotalling in my program using ALV. I am getting the subtotal value in ALV list display , but not getting the text for subtotalling.
    matnr               werks                       stock
    154                  1001                         1589
    158                  1001                         1651
    Subtotal for plant 1001                               3240
    155                  1002                         465
    Subtotal for plant 1002                       465

    hi,
    how did u declared ur internal table?
    Declare a dummy field in your internal table to trigger subtotal text event.
    TYPES: BEGIN OF ty_ekpo,
              lifnr TYPE ekko-lifnr,    "vendor number
              ebeln TYPE ekko-ebeln,    "purchase document number
              ebelp TYPE ekpo-ebelp,    "Item Number of Purchasing Document
              matnr TYPE ekpo-matnr,    "Material Number
              bukrs TYPE ekpo-bukrs,    "Company Code
              werks TYPE ekpo-werks,    "Plant
              d,                        "Dummy field to fire the Subtotal text event
          END OF ty_ekpo.
    Prepare field catalog for that dummyfield also and set attributes like below
    wa_fcat-col_pos = 7.
      wa_fcat-fieldname = 'D'.
      wa_fcat-tabname = 'IT_EKPO'.
      wa_fcat-ref_fieldname = 'NETPR'.
      wa_fcat-ref_tabname = 'EKPO'.
      wa_fcat-no_out = 'X'.
      APPEND wa_fcat TO it_fcat.
    Fill sortinfo table as follows
    wa_sort-spos = 1.
      wa_sort-fieldname = 'LIFNR'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
      wa_sort-spos = 2.
      wa_sort-fieldname = 'D'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO it_sort.
    fill the event table
    wa_event-name = 'SUBTOTAL_TEXT'.  "--> this event is used to trigger subtotal text
      wa_event-form = 'SUBTOTAL'.
      APPEND wa_event TO it_event.
    *&      Form  subtotal
    FORM subtotal USING i_listhead STRUCTURE wa_ekpo  i_subtotal TYPE slis_subtot_text.
      READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
      IF sy-subrc = 0.
        IF i_subtotal-criteria = 'D'.
          i_subtotal-display_text_for_subtotal = 'Sub total'.
        ENDIF.
      ENDIF.
    ENDFORM.                    "subtotal
    Thanks & REgards

  • Total Text Display at the end of the ALV

    Hi,
    I want to display the text 'TOTAL' in my ALV at the end of my report.I am pasting my code, So please any one help me in this issue.
    *& Report  ZFIR0011_O2C_TAX_GL_SUMMARY
    REPORT  zfir0011_o2c_tax_gl_summary.
    TYPE-POOLS slis.
    TABLES: faglflexa.
    Column positions to pass to field catalog
    CONSTANTS :  c_pos_1      TYPE sy-cucol       VALUE '1',   " position of the columns
                 c_pos_2      TYPE sy-cucol       VALUE '2',
                 c_pos_3      TYPE sy-cucol       VALUE '3',
                 c_pos_4      TYPE sy-cucol       VALUE '4',
                 c_pos_5      TYPE sy-cucol       VALUE '5'.
    *Field names for Field Catalog
    CONSTANTS : c_h           TYPE c              VALUE 'H',
                c_s           TYPE c              VALUE 'S',
                c_slash       TYPE c              VALUE '/',
                c_colon       TYPE c              VALUE ':',
                c_top_of_page TYPE slis_formname  VALUE 'TOP_OF_PAGE',
                c_top_of_page_split TYPE slis_formname  VALUE 'TOP_OF_PAGE_SPLIT',
                c_txjcd       TYPE slis_fieldname VALUE 'TXJCD',     "Tax Jurisdiction
                c_region      TYPE slis_fieldname VALUE 'STATE',     "State
                c_currb       TYPE slis_fieldname VALUE 'CURR_BAL',  "Current Balance
                c_perch       TYPE slis_fieldname VALUE 'PER_CHNG',  "Period Change
                c_prbal       TYPE slis_fieldname VALUE 'PRI_BALA',  "Prior Balance
                c_total       TYPE slis_fieldname VALUE 'TOTAL'.     "Total
    CONSTANTS : c_table_name  TYPE slis_tabname   VALUE 'IT_FINAL', "For Field Catalog
                c_spras       TYPE spras          VALUE 'E',        "Language
                c_buzei       TYPE c              VALUE '1',
                c_zp          TYPE bset-mwskz     VALUE 'ZP',
                c_zr          TYPE bset-mwskz     VALUE 'ZR'.
    Types Declaration.
    TYPES: BEGIN OF ty_faglflexa,
           ryear TYPE gjahr,
           bukrs TYPE bukrs,
           belnr TYPE belnr_d,                  "Document Number
           poper TYPE poper,                    "Posting Period
           budat TYPE budat,                    "Posting Date
           buzei TYPE buzei,                    "Document line item
           racct TYPE racct,                    "G/L Account no.
           END   OF ty_faglflexa,
           ty_t_faglflexa TYPE STANDARD TABLE OF ty_faglflexa.
    TYPES: BEGIN OF ty_bset,
           belnr TYPE belnr_d,
           buzei TYPE buzei,
           mwskz TYPE mwskz,                    "Tax code
          hkont TYPE hkont,
           shkzg TYPE shkzg,                    "Debit/Credit Indicator
           txjcd TYPE txjcd,                    "Tax Jurisdiction
           h2ste TYPE h2ste,                    "Tax Amount
           h2bas TYPE h2bas_bses,               "Tax Amount
           END   OF ty_bset,
           ty_t_bset TYPE STANDARD TABLE OF ty_bset.
    TYPES: BEGIN OF ty_skat,
           spras TYPE spras,
           ktopl TYPE ktopl,
           saknr TYPE saknr,
           text  TYPE txt20_skat,
           END   OF ty_skat,
           ty_t_skat TYPE STANDARD TABLE OF ty_skat.
    TYPES: BEGIN OF ty_custom,
           geo_state    TYPE char2,
           geo_county   TYPE char3,
           country      TYPE char2,
           description  TYPE char40,
           END   OF ty_custom,
           ty_t_custom TYPE STANDARD TABLE OF ty_custom.
    TYPES : BEGIN OF ty_budat,
             sign     TYPE char_01,
             option   TYPE char2,
             low      TYPE budat,
             high     TYPE budat,
            END OF ty_budat,
            ty_t_budat TYPE STANDARD TABLE OF ty_budat.
    TYPES: BEGIN OF ty_txjcd,
           geo_state  TYPE char2,
           geo_county TYPE char3,
           END   OF ty_txjcd,
           ty_t_txjcd TYPE STANDARD TABLE OF ty_txjcd.
    TYPES: BEGIN OF ty_inter,
           ryear TYPE gjahr,
           bukrs TYPE bukrs,
           txjcd TYPE txjcd,                    "Tax Jurisdiction
           racct TYPE racct,                    "G/L Account no.
           h2ste TYPE h2ste,                    "Tax Amount
           poper TYPE poper,                    "Posting Period
           belnr TYPE belnr_d,                  "Document Number
           shkzg TYPE shkzg,                    "Debit/Credit Indicator
           END   OF ty_inter,
           ty_t_inter TYPE STANDARD TABLE OF ty_inter.
    TYPES: BEGIN OF ty_final,
           txjcd    TYPE bset-txjcd,                     "Tax Jurisdiction
           state    TYPE char40,                         "State
           curr_bal TYPE bset-h2ste,                     "Current Balance
           per_chng TYPE bset-h2ste,                     "Period Change
           pri_bala TYPE bset-h2ste,                     "Prior Balance
           END   OF ty_final,
           ty_t_final TYPE STANDARD TABLE OF ty_final.
    Internal Tables Declaration.
    DATA : it_faglflexa        TYPE ty_t_faglflexa,
           it_bset             TYPE ty_t_bset,
           it_skat             TYPE ty_t_skat,
           it_custom           TYPE ty_t_custom,
           it_txjcd            TYPE ty_t_txjcd,
           it_inter            TYPE ty_t_inter.                 "Intermediate table for storing data
    DATA : it_final            TYPE ty_t_final.                 "#EC NEEDED
    *Fieldcatalogue Internal Table Declaration
    DATA : it_fieldcat         TYPE slis_t_fieldcat_alv,
           wa_fieldcat         TYPE slis_fieldcat_alv,
           it_alv_top_of_page  TYPE slis_t_listheader,
           gs_line             TYPE slis_listheader.
    *Field-symbols and Work Area Declarations
    FIELD-SYMBOLS : <fs_faglflexa>      TYPE ty_faglflexa,
                    <fs_bset>           TYPE ty_bset,
                    <fs_inter>          TYPE ty_inter.
    DATA : wa_faglflexa     TYPE ty_faglflexa,                  "#EC NEEDED
           wa_bset          TYPE ty_bset,
           wa_skat          TYPE ty_skat,
           wa_custom        TYPE ty_custom,
           wa_txjcd         TYPE ty_txjcd,
           wa_inter         TYPE ty_inter,
           wa_final         TYPE ty_final.                      " #EC NEEDED
    Variables Declaration.
    DATA : v_current_year TYPE i,
           v_poper        TYPE poper,
           v_saknr        TYPE saknr,                           "#EC NEEDED
           v_ktopl        TYPE ktopl,
           v_konts        TYPE saknr,
           v_bukrs        TYPE bukrs,
           v_buzei(2)     TYPE n VALUE '0',
           v_sum_val      TYPE h2ste,
           v_sum_val1     TYPE h2ste,
           v_sum_val2     TYPE h2ste,
           v_h2ste        TYPE string,
           v_desc         TYPE char40,
           v_title        TYPE char40,
           v_start_date   TYPE char10.             "Temp Added
    SELECTION-SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_bukrs TYPE faglflexa-rbukrs OBLIGATORY,              " Company Code
                    p_gjahr TYPE faglflexa-gjahr  OBLIGATORY.              " Fiscal Year
    SELECT-OPTIONS: s_budat FOR  faglflexa-budat  OBLIGATORY
                                                  NO-EXTENSION
                                                  NO INTERVALS.
    PARAMETERS:     p_racct TYPE faglflexa-racct  OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN VALIDATIONS.
    *Company Code Validation.
    AT SELECTION-SCREEN ON p_bukrs.
      SELECT SINGLE bukrs INTO v_bukrs
      FROM t001
      WHERE bukrs = p_bukrs.
      IF sy-subrc NE 0.
        MESSAGE text-002 TYPE 'E'.
      ENDIF.
    Fiscal Year Validation. It should not be more than Current.
    AT SELECTION-SCREEN ON p_gjahr.
      v_current_year = sy-datum+0(4).
      IF p_gjahr > v_current_year.
        MESSAGE text-003 TYPE 'E'.
      ENDIF.
    *G/L Account Validation.
    AT SELECTION-SCREEN ON p_racct.
      SELECT SINGLE saknr INTO v_saknr
      FROM skb1
      WHERE saknr EQ p_racct
      AND   bukrs EQ p_bukrs.
      IF sy-subrc EQ 0.
        SELECT SINGLE ktopl FROM t001
        INTO v_ktopl
        WHERE bukrs = p_bukrs.
        SELECT SINGLE konts FROM t030k
        INTO v_konts
        WHERE ktopl = v_ktopl
        AND   konts = v_saknr.
        IF sy-subrc NE 0.
          MESSAGE text-004 TYPE 'E'.
        ENDIF.
      ELSE.
        MESSAGE text-004 TYPE 'E'.
      ENDIF.
    START-OF-SELECTION.
      PERFORM get_data USING p_bukrs
                             p_gjahr
                             s_budat[]
                             p_racct  CHANGING it_final.
    *Display report in ALV grid
      IF it_final IS NOT INITIAL.
    *Build Top of the page table.
        PERFORM comment_build USING it_skat CHANGING it_alv_top_of_page.
    *Build Field catalog table for ALV
        PERFORM build_field_catalog CHANGING it_fieldcat.
    *Display report
        PERFORM display_alv USING it_final.
      ELSE.
    *No data found for the selection criteria/period.
        MESSAGE text-018 TYPE 'I'.
      ENDIF.
    *&      Form  GET_DATA
          text
         -->P_P_BUKRS  text
         -->P_P_GJAHR  text
         -->P_P_BUDAT  text
         -->P_P_RACCT  text
         <--P_IT_FINAL  text
    FORM get_data  USING    fp_bukrs     TYPE bukrs
                            fp_gjahr     TYPE gjahr
                            fp_budat     TYPE ty_t_budat
                            fp_racct     TYPE racct
                   CHANGING fp_it_final  TYPE ty_t_final.
      DATA : v_date(2)  TYPE c VALUE '01',
             v_month(2) TYPE c VALUE '01',
             v_start_date TYPE datum.
    *concatenate p_gjahr v_month v_date into v_start_date.  " separated by c_slash.
      SELECT ryear
             rbukrs
             belnr                                "Document Number
             poper                                "Posting Period
             budat                                "Posting Date
             buzei                                "Document line item
             racct                                "G/L Account no.
             INTO TABLE it_faglflexa
             FROM faglflexa
             WHERE rbukrs EQ p_bukrs
             AND   gjahr  EQ p_gjahr
             AND   budat  LE s_budat
             AND   racct  EQ p_racct.
    *selecting the Tax Jurisdiction, Tax amount from BSET
      IF it_faglflexa IS NOT INITIAL.
        SELECT belnr
               buzei
               mwskz
               "hkont
               shkzg                                "Debit/Credit Indicator
               txjcd                                "Tax Jurisdicaiton
               h2ste                                "Tax Amount
               h2bas                                "Tax Amount1
               INTO TABLE it_bset
               FROM bset
               FOR ALL ENTRIES IN it_faglflexa
               WHERE belnr EQ it_faglflexa-belnr
               AND   gjahr EQ p_gjahr               "it_faglflexa-ryear
               AND   buzei EQ c_buzei.              "Line item
      ENDIF.
      IF sy-subrc EQ 0.
        SORT it_bset BY txjcd ASCENDING.
      ENDIF.
    *Selecting the G/L Account Long Text from SKAT
      IF it_faglflexa IS NOT INITIAL.
        SELECT  spras                            " Language key
                ktopl                            " Chart of Accounts
                saknr                            " G/L Account Number
                txt20                            " G/L Account Long Text
             INTO TABLE it_skat
             FROM skat
             FOR ALL ENTRIES IN it_faglflexa
             WHERE spras =  c_spras
             AND   saknr =  it_faglflexa-racct.
      ENDIF.
    *Selecting the Description from Custom table
      LOOP AT it_bset ASSIGNING <fs_bset>.
        wa_txjcd-geo_state  = <fs_bset>-txjcd+0(2).
        wa_txjcd-geo_county = <fs_bset>-txjcd+2(3).
        APPEND wa_txjcd TO it_txjcd.
        CLEAR wa_txjcd.
      ENDLOOP.
      IF it_txjcd IS NOT INITIAL.
        SELECT geo_state
               geo_county
               country
               description
        INTO TABLE it_custom
        FROM ztfi_tgl_summary
        FOR ALL ENTRIES IN it_txjcd
        WHERE geo_state  = it_txjcd-geo_state
        AND   geo_county = it_txjcd-geo_county.
      ENDIF.
      LOOP AT it_faglflexa ASSIGNING <fs_faglflexa>.
        MOVE-CORRESPONDING <fs_faglflexa> TO wa_inter.          "#EC ENHOK
    *Read Tax Jurisdiction and Tax Amount from BSET Table.
        READ TABLE it_bset INTO wa_bset WITH KEY belnr =  <fs_faglflexa>-belnr.
        IF sy-subrc EQ 0.
          wa_inter-shkzg = wa_bset-shkzg.
          wa_inter-txjcd = wa_bset-txjcd.
        ENDIF.
    *If BSET-MWSKZ = ZP or ZR then pick H2BAS as Tax Amount.
        IF wa_bset-mwskz = c_zp.
          wa_inter-h2ste = wa_bset-h2bas.
        ELSEIF wa_bset-mwskz = c_zr.
          wa_inter-h2ste = wa_bset-h2bas.
        ELSE.
          wa_inter-h2ste = wa_bset-h2ste.
        ENDIF.
    *Check it is credit entry or debit entry ('H' or 'S').
        IF wa_inter-shkzg EQ 'H'.
          wa_inter-h2ste = wa_inter-h2ste * -1.
        ENDIF.
        APPEND wa_inter TO it_inter.
        CLEAR: wa_inter, wa_bset.
      ENDLOOP.
      IF sy-subrc EQ 0.
        SORT it_inter BY bukrs ryear txjcd ASCENDING.
        DELETE it_inter WHERE txjcd EQ space.
      ENDIF.
      v_poper = s_budat-low+4(2).
      LOOP AT it_inter INTO wa_inter.
    *Read the Text maintained in the custom table based on the GEO_STATE = First two digits of TXJCD
    *and GEO_COUNTY = Next three digits of TXJCD. If this is blank pick based on First two digits of TXJCD.
        READ TABLE it_custom INTO wa_custom WITH KEY geo_state  = wa_bset-txjcd+0(2)
                                                     geo_county = wa_bset-txjcd+2(3).
        IF sy-subrc NE 0.
          READ TABLE it_custom INTO wa_custom WITH KEY geo_state  = wa_bset-txjcd+0(2).
        ENDIF.
        IF sy-subrc = 0.
          wa_final-state = wa_custom-description.
        ENDIF.
        AT NEW txjcd.
          CLEAR: v_sum_val, v_sum_val1, v_sum_val2.
        ENDAT.
      Period Change
        IF wa_inter-poper EQ v_poper.
          v_sum_val1 = v_sum_val1 + wa_inter-h2ste.
        ENDIF.
      Prior Balance
        IF wa_inter-poper LT v_poper.
          v_sum_val2 = v_sum_val2 + wa_inter-h2ste.
        ENDIF.
        AT END OF txjcd.
          wa_final-txjcd    = wa_inter-txjcd.
          wa_final-per_chng = v_sum_val1.                                     "Period change
          wa_final-pri_bala = v_sum_val2.                                     "Prior Balance
          wa_final-curr_bal = v_sum_val1 + v_sum_val2.                        "Current Balance
          APPEND wa_final TO it_final.
          CLEAR wa_final.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  COMMENT_BUILD
          text
         -->P_IT_SKAT  text
         <--P_IT_ALV_TOP_OF_PAGE  text
    FORM comment_build  USING    fp_it_skat            TYPE ty_t_skat
                        CHANGING fp_it_alv_top_of_page TYPE slis_t_listheader.
      DATA: v_budat_low  TYPE c LENGTH 10,
            v_budat_high TYPE c LENGTH 10,
            v_butxt      TYPE butxt.
      CLEAR gs_line.
    *Report Title
      CONCATENATE text-005 p_bukrs INTO v_title SEPARATED BY space.
      gs_line-typ = c_h.
      gs_line-key = ' '.
      gs_line-info = v_title.
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *Account Number
      gs_line-typ = c_s.
      gs_line-key = text-006.
      gs_line-info = p_racct.
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *G/L Account Description
      READ TABLE it_skat INTO wa_skat WITH KEY ktopl = v_ktopl.
      IF sy-subrc EQ 0.
        v_desc = wa_skat-text.
      ENDIF.
      gs_line-typ = c_s.
      gs_line-key = text-007.
      gs_line-info = v_desc.
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *Fiscal Year from selection
      IF NOT p_gjahr IS INITIAL.
        gs_line-info = p_gjahr.
        gs_line-typ   = c_s.
        gs_line-key  = text-008.                                              "Fiscal Year
        APPEND gs_line TO fp_it_alv_top_of_page.
        CLEAR gs_line.
      ENDIF.
    *Posting Date
      CONCATENATE s_budat-low4(2) s_budat-low6(2) s_budat-low+0(4) INTO gs_line-info SEPARATED BY c_slash.
      gs_line-typ   = c_s.
      gs_line-key  = text-009.                                               "Posting Date
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR gs_line.
    *Company Code Description from selection
      IF NOT p_bukrs IS INITIAL.
        SELECT SINGLE butxt FROM t001
        INTO v_butxt WHERE bukrs EQ p_bukrs.
        gs_line-info = v_butxt.
        gs_line-typ  = c_s.
        gs_line-key  = text-010.                                              "Company Code Description
        APPEND gs_line TO fp_it_alv_top_of_page.
        CLEAR gs_line.
      ENDIF.
    Printed Date
      gs_line-typ = c_s.
      gs_line-key = text-011.                                                 "Printed Date
      CONCATENATE  sy-datum+4(2)
                   sy-datum+6(2)
                   sy-datum(4) INTO gs_line-info SEPARATED BY c_slash.        "todays date
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR: gs_line.
    Printing Time
      gs_line-typ = c_s.
      gs_line-key = text-012.                                                 "Printing Time
      gs_line-info = sy-uzeit.
      CONCATENATE  sy-uzeit(2)
                   sy-uzeit+2(2)
                   sy-uzeit+4(2) INTO gs_line-info SEPARATED BY c_colon.      "current time
      APPEND gs_line TO fp_it_alv_top_of_page.
      CLEAR: gs_line.
    ENDFORM.                    " COMMENT_BUILD
    *&      Form  BUILD_FIELD_CATALOG
          text
         <--P_IT_FIELDCAT  text
    FORM build_field_catalog  CHANGING fp_it_fieldcat TYPE slis_t_fieldcat_alv.
    TAX JURISDICTION
      wa_fieldcat-col_pos      = c_pos_1.
      wa_fieldcat-reptext_ddic = text-013.                                    "TAX JURISDICTION
      wa_fieldcat-fieldname    = c_txjcd.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-outputlen    = '15'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    STATE
      wa_fieldcat-col_pos      = c_pos_2.
      wa_fieldcat-reptext_ddic = text-014.                                    "STATE
      wa_fieldcat-fieldname    = c_region.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-outputlen    = '40'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    CURRENT BALANCE
      wa_fieldcat-col_pos      = c_pos_3.
      wa_fieldcat-reptext_ddic = text-015.                                    "CURRENT BALANCE
      wa_fieldcat-fieldname    = c_currb.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    PERIOD CHANGE
      wa_fieldcat-col_pos      = c_pos_4.
      wa_fieldcat-reptext_ddic = text-016.                                    "PERIOD CHANGE
      wa_fieldcat-fieldname    = c_perch.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    PRIOR BALANCE
      wa_fieldcat-col_pos      = c_pos_5.
      wa_fieldcat-reptext_ddic = text-017.                                    "PRIOR BALANCE
      wa_fieldcat-fieldname    = c_prbal.
      wa_fieldcat-tabname      = c_table_name.
      wa_fieldcat-do_sum       = 'X'.
      wa_fieldcat-datatype     = 'CURR'.
      wa_fieldcat-outputlen    = '17'.
      APPEND  wa_fieldcat TO fp_it_fieldcat.
      CLEAR : wa_fieldcat.
    ENDFORM.                    " BUILD_FIELD_CATALOG
    *&      Form  DISPLAY_ALV
          text
         -->P_IT_FINAL  text
    FORM display_alv  USING    fp_it_final TYPE ty_t_final.
      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            = c_top_of_page
       i_callback_html_top_of_page       = c_top_of_page_split
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
         it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         i_save                            = 'A'
      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                          = fp_it_final
    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_ALV
    *&      Form  top_of_page
          Top of the page for ALV
    FORM top_of_page.                                           "#EC CALLED
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_alv_top_of_page
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM. "top_of_page
    *&      Form  top_of_page_split
          text
    FORM top_of_page_split USING r_top TYPE REF TO cl_dd_document."#EC *
      TYPES: BEGIN  OF ty_text,
             text   TYPE sdydo_text_element,
             END    OF ty_text.
      TYPES: BEGIN  OF ty_text1,                        "AAAAAAAA
             text1  TYPE sdydo_text_element,
             END    OF ty_text1.
      DATA: s_tab          TYPE sdydo_text_table,
            c_area         TYPE REF TO cl_dd_area,
            text           TYPE sdydo_text_element,
            c_area1        TYPE REF TO cl_dd_area,             "AAAAAAA
            text1          TYPE sdydo_text_element,
            s_tab1         TYPE sdydo_text_table.
      DATA: it_text        TYPE TABLE OF ty_text,
            wa_text        TYPE ty_text.
      DATA: it_text1       TYPE TABLE OF ty_text1,
            wa_text1       TYPE ty_text1.
      DATA: v_title        TYPE string,
            v_accts_desc   TYPE string,
            v_year         TYPE string,
            v_comp_code    TYPE string,
            v_desc         TYPE char40,
            v_budat        TYPE char10,
            v_budat1       TYPE char10,
            v_butxt        TYPE butxt,
            v_time         TYPE char10,
            v_comma        TYPE c VALUE ','.
      CALL METHOD r_top->initialize_document.
      CALL METHOD r_top->vertical_split
        EXPORTING
          split_area  = r_top
          split_width = '31%'
        IMPORTING
          right_area  = c_area.
      IF sy-subrc EQ 0.
    *MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *G/L Account Description
      READ TABLE it_skat INTO wa_skat WITH KEY ktopl = v_ktopl.
      IF sy-subrc EQ 0.
        v_desc = wa_skat-text.
      ENDIF.
    *Company code Description
      IF NOT p_bukrs IS INITIAL.
        SELECT SINGLE butxt FROM t001
        INTO v_butxt WHERE bukrs EQ p_bukrs.
      ENDIF.
      CONCATENATE text-005 p_bukrs INTO v_title SEPARATED BY space.
      wa_text1-text1 = v_title.
      APPEND wa_text1 TO it_text1.
      s_tab1 = it_text1.
      CALL METHOD c_area->add_text
        EXPORTING
          text_table   = s_tab1
          fix_lines    = 'X'
          sap_fontsize = cl_dd_document=>large
          sap_emphasis = cl_dd_document=>strong.                           "AAAAAA
      CONCATENATE text-006 p_racct v_comma text-007 v_desc INTO v_accts_desc SEPARATED BY space.
      CONCATENATE s_budat-low4(2) s_budat-low6(2) s_budat-low+0(4) INTO v_budat SEPARATED BY c_slash.
      CONCATENATE text-008 p_gjahr v_comma text-009 v_budat INTO v_year SEPARATED BY space.
      CONCATENATE text-010 v_butxt INTO v_comp_code SEPARATED BY space.
    wa_text-text = v_title.
    APPEND wa_text TO it_text.
      wa_text-text = v_accts_desc.
      APPEND wa_text TO it_text.
      wa_text-text = v_year.
      APPEND wa_text TO it_text.
      wa_text-text = v_comp_code.
      APPEND wa_text TO it_text.
      s_tab = it_text.
      CALL METHOD c_area->add_text
        EXPORTING
          text_table   = s_tab
          fix_lines    = 'X'
          sap_fontsize = cl_dd_document=>medium
          sap_emphasis = cl_dd_document=>medium.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->add_gap
        EXPORTING
          width = 0.
      CONCATENATE sy-datum4(2) sy-datum6(2) sy-datum+0(4) INTO v_budat1 SEPARATED BY c_slash.
      CALL METHOD r_top->add_text
        EXPORTING
          text         = text-011
          sap_emphasis = 'STRONG'.
      CALL METHOD r_top->add_gap
        EXPORTING
          width = 1.
      text = v_budat1.
      CALL METHOD r_top->add_text
        EXPORTING
          text = text.
         sap_style = 'KEY'.
      CALL METHOD r_top->new_line.
      CALL METHOD r_top->add_text
        EXPORTING
          text         = text-012
          sap_emphasis = 'STRONG'.
      CALL METHOD r_top->add_gap
        EXPORTING
          width = 1.
      CONCATENATE  sy-uzeit(2)
                   sy-uzeit+2(2)
                   sy-uzeit+4(2) INTO v_time SEPARATED BY c_colon.   "current time
      text = v_time.
      CALL METHOD r_top->add_text
        EXPORTING
          text = text.
         sap_style = 'KEY'.
    ENDFORM.                    "top_of_page_split
    Thanks & Regards,
    Ramana

    Hi,
    try to declare alv layout and in that
    FORM t_layout  USING    i_layout TYPE slis_layout_alv.
    i_layout-colwidth_optimize = 'X'.
      i_layout-zebra  = 'X'.
    p_i_layout-totals_text = 'GRAND TOTAL ='.
    p_i_layout-subtotals_text = 'Sub Total'.
    p_i_layout-DEF_STATUS  = ' '.
    p_i_layout-info_fieldname = 'LINE_COLOR'.
    ENDFORM.                    " T_LAYOUT
    hope this helps you.
    Thanks & Regards,
    Y.R.Prem Kumar

  • ALV Grid  Subtotal text and Total text display

    Hello ABAPGuru's
    I want to display the subtotal and Total texts. alv grid program runing on background.
    Regards
    Sweety(Sri)

    Hello Neil,
    Here I have attached my routines.anyway my confusion. I have wrote the routine subtotal_text .but i am not passing ALV GRID FM.
    *&      Form  eventtab_build
    &----       This is used to get the list of events
    ----      <--RI_EVENTS  Internal table
    FORM eventtab_build  CHANGING ri_events TYPE slis_t_event.
    Structure for event handling.
      DATA: rs_event TYPE slis_alv_event.
    Returns table of possible events for a list type.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = ri_events.  " Table of events to perform
    Read the internal table with the TOP_OF_PAGE and move the
    form name to the internal table
      READ TABLE ri_events
        WITH KEY name = slis_ev_top_of_page INTO rs_event.
      IF sy-subrc = 0.
        MOVE c_formname TO rs_event-form.              " Form name
        MODIFY ri_events FROM rs_event
           INDEX sy-tabix.                  " Top of page event
      ENDIF.
      READ TABLE ri_events
         WITH KEY name = slis_ev_end_of_page INTO rs_event.
      IF sy-subrc = 0.
        MOVE c_form_eop_name TO rs_event-form.              " Form name
        MODIFY ri_events FROM rs_event
           INDEX sy-tabix.                  " Top of page event
      ENDIF.
      READ TABLE ri_events
          WITH KEY name = slis_ev_subtotal_text INTO rs_event.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO rs_event-form.     " Formname
        MODIFY ri_events FROM rs_event
           INDEX sy-tabix.                  " Top of page event
      ENDIF.
    *&-- Delete all unneeded events:
    DELETE ri_events  WHERE form IS INITIAL.
    ENDFORM.                    " eventtab_build
    *&      Form  SUBTOTAL_TEXT
          text
    -->  p1        text
    <--  p2        text
    FORM SUBTOTAL_TEXT USING  ep_subtot_line     TYPE  type_data
                              e_event_data       TYPE  slis_subtot_text.
      IF NOT e_event_data-criteria IS INITIAL.
      E_EVENT_DATA-DISPLAY_TEXT_FOR_SUBTOTAL = 'Account Total'.
       ENDIF.
    ENDFORM.                    "SUBTOTAL_TEXT
    *&      Form  initialise_layout
          Initialise Layout
    FORM initialise_layout .
      i_layout-colwidth_optimize = c_x.
      i_layout-group_change_edit = c_x.
    *i_layout-subtotals_text = ' a'.
      i_layout-detail_popup   = c_x.
    i_layout-zebra          = c_x.
      i_layout-no_vline       = 'X'.
      i_layout-no_hline       = 'X'.
      i_layout-totals_text = 'Account Total'.
    ENDFORM.                    " initialise_layout
    Call the function module to display the report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = v_program
          i_callback_top_of_page = 'TOP_OF_PAGE'       "Top Of Page
          is_layout              = i_layout
          it_fieldcat            = i_fieldtab
          it_sort                = i_sort
          it_events              = i_events         " Events
          is_print               = i_print
          i_default              = c_x
          i_save                 = c_save
          is_variant             = v_variant
        TABLES
          t_outtab               = i_data
        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.
    Regards
    Sweety (Sri)

  • Sub Total Text in an ALV using FACTORY Method

    Hi Gurus,
    My requirement is simple, but I couldn't find any answers under SDN or any other forums. Some of you may ask me to check for the SCN posts, but I almost checked everything.
    My requirement is - When I get the Sub-total in my ALV, it should print a text other than the field which has got sub-total value.
    My ALV Schema:
    Field1  |  Field2 |  Field 3 |
    ____   |______ |______ |
               |             |             |
               |             |             |
              Tot. Qty  | 1000.00|
    I have sorted and added the subtotal = 'X' for the field which I need the Subtotal. Added Aggregations to Field3. But where and how to the field 'Tot. Qty', so that it should appear at the Sub-Total Level.
    Please guide me if I've missed any of the forums. Again my requirement is to print the Field Name.
    Regards,
    -Wahid Hussain Syed.

    Hi,
    You can view this thread for example Display constant text in intermediate results column of SALV as it says that this is a limitation in SALV that "The output of totals and subtotals is handled solely by ALV. You can neither pass the results to your application nor manipulate them in any way.". But you can see a work around done for this problem, to be frank that I have not done that and I am only providing this link for your reference.

  • Regarding totals  and sub totals text in alv

    Hi all,
    i am displaying Totals and subtotals ......but i want to display the text before the the Totals and Subtotals.
    Please help me in regarding this..
    Thanks in advance,
    S.Gangi reddy.

    hi,
    check this report.
    *& Report  ZGM_ALV_SUBTOTAL_TEXT                                       *
    *& Author :
    *& Date :
    *& Description :
    *& Modification History
    REPORT  ZGM_ALV_SUBTOTAL_TEXT                   .
    *& 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:
      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_textSelection screen:
    \[removed by moderator\]
    Edited by: Jan Stallkamp on Sep 3, 2008 6:17 PM

  • 'TOTAL' text display in ALV GRID output

    Hi,
      My requirement is to display 'TOTAL' text at the end of the ALV report alongwith Totals for the respective columns.
      I've used Classical method(i.e. used ALV GRID FM) to display the report.
      For Totals I've used 'DO_SUM', option and for text populated 'TOTALS_TEXT' field, but still its not showing the desired text.
      I've tried most of the solutions provided on SDN, and they are not working.
      So, plssss help me to find out correct solution.
      Thanks in Advance!!!!!!
    Thanks & regards,
    Amit

    hi,
    i hope this code will exactli fulfil ur requirement.
    type-poolS: slis.
    TYPES: BEGIN OF S_TAB,
           F1 TYPE CHAR5,
           F2 TYPE I,
           F3 TYPE I,
           END OF S_TAB.
    TYPES: BEGIN OF sf_TAB,
           f0 type char10,
           F1 TYPE CHAR5,
           F2 TYPE I,
           F3 TYPE I,
           END OF Sf_TAB.
    DATA: IT_TAB TYPE TABLE OF S_TAB,
          WA_TAB TYPE S_TAB,
          IT_FIN TYPE TABLE OF Sf_TAB,
          WA_FIN TYPE Sf_TAB.
    data: fcat type slis_t_fieldcat_alv,
          wa_fcat type slis_fieldcat_alv,
          layout  type slis_layout_alv,
          it_sort type SLIS_T_SORTINFO_ALV,
          wa_sort type SLIS_SORTINFO_ALV.
    FREE IT_TAB. CLEAR WA_TAB.
    WA_TAB-F1 = 'A1'.
    WA_TAB-F2 = '10'.
    WA_TAB-F3 = '20'.
    APPEND WA_TAB TO IT_TAB.
    CLEAR WA_TAB.
    WA_TAB-F1 = 'A1'.
    WA_TAB-F2 = '10'.
    WA_TAB-F3 = '20'.
    APPEND WA_TAB TO IT_TAB.
    CLEAR WA_TAB.
    WA_TAB-F1 = 'A2'.
    WA_TAB-F2 = '15'.
    WA_TAB-F3 = '30'.
    APPEND WA_TAB TO IT_TAB.
    CLEAR WA_TAB.
    WA_TAB-F1 = 'A3'.
    WA_TAB-F2 = '15'.
    WA_TAB-F3 = '40'.
    APPEND WA_TAB TO IT_TAB.
    CLEAR WA_TAB.
    WA_TAB-F1 = 'A3'.
    WA_TAB-F2 = '20'.
    WA_TAB-F3 = '60'.
    APPEND WA_TAB TO IT_TAB.
    CLEAR WA_TAB.
    LOOP AT IT_TAB INTO WA_TAB.
    wa_fin-f0 = 'Total'.
    wa_fin-f1 = wa_tab-f1.
    wa_fin-f2 = wa_tab-f2.
    wa_fin-f3 = wa_tab-f3.
    append wa_fin to it_fin.
    clear wa_fin.
    ENDLOOP.
    Define Imacro.
    wa_fcat-fieldname      = &1.
    wa_fcat-tabname        = &2.
    wa_fcat-reptext_ddic  = &3.
    wa_fcat-col_pos       = &4.
    WA_FCAT-DO_SUM      = &5.
    WA_FCAT-NO_OUT = &6.
    append wa_fcat to fcat .
    clear wa_fcat.
    end-of-definition.
    imacro 'F0'   'it_fin' ''   '1' ''  'X'.
    imacro 'F1'   'it_fin' 'PO Document'   '2' ''  ''.
    imacro 'F2'   'it_fin' 'TOTAL'    '3' 'X'  ''.
    imacro 'F3'   'it_fin' 'Space'     '4' '' ''.
    ****************DEFINE LAYOUT
    layout-zebra             = 'X'.
    layout-colwidth_optimize = 'X'.
    layout-no_totAlLine = 'X'.
    WA_SORT-SPOS = 1.
    WA_SORT-fieldname = 'F0'.
    wa_SORT-UP = 'X'.
    WA_SORT-SUBTOT = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = SY-REPID
       I_GRID_TITLE                      = 'SALES ORDER DETAILS'
       IS_LAYOUT                         = layout
       IT_FIELDCAT                       = fcat
       IT_SORT                           = IT_SORT
       TABLES
       T_OUTTAB                          = IT_FIN
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Cheers,
    Rudhir

  • Remove sub total text in ALV.

    Hello,
    How can I remove the text in sub total in ALV? I want to show only sub total values, not any explanation.
    Thanks.

    In my code;
    FIELDCATALOG-FIELDNAME   = 'SYSTEM_UNIQ_NO'.
    FIELDCATALOG-SELTEXT_L   = 'No'.
    FIELDCATALOG-DDICTXT     = 'L'.
    APPEND FIELDCATALOG TO FIELDCATALOG.
    FIELDCATALOG-FIELDNAME   = 'QUANTITY'.
    FIELDCATALOG-SELTEXT_L   = 'Quantity'.
    FIELDCATALOG-DDICTXT     = 'L'.
    FIELDCATALOG-do_sum       = 'X'.
    FIELDCATALOG-QFIELDNAME  = 'QUNIT'.
    APPEND FIELDCATALOG TO FIELDCATALOG.
    it_sort-spos      = 1.
    it_sort-fieldname = 'SYSTEM_UNIQ_NO'.
    it_sort-SUBTOT    = 'X'.
    it_sort-UP        = 'X'.
    GD_LAYOUT-NO_INPUT          = 'X'.
    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    GD_LAYOUT-no_totalline      = 'X'.
    GD_LAYOUT-subtotals_text    = SPACE.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM      = GD_REPID
                  I_CALLBACK_USER_COMMAND = 'USER_COMMAND' 
                  IS_LAYOUT               = GD_LAYOUT
                  IT_FIELDCAT             = FIELDCATALOG[]
                  I_SAVE                  = 'X'
                  IT_SORT                 = IT_SORT[]
             TABLES
                  T_OUTTAB                = ITAB
             EXCEPTIONS
                  PROGRAM_ERROR           = 1
                  OTHERS                  = 2.
    But, I am seeing the System Uniq No before sub totals. Also, I have assigned 'Test' to GD_LAYOUT-subtotals_text. But, I can not see 'Test' anywhere.

  • Am getting SUB TOTALS. But, I do NOT wanna show up the GRAND TOTALS in ALV

    Hi Experts,
    Am getting Sub Totals(line in dim yellow color) for my_alv report.........fine.
    But, for some reason, I do NOT wanna to show up the GRAND TOTALS(line in dark yellow color) for my_alv!!
    So, pls. let me know, How to get it done?
    thanq

    hi Srinivas,
    is_layout-no_totalline = 'X'.
    hope this helps
    ec

  • Alv - sub  totals and avg

    Hi gurus,
    I have a problem, please help me out.
    Iam doing an report program with alv display. In that iam calculating the AVG for the workcenter wise for the field TAT.
    please observe my below o/p in general ALv  format.
    work center-- TAT- Tat(Yes/no)
    qm0010------ 1 --  yes
    qm0010-------2 --  yes
    qm0010------ 4 -- yes
    qm0010------ 7 -- No (because >5)
    Subtotal(qm0010)--3  (avg caluculated)
    qm0020--  4 --- yes
    qm0020-7-- No (because >5)
    qm0020--10 - No (because >5)
    qm002010- No (because >5)
    Subtotal(qm0020)-- 7 (avg caluculated).
    this is the rough o/p iam getting . this is acheived by programming the Field catalog for TAT field i.e... do_sum  = 'C'.
    then giving the sort table to REUSE_ALV_GRID_DISPLAY.
    Now my problem is:
    I want the avg to be calcuted by the business formula which is:
    avg  =  sum of(TAT within 5 days) / total no of the entries .
    Ex:
    work center-- TAT- Tat(Yes/no)
    qm0010------ 1 --  yes
    qm0010-------2 --  yes
    qm0010------ 4 -- yes
    qm0010------ 7 -- No (because >5)
    Subtotal(qm0010)---*7/4=2 (avg caluculated for tat<5)*
    qm0020--  4 --- yes
    qm0020-7-- No (because >5)
    qm0020--10 - No (because >5)
    qm002010- No (because >5)
    Subtotal(qm0020)--4/4=1 (avg caluculated for tat<5).
    How can i acheive the above, since in field catalog and alv, i think we cannot pass any conditions(like for TAT which is less than 5). So is there any other way to acheive the above.
    Please understand the problem and give me(please directly dont suggest any programs , since iam not a expert to understand)..
    Please explain me in detail.  Points will be duly rewarded.
    Thanks in advance........Chaitu
    Edited by: chaitanya on May 30, 2008 12:33 PM
    Edited by: chaitanya on May 30, 2008 12:38 PM
    Edited by: chaitanya on May 30, 2008 12:39 PM

    Hi Chaitanya,
       You can display in your report with totals and sub-totals using alv, but not average. That functionality has not provided by sap. Do one thing add one more extra column Average in your output, do the calculation for average and pass the value in the coding itself. Then last display your report with Average field.
    Rgds,
    Bujji

  • Reg. ALV- Sub total?

    Hi Experts,
    How to hide the column values in ALV? That is I need to display the sub-total values alone and not to show the other values in the ALV output. Take for e.g
    1   2   2  andre
    2   3   4  brown
    3   5   6  subtotal
    2   2    3  A
    1   1    1  B
    1   1     1  C
    1   1     2  D
    5   5   7   subtotal
    If the alv output is like this means, I want to display the 3, 5, 6 fields alone how to hide the first column colum field values alone i.e 1 & 2. Then in second part of the ALV how to hide the first column values 2,1,1 & 1 alone.
    Regards,
    Sakthi

    Hi Tarun,
    Thanks for your reply.
    If I give that no_out = 'X' in the sense it will hide the whole column.
    I need How to hide the values alone and need to display the column subtotal.
    Those values need to be displayed as blank in the output.
    How to do that?
    The output normally will be like this.
    1 1 1 A
    1 2 3 B
    1 1 1 C
    3 4 5 subtotal
    1 2 3 E
    1 1 1 F
    2 3 4 SubTotal
    But what I need  is
        1 1 A
        2 3 B
        1 1 C
    3   4 5 SubTotal
      2 3 E
      1 1 F
    2 3 4 Sub Total
    Like this I need to hide a single column values alone not along with sub total values. The first column values should not appear but subtotal value should appear.

Maybe you are looking for

  • Media Encoder CS6 Not Exporting all Audio Tracks From Premiere

    I'm working with DSLR footage, 2 Channels of .WAV audio from an exernal recorder (H4N), and a 1 channel .WAV Music track. 3 Channels total of .Wav audio. I can export from Premiere Pro CS6 to H.264 just fine, but if I try to send it to Media Encoder,

  • Dynamic table data not transfered to context WD4ABAP

    Hello Guys, Currently I have a urgent problem with Adobe Forms and WD4Abap. We are using AdobeReader 8.1.1 und Designer 7.1. Me problem is: 1) I have an interactive form with dynamic table and simple fields... 2) Data within textfields can be updated

  • Problem in compiling pro * c program

    Hi Greetings , I am new to proc, i wrote a small sample program while compiling this program in vc++ 6.0 i am getting the following error c:\proheaderfiles\database.c(24) : error C2061: syntax error : identifier 'SQL' c:\proheaderfiles\database.c(24)

  • How to access host files?

    how to access host files?

  • Is there a retirement date for the CS6 certification exams?

    Is there a retirement date for the Adobe Photoshop CS6, Indesign CS6 & Illustrator CS6 exams? If so, when will Adobe retire these exams?(Not the recertification exams. I don't have any previous certification with Adobe.)