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.

Similar Messages

  • 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

  • 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

  • How to change sub total value in ALV Grid.

    Hi All,
    Can u please explain how to change SUBTOTAL Value in ALV Grid display based on another field value.
    EX; F1 subtotal is  initial then we have to modify the F2 sub total to 9999.9.
    Thanks
    Radha.

    Hi Radha,
    I doubt if that can be changed....because the event that i was referring to in my previous post works with ALV List display...But in any case you can try that.....
    There is an event in SLIS....(As i told you, i dont remember the name and currently i dont have access to SAP system, so i am not able to verify and let you know that event name).....
    Other thatn TOP and END of PAGE events, there is an event for sub-total text......i think it would start with "SUBTOTAL"...
    you need to use that event in your events table and pass it to ALV Grid display.
    Then create a sub-routine with that name (As you do for TOP-OF-PAGE event)....and in this event you can change the values in runtime (PROVIDED, this event gets triggered for ALV GRID).....
    If this does not work, i think calculating sub-totals while you build the internal table would be a better option....(If you have time constraint....else you can do some more research on the same)........
    Best Regards,
    Ram.

  • Hi, coding to display popup window after first alv grid display

    hi
    can anybody please send coding to display popup window after first alv grid display i.e.  first the prog shows grid display and from grid display the user select the field and on the basis of field value i need to show pop up window in the first secondary window and then third popup window.
    thanx
    rocky

    Hi rocky,
    here is the sample code .hope this helps you.
    TYPE-POOLS : SLIS.
    DATA : GT_OUTTAB TYPE VBAK OCCURS 0,
           GS_PRIVATE TYPE SLIS_DATA_CALLER_EXIT,
           GS_SELFIELD TYPE SLIS_SELFIELD.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA : ITAB TYPE TABLE OF SLIS_SELFIELD,
           WA_ITAB LIKE LINE OF ITAB.
    START-OF-SELECTION.
    PERFORM POPULATE_GT_OUTTAB.
    PERFORM GET_POPUP.
    PERFORM POPULATE_ITAB.
    PERFORM FIELDCAT.
    PERFORM DISPLAY_DETAILS.
    *&      Form  FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
    LOOP AT ITAB INTO WA_ITAB.
    WA_FIELDCAT-FIELDNAME = 'TABINDEX'.
    WA_FIELDCAT-TABNAME = 'WA_ITAB'.
    WA_FIELDCAT-COL_POS = 1.
    WA_FIELDCAT-SELTEXT_L = 'TABLE INDEX'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    WA_FIELDCAT-FIELDNAME = 'SEL_TAB_FIELD'.
    WA_FIELDCAT-TABNAME = 'WA_ITAB'.
    WA_FIELDCAT-COL_POS = 2.
    WA_FIELDCAT-OUTPUTLEN = 20.
    WA_FIELDCAT-SELTEXT_L = 'FIELD NAME'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    WA_FIELDCAT-FIELDNAME = 'VALUE'.
    WA_FIELDCAT-TABNAME = 'WA_ITAB'.
    WA_FIELDCAT-COL_POS = 3.
    WA_FIELDCAT-SELTEXT_L = 'FIELD VALUE'.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    ENDLOOP.
    ENDFORM.                    " FIELDCAT
    *&      Form  POPULATE_GT_OUTTAB
          text
    -->  p1        text
    <--  p2        text
    FORM POPULATE_GT_OUTTAB .
    SELECT * FROM VBAK
           UP TO 10 ROWS
           INTO TABLE GT_OUTTAB.
    ENDFORM.                    " POPULATE_GT_OUTTAB
    *&      Form  GET_POPUP
          text
    -->  p1        text
    <--  p2        text
    FORM GET_POPUP .
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
      EXPORTING
       I_TITLE                       = 'SALES ORDER'
      I_SELECTION                   = 'X'
      I_ALLOW_NO_SELECTION          =
       I_ZEBRA                       = 'X'
      I_SCREEN_START_COLUMN         = 0
      I_SCREEN_START_LINE           = 0
      I_SCREEN_END_COLUMN           = 0
      I_SCREEN_END_LINE             = 0
      I_CHECKBOX_FIELDNAME          =
      I_LINEMARK_FIELDNAME          =
      I_SCROLL_TO_SEL_LINE          = 'X'
        I_TABNAME                     = 'SALES ORDER'
        I_STRUCTURE_NAME              = 'VBAK'
      IT_FIELDCAT                   =
      IT_EXCLUDING                  =
      I_CALLBACK_PROGRAM            =
      I_CALLBACK_USER_COMMAND       =
       IS_PRIVATE                    = GS_PRIVATE
    IMPORTING
       ES_SELFIELD                   = GS_SELFIELD
      E_EXIT                        = G_EXIT
      TABLES
        T_OUTTAB                      = GT_OUTTAB
    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.                    " GET_POPUP
    *&      Form  POPULATE_ITAB
          text
    -->  p1        text
    <--  p2        text
    FORM POPULATE_ITAB .
    WA_ITAB-TABNAME = GS_SELFIELD-TABNAME.
    WA_ITAB-TABINDEX = GS_SELFIELD-TABINDEX.
    WA_ITAB-SEL_TAB_FIELD = GS_SELFIELD-SEL_TAB_FIELD.
    WA_ITAB-VALUE = GS_SELFIELD-VALUE.
    APPEND WA_ITAB TO ITAB.
    ENDFORM.                    " POPULATE_ITAB
    *&      Form  DISPLAY_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_DETAILS .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
      I_CALLBACK_PROGRAM             = ' '
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
       IT_FIELDCAT                    = IT_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_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
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        T_OUTTAB                       = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                  = 1
       OTHERS                         = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " DISPLAY_DETAILS
    award points if helpful.
    regards,
    deepthi reddy

  • Problem displaying 'Total' text in ALV grid

    My ALV works and displays correct output. However, I am struggling to display the text 'Total' on position in the last row of the grid. The total is for the salary. My code is below..
    I have looked on numerous sites and forums for assistance.
    *& Report  ZALV
    REPORT  ZALV.
    TABLES: ZCONTACT.
    TYPE-POOLS: slis. "slis contains all of the ALV data types.
    DATA: "fieldcatALOG TYPE slis_t_fieldcat_alv WITH HEADER LINE,
           it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
           alv_prog_name LIKE sy-repid,
           g_variant TYPE disvariant,
           gx_variant TYPE disvariant,
           g_save TYPE c VALUE 'X',
           it_fieldcat TYPE slis_t_fieldcat_alv,"declares field catalog table of line type alv
           wa_fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
           it_list_top_of_page TYPE slis_t_listheader,
           izontact TYPE TABLE OF zcontact,
           h1(10) TYPE c VALUE 'Toatall',
            "i_logo TYPE OT.
           gt_events     TYPE slis_t_event,
           gd_prntparams TYPE slis_print_alv,
           text(40) type c,
           wa_layout TYPE slis_layout_alv.
    **Selection Screen details
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    PARAMETERS: variant like disvariant-variant.
    SELECTION-SCREEN END OF BLOCK B1.
    **Getting default variant
    INITIALIZATION.
    gx_variant-report = sy-repid.
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
       I_SAVE = G_SAVE
       CHANGING
         CS_VARIANT = GX_VARIANT
       EXCEPTIONS
         NOT_FOUND = 2.
    IF SY-SUBRC = 0.
       VARIANT = GX_VARIANT-VARIANT.
       ENDIF.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM DISPLAY_ALV_REPORT.
      "PERFORM build_alv_header
    FORM BUILD_FIELDCATALOG.
    *Build field catalog
    wa_fieldcat-fieldname = 'ID'.
    wa_fieldcat-seltext_m = 'ID'.
    wa_fieldcat-col_pos   = 0.
    wa_fieldcat-outputlen = 10.
    wa_fieldcat-emphasize  = 'X'.
    wa_fieldcat-key       = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'LASTNAME'.
    wa_fieldcat-seltext_m = 'LASTNAME'.
    wa_fieldcat-col_pos   = 1.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'FIRSTNAME'.
    wa_fieldcat-seltext_m = 'FIRSTNAME'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'DOB'.
    wa_fieldcat-seltext_m = 'DOB'.
    wa_fieldcat-col_pos = 3.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'TEL'.
    wa_fieldcat-seltext_m = 'Tel'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'ADDRESS'.
    wa_fieldcat-seltext_m = 'ADDRESS'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'OCCUPATION'.
    wa_fieldcat-seltext_m = 'OCCUPATION'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'WEIGHT'.
    wa_fieldcat-seltext_m = 'WEIGHT'.
    wa_fieldcat-do_sum    = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'AGE'.
    wa_fieldcat-seltext_m = 'AGE'.
    wa_fieldcat-do_sum   = 'X'.        "Display column total
    APPEND wa_fieldcat TO it_fieldcat.
    "CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'SALARY'.
    wa_fieldcat-seltext_m = 'SALARY'.
    wa_fieldcat-do_sum    = 'X'.
    wa_fieldcat-cfieldname = 'CURRENCYKEY'.
    APPEND wa_fieldcat TO it_fieldcat.
    wa_fieldcat-fieldname = 'CURRENCY'.
    wa_fieldcat-seltext_s = 'CURRENCY'.
    APPEND wa_fieldcat TO it_fieldcat.
    "CLEAR wa_fieldcat.
    ENDFORM. "BUILDING THE FIELD CATALOG
    **FORM layout.
    *wa_layout-colwidth_optimize = 'X'.
    *wa_layout-totals_text ='TOTAL'.
    *wa_layout-zebra = 'X'.
    *ENDFORM.
    "ls_layout-cell_merge = 'X'.
    FORM DISPLAY_ALV_REPORT.
    alv_prog_name = sy-repid.
    *Pass data and field catalog to ALV function module to display ALV list
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           it_fieldcat            = it_fieldcat[]
           i_callback_program     = alv_prog_name
           is_layout              = wa_layout
           i_callback_top_of_page =  'TOP_OF_PAGE'
           i_callback_user_command =  'USER_COMMAND'
           i_structure_name       =  'ZCONTACT'
           i_save                 = 'X'
           it_events               = gt_events
           is_print                = gd_prntparams
           is_variant             = g_variant
           "is_layout     = ls_layout
    TABLES
           t_outtab      = it_zcontact
    EXCEPTIONS
           program_error = 1
           OTHERS        = 2.
    WRITE: H1 UNDER 'SALARY'.
    ENDFORM.
    **Fetch data from the database
    FORM DATA_RETRIEVAL.
    SELECT * FROM zcontact INTO TABLE it_zcontact.
    ENDFORM.
    FORM top_of_page.
    *ALV Header declarations
       DATA: it_listheader TYPE slis_t_listheader,
             wa_listheader TYPE slis_listheader,
             t_line like wa_listheader-info,
             ld_lines TYPE I,
             ld_linesc(10) TYPE C.
    wa_listheader-typ = 'H'.
    wa_listheader-info = 'Contact Details'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-repid.
    wa_listheader-key = 'Program Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-uname.
    wa_listheader-key = 'User Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Run Date :'.
    CONCATENATE sy-datum+6(2)
                 sy-datum+4(2)
                 sy-datum(4)
                 INTO wa_listheader-info
                 SEPARATED BY '/'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Time :'.
    CONCATENATE sy-uzeit(2)
                 sy-uzeit+2(2)
                 sy-uzeit+4(2)
                 INTO wa_listheader-info
                 SEPARATED BY ':'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
       CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
         EXPORTING
           it_list_commentary = it_listheader[]
           i_logo = 'KLOGO'.
    ENDFORM.                    "top_of_page

    I did this but still i cant display the total text..I have reposted my code. please assist. Im only missing that total label
    *& Report  ZALV
    REPORT  ZALV.
    TABLES: ZCONTACT.
    TYPE-POOLS: slis. "slis contains all of the ALV data types.
    TYPES: BEGIN OF t_zcontact,
         text(40) TYPE c, "storing the total text
       mandt TYPE mandt,
       id TYPE zcontactid,
       lastname type zcontactlname,
       firstname TYPE zcontactfname,
       dob TYPE zdateofbirth,
       tel TYPE ztel,
       address TYPE zaddress,
       occupation TYPE zoccup,
       weight type zweight,
       age TYPE zage,
       salary TYPE zsalary,
       ecurrency TYPE curcy,
       END OF t_zcontact.
    TYPES: BEGIN OF wa_zcontact,
       mandt TYPE mandt,
       id TYPE zcontactid,
       lastname type zcontactlname,
       firstname TYPE zcontactfname,
       dob TYPE zdateofbirth,
       tel TYPE ztel,
       address TYPE zaddress,
       occupation TYPE zoccup,
       weight type zweight,
       age TYPE zage,
       salary TYPE zsalary,
       ecurrency TYPE curcy,
       END OF wa_zcontact.
    TYPES:
    i_zcontact TYPE STANDARD TABLE OF t_zcontact." INITIAL SIZE 0.
       DATA: itt_zcontact TYPE STANDARD TABLE OF wa_zcontact INITIAL SIZE 0,
             wat_zcontact TYPE wa_zcontact.
    DATA: "it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
           gd_repid LIKE sy-repid,
           g_variant TYPE disvariant,
           gx_variant TYPE disvariant,
           g_save TYPE c VALUE 'X',
           fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,"declares field catalog table of line type alv
            gd_tab_group type slis_t_sp_group_alv,
            gd_prntparams TYPE slis_print_alv,
           fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
           it_list_top_of_page TYPE slis_t_listheader,
           i_zcontact TYPE TABLE OF zcontact,
           "h1(10) TYPE c VALUE 'Toatall',
            "i_logo TYPE OT.
           gt_events TYPE slis_t_event,
           gd_layout TYPE slis_layout_alv."work area for the alv layout
    data: it_sortcat type slis_sortinfo_alv occurs 1,
             wa_sort LIKE LINE OF it_sortcat.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM DISPLAY_ALV_REPORT.
      PERFORM BUILD_LAYOUT.
      perform build_sortcat.
      PERFORM sub_add_text.
      "PERFORM build_events.
      PERFORM top-of-page.
      "PERFORM build_alv_header.
      END-OF-SELECTION.
    *DATA: gd_layout TYPE slis_layout_alv.
    *      gd_layout-totals_text = 'TOTAL'.
    **Selection Screen details
    *SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    *PARAMETERS: variant like disvariant-variant.
    *SELECTION-SCREEN END OF BLOCK B1.
    ***Getting default variant
    *INITIALIZATION.
    *gx_variant-report = sy-repid.
    *CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    *EXPORTING
    *  I_SAVE = G_SAVE
    *  CHANGING
    *    CS_VARIANT = GX_VARIANT
    *  EXCEPTIONS
    *    NOT_FOUND = 2.
    *IF SY-SUBRC = 0.
    *  VARIANT = GX_VARIANT-VARIANT.
    *  ENDIF.
    FORM BUILD_FIELDCATALOG.
    *Build field catalog
    fieldcatalog-fieldname = 'ID'.
    fieldcatalog-seltext_m = 'ID'.
    fieldcatalog-col_pos   = 2.
    fieldcatalog-outputlen = 10.
    fieldcatalog-datatype = 'CHAR'.
      "fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
    fieldcatalog-emphasize  = 'X'.
    fieldcatalog-key       = 'X'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'LASTNAME'.
    fieldcatalog-seltext_m = 'LASTNAME'.
    fieldcatalog-col_pos   = 3.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'FIRSTNAME'.
    fieldcatalog-seltext_m = 'FIRSTNAME'.
      fieldcatalog-col_pos = 4.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'DOB'.
    fieldcatalog-seltext_m = 'DOB'.
    fieldcatalog-col_pos = 5.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'TEL'.
    fieldcatalog-seltext_m = 'Tel'.
      fieldcatalog-col_pos = 6.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'ADDRESS'.
    fieldcatalog-seltext_m = 'ADDRESS'.
      fieldcatalog-col_pos = 7.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'OCCUPATION'.
    fieldcatalog-seltext_m = 'OCCUPATION'.
      fieldcatalog-col_pos = 8.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'WEIGHT'.
    fieldcatalog-seltext_m = 'WEIGHT'.
    "fieldcatalog-do_sum    = 'X'.
      fieldcatalog-col_pos = 9.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'AGE'.
    fieldcatalog-seltext_m = 'AGE'.
    "fieldcatalog-do_sum   = 'X'.        "Display column total
      fieldcatalog-col_pos = 10.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'SALARY'.
    fieldcatalog-seltext_m = 'SALARY'.
    fieldcatalog-do_sum    = 'X'.
    fieldcatalog-outputlen = 15.
    fieldcatalog-datatype ='CURR'.
      fieldcatalog-col_pos = 11.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    "fieldcatalog-fieldname = 'ECURRENCY'.
    "fieldcatalog-seltext_s = 'ECURRENCY'.
    "APPEND fieldcatalog TO fieldcatalog.
    "CLEAR fieldcatalog.
       fieldcatalog-fieldname   = 'TEXT'.
       fieldcatalog-col_pos = 0.
       "fieldcatalog-seltext_m   = 'TEXT'.
       fieldcatalog-tech        = 'X'.
       fieldcatalog-no_out      = 'X'.
       append fieldcatalog to fieldcatalog.
       clear  fieldcatalog.
    ENDFORM.
    *&      Form  build_sortcat
    *       Build Sort catalog
    FORM build_sortcat .
       "wa_sort-spos      = 1.
       wa_sort-fieldname = 'TEXT'.
       "wa_sort-SUBTOT    = 'X'. "subtotals any totals column by this field
       wa_sort-up        = 'X'.
       APPEND wa_sort TO it_sortcat.
       CLEAR wa_sort.
    ENDFORM.                    " build_sortcat
    FORM BUILD_LAYOUT.
    *gd_layout-no_input = 'X'.
    *gd_layout-colwidth_optimize = 'X'.
    *gd_layout-totals_text  =  'Totals'(201).
    *"gd_LAYOUT-coltab_fieldname = 'SALARY'.
    gd_layout-no_totalline = 'X'.
    ENDFORM.
    *IF sy-subrc = 0.
    *      LOOP AT fieldcatalog INTO fieldcat.
    *        IF fieldcat-fieldname = 'WEIGHT' OR
    *          fieldcat-fieldname = 'AGE'.
    **         Summation for WEIGHT & AGE
    *          fieldcat-do_sum = 'X'.
    *          MODIFY fieldcatalog FROM fieldcat TRANSPORTING do_sum.
    *        ENDIF.
    *        IF fieldcat-fieldname = 'TEXT'.
    **         Hide this field so that it can display it's content i.e.
    **         Total text in Subtotal level
    *          fieldcat-tech = 'X'.
    *          fieldcat-no_out = 'X'.
    *          MODIFY fieldcatalog FROM fieldcat TRANSPORTING tech no_out.
    *        ENDIF.
    *        CLEAR fieldcat.
    *      ENDLOOP.
    *    ENDIF.
    *ENDFORM. "BUILDING THE FIELD CATALOG
    *form build_events.
    *  data: ls_event type slis_alv_event.
    *  call function 'REUSE_ALV_EVENTS_GET'
    *       exporting
    *            i_list_type = 0
    *       importing
    *            et_events   = gt_events[].
    *  read table gt_events with key name =  slis_ev_top_of_page
    *                           into ls_event.
    *  if sy-subrc = 0.
    *    move 'TOP-OF-PAGE' to ls_event-form.
    *    append ls_event to gt_events.
    *  endif.
    *    read table gt_events with key name =  slis_ev_end_of_list
    *                           into ls_event.
    *  if sy-subrc = 0.
    *    move 'END_OF_LIST' to ls_event-form.
    *    append ls_event to gt_events.
    *  endif.
    *endform.                    " BUILD_EVENTS
    "ls_layout-cell_merge = 'X'.
    FORM DISPLAY_ALV_REPORT.
    gd_repid = sy-repid.
    *Pass data and field catalog to ALV function module to display ALV list
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           it_fieldcat         = fieldcatalog[]
           it_sort  =  it_sortcat
           i_callback_program     = gd_repid
           is_layout              = gd_layout
           i_callback_top_of_page =  'TOP-OF-PAGE'
           i_callback_user_command =  'USER_COMMAND'
           i_structure_name       =  'ZCONTACT'
           i_save                 = 'X'
           it_events               = gt_events
           is_print                = gd_prntparams
           is_variant             = g_variant
           "is_layout     = ls_layout
    TABLES
           t_outtab      = itt_zcontact
    EXCEPTIONS
           program_error = 1
           OTHERS        = 2.
    "WRITE: 'TOTAL' UNDER 'ID'.
    ENDFORM.
    **Fetch data from the database
    FORM DATA_RETRIEVAL.
    "DATA: ld_subtot(1) type c.
    SELECT * FROM zcontact INTO TABLE itt_zcontact UP TO 10 ROWS.
    ENDFORM.
    FORM sub_add_text.
    *Populate field with text value
       DATA:
       wt_zcontact TYPE t_zcontact,
       last TYPE zcontact-ID,
       l_text(40) type c,
       num type n.
    loop at itt_zcontact into wat_zcontact.
    * Populate final table
       wt_zcontact-TEXT = 'Total salary:  '.
       "ld_subtot = ld_subtot + 1.
       "wat_zcontact-text = ld_subtot.
         modify itt_zcontact FROM wat_zcontact.
         clear wat_zcontact.
       "APPEND wat_zcontact TO itt_zcontact.
    endloop.
    ENDFORM.
    FORM top-of-page.
    *ALV Header declarations
       DATA: it_listheader TYPE slis_t_listheader,
             wa_listheader TYPE slis_listheader,
             t_line like wa_listheader-info,
             ld_lines TYPE I,
             ld_linesc(10) TYPE C.
    wa_listheader-typ = 'H'.
    wa_listheader-info = 'Contact Details'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-repid.
    wa_listheader-key = 'Program Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-uname.
    wa_listheader-key = 'User Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Run Date :'.
    CONCATENATE sy-datum+6(2)
                 sy-datum+4(2)
                 sy-datum(4)
                 INTO wa_listheader-info
                 SEPARATED BY '/'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Time :'.
    CONCATENATE sy-uzeit(2)
                 sy-uzeit+2(2)
                 sy-uzeit+4(2)
                 INTO wa_listheader-info
                 SEPARATED BY ':'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
       CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
         EXPORTING
           it_list_commentary = it_listheader[]
           i_logo = 'KLOGO'.
    ENDFORM.                    "top_of_page

  • How to capture the checkbox status in ALV Grid display

    I need some immediate help regarding Grid ALV.
    My Requirement: I need to display an ALV grid report along with checkboxes. Further, I need to provide an option wherein the user can checkboxes and select the records that I need to process further (by clicking the process button on the ALV Report).
    My Query: The problem here is that I am not able to capture the status of the checkboxes. This means that I am not able to capture which of the records have been selected by checking their resp checkboxes.
    Solutions that I have tried: I have tried capturing the same at user command by checking the value in slis_selfield. But all the records show the value as 1 for the checkbox field.
    Kinldy suggest how to go about it.
    I am not using Object Oriented ALV. Please suggest something to be used in ALV Grid display in 4.6C version.
    Regards,
    Namrata

    Here is a Sample code , it might help you
    TABLES : sflight.
    TYPE-POOLS: slis.
    DATA : w_repid LIKE sy-repid.
    w_repid = sy-repid.
    DATA: BEGIN OF it_sflight OCCURS 0,
      checkbox(1),
      carrid LIKE sflight-carrid,
    END OF it_sflight.
    *layout
    DATA: wa_layout TYPE slis_layout_alv.
    *field catalog
    DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
              wa_fieldcatalog TYPE slis_fieldcat_alv.
    START-OF-SELECTION.
      SELECT carrid FROM sflight
         INTO CORRESPONDING FIELDS OF TABLE it_sflight.
    END-OF-SELECTION.
      CLEAR it_fieldcatalog.
      REFRESH it_fieldcatalog.
      wa_fieldcatalog-fieldname = 'CHECKBOX'.
      wa_fieldcatalog-outputlen = '3'.
      wa_fieldcatalog-col_pos = '1'.
      wa_fieldcatalog-seltext_m = 'Chk'.
      wa_fieldcatalog-checkbox = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'CARRID'.
      wa_fieldcatalog-outputlen = '10'.
      wa_fieldcatalog-col_pos = '2'.
      wa_fieldcatalog-seltext_m = 'Carrid'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = w_repid
          is_layout = wa_layout
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat = it_fieldcatalog
        TABLES
          t_outtab = it_sflight
        EXCEPTIONS
          program_error = 1
          OTHERS = 2.
    *& Form USER_COMMAND
    FORM user_command USING p_ucomm TYPE sy-ucomm
      p_selfld TYPE slis_selfield.
      CASE p_ucomm.
       WHEN '&DATA_SAVE'.
          DATA ref1 TYPE REF TO cl_gui_alv_grid.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
             IMPORTING
               e_grid = ref1.
          CALL METHOD ref1->check_changed_data.
          LOOP AT it_sflight WHERE checkbox = 'X'.
             DELETE it_sflight INDEX sy-tabix.
          ENDLOOP.
          p_selfld-refresh = 'X'.
      ENDCASE.
    ENDFORM. "user_command

  • How to give a page break in alv grid display after 65 lines are displayed?

    hi all,
    I need to give a page break in alv grid display after 65 lines are displayed on each page...Please help me with this...

    hai
    give this command beging of the report name... u have to diclar the beging of the report ......
    <b>report</b> ( name of the report)  <b>standard page heading line-size 200 line-count 65.</b>
    ex1.:- report name is  rtpm_trl_show_flows 
    report <b>rtpm_trl_show_flows </b> no standard page heading line-size 200
                                                         line-count 65.
    ex:2
    report  <b>zlpur01</b> no standard page heading line-size 200
                                                         line-count 65.
    type-pools: slis.
    tables: bkpf.
    selection-screen begin of block sel with frame title text-001.
    select-options: s_comp for bkpf-bukrs, " Company
                    s_valut for bkpf-budat. " Invoice Date
                   S_MTART FOR MARA-MTART. " Material Type
    selection-screen end of block sel.
    parameters: p_vari like disvariant-variant. " ALV Variant
    constants: formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.
    data:   i_bseg type bseg  occurs 0 with header line.
    data: vatval type p decimals 2 value '0.15'.
    data: xhkont type string value '154000'.
    data COM type c.
    data: begin of invt occurs 100,
            budat like bkpf-budat, " Inv Dat
            bukrs like bkpf-bukrs, " Material
            STCEG like bsak-STCEG, "name of the companycode
            belnr like bkpf-belnr,
            xblnr like bkpf-xblnr, " Inv Reference
            ebeln like rseg-ebeln, " PO number
            lifnr like bseg-lifnr, " Vendor No
            name1 like lfa1-name1, " Supplier Name
            matnr like bseg-matnr,
            maktx like makt-maktx,
            stcd1 like lfa1-stcd1, " Supplier VAT REG NO
            xamt like bseg-dmbtr, " TAX amt
            yamt like bseg-wrbtr,
            wrbtr like bseg-wrbtr, " Base amount
            mwskz like bseg-mwskz,
            dmbtr like bseg-dmbtr, " TAX amt
            gjahr like bkpf-gjahr,
            hkont like bseg-hkont,
            zamt like bseg-dmbtr, " TAX amt
            wamt like bseg-dmbtr,
            shkzg like bseg-shkzg,
            shkzg1 like bseg-shkzg,
          end of invt.
    regard
    nawa

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

  • 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

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

  • 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

  • Can we display only sub totals on the alv grid output

    hi,
    can we display only the subtotals calculated on the grid display.it should display all the data it shpuld display only the subtotals of it.
    if yes can any one please give me the code for
    will be awarded with points.

    Hi Raju
    You can do that
    When you are doing fieldcatalog,comment ws_fieldcat-do_sum = 'x'.
    if you comment that it wont display totals.
    use sort
    i_sort type slis_alv...
    clear ws_sort.
    ws_sort1-spos = '1'<position of field>
    ws_sort-fieldname  = 'matnr'.
    ws_sort-up = 'x'.
    append ws_sort to i_sort.
    pass this i_sort to FM

  • How to Edit the CheckBox in Classic ALV GRID Display

    Hi,
    I want to Edit the checkbox in Grid Display.
    I have one checkbox field in my internal Table,
    Code Of the Program,
    Data :
    Begin of itab occurs 0,
    CHK type C,
    MATNR like MARA-MATNR,
    end of itab.
    Iam building the fieldcatelog using Merge Funcion module.
    After that I am chaning the properties of the field
    catelog like below,
    loop at I_FCAT assigning <FCAT>.
    Case <FCAT>-Fieldname
    When 'CHK'.
    <FCAT>-Checkbox = 'X'.
    <FCAT>-INPUT = 'X'.
    I dont have edit option in fieldcatelog.
    modify I_FCAT from <FCAT>.
    endcase.
    endloop.
    In the Layout,
    I_LAYOUT-box_fieldname = 'CHK'.
    I_LAYOUT-box_tabname = 'ITAB'.
    It is displaying the Checkbox field.but I couldnt edit the checkBox.
    I can able to edit in REUSE_ALV_LIST_DISPLAY.
    But I  have to use REUSE_ALV_GRID_DISPLAY.How to edit the checkbox.
    Thanks in Advance,
    Sumithra

    Hi vasu,
    The below procedure explains you to create a checkbox cloumn in the grid and allows you to edit i hope this will helps u.
    The ALV Grid Control displays the cells of a column as checkboxes if the column is marked as a checkbox column in the field catalog.
    •     Add another field to the output table in which you want to display checkboxes
    OR
    •     Define an existing field as a checkbox.
    Procedure
    1.     Add a field to your output table:
    Data: gt_fieldcat type lvc_t_fcat.
    Types: begin of gs_outtab.
    Types: checkbox type c. "field for checkbox
    Include structure <ABAP Dictionary structure> .
    Types: end of gs_outtab.
    Data: gt_outtab type gs_outtab occurs 0 with header line.
    2 * Add an entry for the checkbox to the field catalog
    clear ls_fcat.
    ls_fcat-fieldname = 'CHECKBOX'.
    * Essential: declare field as checkbox and
    * mark it as editable field:
    ls_fcat-checkbox = 'X'.
    ls_fcat-edit = 'X'.
    * do not forget to provide texts for this extra field
    ls_fcat-coltext = text-f01.
    ls_fcat-tooltip = text-f02.
    ls_fcat-seltext = text-f03.
    append ls_fcat to gt_fieldcat.
    regards,
    venu.

  • Identify selection of sub-total line in ALV grid

    Hi folks,
    Is there a way to identify in the report if the user has selected any sub-total line in an ALV grid? Both for REUSE_ALV_GRID_DISPLAY and CL_GUI_ALV_GRID.
    Thanks
    Sagar

    Sagar,
    1. I don't think its good design, if you want to process those three lines, you should ask the user to select those 3 rows and process them.
    2. If you have no choice, tyr these methods, these might give you some info
    GET_SORT_CRITERIA
    GET_SUBTOTALS
    These methods might give you the info you are looking for. Try it out.
    regards,
    Ravi

Maybe you are looking for