Suppressing some subtotals in an ALV grid

Hi,
Does anyone know if it is possible to suppress some of the subtotals in an ALV grid? In some cases I have redundant subtotals, and I would like to suppress one of them. I am using the event SUBTOTAL_TEXT, and this is not something I can control with the sort order.
Thanks,
Margaret Brooker.

Hi Margaret,
You might want to take a look at the Development Class (Package) in the Object Navigator (SE80) called SLIS.
There you will find excellent ALV demo programs that illustrate many possible customizations to the Alv grid.
Although there is not an exact supress subtotal example, you could probably create your own pushbuttons or events to embed your own logic.
It is possible to create a local class and implement a double click event, which could delete a duplicate line or any other preferred logic that you code.
cheers,
Marilyn

Similar Messages

  • How to disable sorting for some columns in a ALV GRID?

    Hi i have requirement where I have to disable sorting for some columns in a ALV GRID. i am using REUSE_ALV_GRID_DISPLAY function module.
    Can anybody help me. how to acieve this? Any code snippets will really be appreciated.

    Hi,
    I have tried this but not completely successful. I think this can be done using the OOPS method.
      DATA: it_event_exit TYPE  slis_t_event_exit.
      DATA: w_exit TYPE slis_event_exit.
      w_exit-ucomm = '&ODN'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      w_exit-ucomm = '&OUP'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          i_callback_top_of_page      = 'ALV_TOP_OF_PAGE'
          i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'
          i_callback_user_command     = 'USER_COMMAND'  <- User command form
          is_layout                   = wm_layout
          it_fieldcat                 = wt_fieldcat
          it_events                   = i_events
          it_event_exit               = it_event_exit    <- Need to fill
          it_sort                     = wt_sort
          i_default                   = 'X'
    Now you can capture this events in the user command
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      IF r_ucomm = '&OUP' and rs_selfield-SEL_TAB_FIELD = 'Your field name'.
      ENDIF.
    ENDFORM.                    "user_command
    In this form you will get the function code in 'r_ucomm' and the field selected for sorting in 'rs_selfield-SEL_TAB_FIELD'. But reseting 'r_ucomm' will not work.
    May be somebody else can give some help on this.
    But this will work if you follow the oop method.
    Please see this document for more info.
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
    Thanks
    Vinod

  • ALV grid using classes(displaying subtotals groupwise in ALV grid control)

    Hello ,
      please can any body help me its urgent tome.
    displaying subtotals groupwise ..say for ex..
    cost group  costelement         amount     
    10          101         100.00
    10                            102          200.00
    10                            103          300.00
    20                            104          400.00
    20                            105          500.00
    20                            106          600.00
                    101         100.00
                    102         200.00
                    103         300.00
    10                          600.00
              104         400.00
              105         500.00
              106         600.00
    20                         1500.00
    In ALV grid control using classes.
    Thanks in Advance

    Hi alson,
    MODULE pbo OUTPUT.
    SET PF-STATUS 'MAIN100'.
    IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
    EXPORTING container_name = g_container.
    CREATE OBJECT grid1
    EXPORTING i_parent = g_custom_container.
    <b>CALL METHOD grid1->set_table_for_first_display
    EXPORTING IS_LAYOUT = it_LAY
    CHANGING it_fieldcatalog = fieldcat
    it_sort = it_sort
    it_outtab = itab[].</b>
    ENDIF.
    ENDMODULE. " PBO OUTPUT
    keep the below code
    <b>CALL METHOD grid1->set_table_for_first_display
    EXPORTING IS_LAYOUT = it_LAY
    CHANGING it_fieldcatalog = fieldcat
    it_sort = it_sort
    it_outtab = itab[].</b>
    here
    IF pdel = 'X'.
    *BEGIN OF CHANGES BY VINAY DASARI
    PERFORM get_data.
    <b>CALL METHOD grid1->set_table_for_first_display
    EXPORTING IS_LAYOUT = it_LAY
    CHANGING it_fieldcatalog = fieldcat
    it_sort = it_sort
    it_outtab = itab[].</b>
    ENDIF.

  • Create deep structure to disable some cells in Dynamic ALV GRID

    Hi,
    I want to disable some cells in a Dynamic ALV Grid before calling "SET_tABLE_Display" Method.
    I check the BCALV_EDIT_02, where some cells are grayed out by assign the  CL_GUI_ALV_GRID-MC_STYLE_DISABLED  to the field name.
    But I want the same using Field symbol.
    I'm creating Dynamic table and dynamic structure based on the Dynamic field catalog.
    Example: <FT_TAB> TYPE STANDARD TABLE,
                    <FS_TAB> TYPE ANY,            
    DATA: INT_TAB  is my dynamic table values.
    For the INT_TAB internal table, I created dynamic Structure and dynamic field symbol table.
    LOOP AT INT_TAB.
    ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    <F_VALUE> = INT_TAB-MATNR.
    APPEND <FS_TAB> TO <FT_TAB>
    "Here is the problem occurs, I want to grayed out the MATNR value based on some condition.
    ENDLOOP.
    I would like to set the 'MATNR' value to be grayed out by passing the CL_GUI_ALV_GRID-MC_STYLE_DISABLED.
    and update into <FT_TAB>(       <FT_TAB> structure will have 2 structures)
    Finally the fieldsymbol should have two structure ( <F_TAB> = DYNAMIC STRUCTURE + LVC_S_STYLE )
    Display alv grid by passing <FT_TAB> to set_table_display method.
    Thanks in advance,
    Kumar.

    Hi,
    I am  not sure whether I really understand your request. Let me try to help.
    > Example: <FT_TAB> TYPE STANDARD TABLE,
    >                 <FS_TAB> TYPE ANY,            
    >
    > DATA: INT_TAB  is my dynamic table values.
    >
    >
    > LOOP AT INT_TAB.
    >  ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    > <F_VALUE> = INT_TAB-MATNR.
    >  APPEND <FS_TAB> TO <FT_TAB>
    Here <FT_TAB> must already be assigned to some internal table with a given (dynamic) structure. Did this happen before this piece of code?
    What I would do is to create a dynamic table (see documentation to CREATE DATA) with MATNR and the STYLE field (LVC_T_STYL). See the documentation for CREATE DATA - creation of internal tables. When collection the field descriptions for that internal table I would also build the field catalogue for the ALV.
    Then assign <FT_TAB> to that newly created internal table, <FS_TAB> to a newly created structure (same as a table line).
    Move the MATNR to component 1 (or component 'MATNR') of the table and fill the style table according to your needs. Then insert the <FS_TAB> into <FT_TAB>.
    Finally call the ALV SET_TABLE... method with your dynamic table and your field catalogue.
    Regards,
    Gerd Rother

  • Hide some cells while displaying ALV GRID !

    Hi guyz!
        Back with lill query,
        While displaying ALV GRID using REUSE_ALV_GRID... FMs ,i need to hide
        some cells by default, when the lists is generated.But those cells should
        be  availble to be displayed by the user from ALV layout settings.
        Please advise
    Thanks
    jahan

    Hi, Check for fm documentation.
    Only relevant if layout parameter
    LAYOUT-GET_SELINFOS of IMPORTING structure IS_LAYOUT is set.
    Complex type for modifying information displayed on the selection dialog box:
    mode:              'R' = Only entries passed in internal table
                              IS_SEL_HIDE-T_ENTRIES are output on
                              the dialog box. Selection information
                              obtained by the list tool by reading the
                              selection screen again (only if the report
                              is called with selection screen) are
                              replaced by the entries passed.
                       'S' = The selection information obtained by the
                              list tool by reading the selection screen
                              of the calling report again, are modified
                              by the entries of table
                              IS_SEL_HIDE-T_ENTRIES.
    t_entries:         Table with selection information
    t_entries-mode:   'A' = Display selection information of the current
                             table row on the information dialog box.
                      'D' = Do not display selection information of the
                             the Select option or of parameter SELNAME
                             on the dialog box.
    t_entries-selname: (required only if t_entries-mode = 'D')
                       name of Select option or parameter
    The following table fields are only required if t_entries-mode = 'A'. They contain the selection information to be added.
    t_entries-field:  DDIC field name of the field for which selection
                       information is to be displayed
    t_entries-table:  DDIC table name of t_entries-field.
    t_entries-stext:  Field description on the information dialog box.
                      If t_entries-field and t_entries-table were
                      filled, this text is taken from the DDIC.
    t_entries-valuf:  Selection condition from-value (external format)
    t_entries-valut:  Selection condition to-value (external format)
    t_entries-sign0:  (I)nclusive (E)xclusive
    t_entries-optio:  All values of the option field of the Select
                      option are allowed.
    The remaining fields are used internally and are irrelevant to the caller.
    aRs

  • How to download only some fields(dynamically) from alv grid layouts

    I have ALV grid list.
    I have layouts for selecting sets of fields dynamically.
    If I select a particular layout, I want to download only those fields into an Excel sheet.
    If I select another layout, I want to download only fields of that layout , into an Excel sheet.
    Can u plz write examples.
    Narendra

    Hello ,
    Here it is.
      FIELD-SYMBOLS <FS> TYPE ANY.
      DATA: GR_ATTACHMENT TYPE Z48S3_ATTACHMENT,
            GT_ATTACHMENT TYPE Z48S3_ATTACHMENT_TAB,
            L_F_TITLE     TYPE SO_OBJ_DES,
            L_R_FIELDCAT  LIKE LINE OF GT_FIELDCAT,
            L_F_FIELD     LIKE L_R_FIELDCAT-FIELDNAME,
            L_F_EMAILID   TYPE Z48S3_RECEIVER,
            L_F_FIRST     TYPE C.
      IF SY-SYSID EQ G_C_DEV_SYSTEM OR
         SY-SYSID EQ G_C_QUA_SYSTEM.
        CONCATENATE SY-SYSID '/' SY-MANDT ':' INTO L_F_TITLE.
        CONDENSE L_F_TITLE.
        CONCATENATE L_F_TITLE SY-TITLE INTO L_F_TITLE SEPARATED BY SPACE.
      ELSE.
        L_F_TITLE = SY-TITLE.
      ENDIF.
      G_R_VARIANT-REPORT = SY-REPID.
      G_R_VARIANT-VARIANT = P_VARIAN.
      CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
           EXPORTING
                I_DIALOG            = 'N'
                I_USER_SPECIFIC     = 'A'
                I_DEFAULT           = 'X'
                IT_DEFAULT_FIELDCAT = G_T_FIELDCAT
                I_LAYOUT            = GR_LAYOUT
           IMPORTING
                ET_FIELDCAT         = G_T_FIELDCAT
                ES_LAYOUT           = GR_LAYOUT
           CHANGING
                CS_VARIANT          = G_R_VARIANT
           EXCEPTIONS
                ERROR_MESSAGE       = 4
                OTHERS              = 4.
      SORT G_T_FIELDCAT BY COL_POS.
      PERFORM CREATE_EXCEL_ATTM_HEADING_ROW TABLES GT_ATTACHMENT
                                                   G_T_FIELDCAT.
      LOOP AT G_T_ALVLIST.
        L_F_FIRST = 'X'.
        LOOP AT G_T_FIELDCAT INTO L_R_FIELDCAT WHERE NO_OUT IS INITIAL.
          CLEAR GR_ATTACHMENT-XNEWLINE.
          IF NOT L_F_FIRST IS INITIAL.
            GR_ATTACHMENT-XNEWLINE = 'X'.
            CLEAR L_F_FIRST.
          ENDIF.
          CLEAR L_F_FIELD.
          CONCATENATE 'G_T_ALVLIST-' L_R_FIELDCAT-FIELDNAME
                 INTO L_F_FIELD.
          CONDENSE L_F_FIELD.
          ASSIGN (L_F_FIELD) TO <FS>.
          WRITE <FS> TO GR_ATTACHMENT-FIELDVALUE.
          UNASSIGN <FS>.
          APPEND GR_ATTACHMENT TO GT_ATTACHMENT.
        ENDLOOP.
      ENDLOOP.
    Regards,
    Vasanth

  • Require some tutorials to use ALV grids to access database

    I am new to ALV grids
    I want step by step method to use ALV grids in ABAP reports to access database.

    Hi,
    pls go throgugh this link.
    http://www.erpgenie.com/abap/controls/alvgrid.htm
    sample program
    Sample programs on ALV Grid
    report zbnstest.
    TABLES AND DATA DECLARATION.
    *TABLES: mara,makt.",marc.
    data syrepid like sy-repid.
    data sydatum(10). " LIKE sy-datum.
    data sypagno(3) type n.
    WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
    GROUP (TYPE-POOLS--------->SLIS)
    type-pools : slis.
    INTERNAL TABLE DECLARATION.
    INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    mtart like mara-mtart,
    matkl like mara-matkl,
    end of t_mara.
    INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
    data : begin of t_marc occurs 0,
    matnr like mara-matnr,
    werks like marc-werks,
    minbe like marc-minbe.
    data: end of t_marc.
    INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
    data : begin of t_makt occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    spras like makt-spras,
    end of t_makt.
    INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
    data: begin of itab1 occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    maktx like makt-maktx,
    spras like makt-spras,
    werks like marc-werks,
    minbe like marc-minbe,
    end of itab1.
    THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
    AND THE LAYOUT FOR THE ALV.
    HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
    WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
    OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
    THIS IS DONE TO MAKE THE CODE SIMPLER.
    OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
    PROGRAMS.
    IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
    MORE TABLES AND CREATE A STRUCTURE
    IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
    LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    fieldlayout type slis_layout_alv.
    DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
    TOP-OF-PAGE ETC.
    data : eventstab type slis_t_event with header line.
    DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
    data : heading type slis_t_listheader with header line.
    data : heading1 type slis_t_listheader with header line.
    data : heading2 type slis_t_listheader with header line.
    data : heading3 type slis_t_listheader with header line.
    data : heading4 type slis_t_listheader with header line.
    data : heading5 type slis_t_listheader with header line.
    data : heading6 type slis_t_listheader with header line.
    data : heading7 type slis_t_listheader with header line.
    data : heading8 type slis_t_listheader with header line.
    STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
    data : colorstruct type slis_coltypes.
    INITIALIZATION. *
    initialization.
    syrepid = sy-repid.
    sypagno = sy-pagno.
    clear fieldcatalog.
    START-OF-SELECTION. *
    start-of-selection.
    SUBROUTINE TO POPULATE THE COLORSTRUCT
    perform fill_colorstruct using colorstruct.
    SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
    perform populate_fieldcatalog.
    SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
    INTERNAL TABLE.
    perform selectdata_and_sort.
    SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
    perform populate_layout using fieldlayout.
    SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
    perform merge_fieldcatalog.
    SUBROUTINE TO POPULATE THE EVENTSTAB.
    perform fill_eventstab tables eventstab.
    SUBROUTINE TO POPULATE THE HEADING TABLES.
    perform fill_headingtable tables heading using 'HEADING'.
    perform fill_headingtable tables heading1 using 'HEADING1'.
    perform fill_headingtable tables heading2 using 'HEADING2'.
    perform fill_headingtable tables heading3 using 'HEADING3'.
    perform fill_headingtable tables heading4 using 'HEADING4'.
    perform fill_headingtable tables heading5 using 'HEADING5'.
    perform fill_headingtable tables heading6 using 'HEADING6'.
    perform fill_headingtable tables heading7 using 'HEADING7'.
    perform fill_headingtable tables heading8 using 'HEADING8'.
    SUBROUTINE TO DISPLAY THE LIST.
    perform display_alv_list.
    FORMS
    IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
    OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
    COLUMN JUSTIFICATION.
    form populate_fieldcatalog.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATNR' 'X' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MEINS' ' '.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MAKTX' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MTART' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATKL' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'SPRAS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'WERKS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MINBE' ' ' .
    endform. " POPULATE_FIELDCATALOG
    FORM FILL_FIELDS_OF_FIELDCATALOG *
    --> FIELDCATALOG *
    --> P_TABNAME *
    --> P_FIELDNAME *
    --> P_KEY *
    --> P_KEY *
    form fill_fields_of_fieldcatalog tables fieldcatalog
    structure fieldcatalog
    using p_tabname
    p_fieldname
    p_key.
    p_no_out.
    fieldcatalog-tabname = p_tabname.
    fieldcatalog-fieldname = p_fieldname.
    fieldcatalog-key = p_key.
    fieldcatalog-emphasize = '1234'.
    *fieldcatalog-no_out = p_no_out.
    append fieldcatalog.
    endform. " FILL_FIELDSOFFIELDCATALOG
    FORM POPULATE_LAYOUT *
    --> FIELDLAYOUT *
    form populate_layout using fieldlayout type slis_layout_alv.
    fieldlayout-f2code = '&ETA' .
    fieldlayout-zebra = 'X'.
    FOR THE WINDOW TITLE.
    fieldlayout-window_titlebar = 'ALV with Events'.
    fieldlayout-colwidth_optimize = 'X'.
    fieldlayout-no_vline = ' '.
    *fieldlayout-no_input = 'X'.
    fieldlayout-confirmation_prompt = ''.
    fieldlayout-key_hotspot = 'X'.
    This removes the column headings if the flag is set to 'X'
    fieldlayout-no_colhead = ' '.
    *fieldlayout-hotspot_fieldname = 'MAKTX'.
    fieldlayout-detail_popup = 'X'.
    fieldlayout-coltab_fieldname = 'X'.
    endform. " POPULATE_LAYOUT
    FORM SELECTDATA_AND_SORT *
    form selectdata_and_sort.
    select matnr meins mtart matkl from mara
    into corresponding fields of t_mara
    up to 500 rows .
    select matnr maktx spras from makt
    into corresponding fields of t_makt
    where matnr = t_mara-matnr and
    spras = sy-langu.
    select matnr werks minbe from marc
    into corresponding fields of t_marc
    where matnr = t_mara-matnr.
    append t_marc.
    endselect.
    append t_makt.
    endselect.
    append t_mara.
    endselect.
    perform populate_itab1.
    sort itab1 by matnr.
    endform. " SELECTDATA_AND_SORT
    FORM MERGE_FIELDCATALOG *
    form merge_fieldcatalog.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = syrepid
    i_internal_tabname = 'ITAB1'
    i_structure_name = 'COLORSTRUCT'
    I_CLIENT_NEVER_DISPLAY = 'X'
    i_inclname = syrepid
    changing
    ct_fieldcat = fieldcatalog[]
    exceptions
    inconsistent_interface = 1
    program_error = 2
    others = 3.
    endform. " MERGE_FIELDCATALOG
    IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
    FOLLOWS:-
    i_callback_program --> CALLING PROGRAM NAME
    i_structure_name --> STRUCTURE NAME.
    is_layout --> LAYOUT NAME.
    it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
    form display_alv_list.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    I_INTERFACE_CHECK = ' '
    i_callback_program = syrepid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ITAB1'
    is_layout = fieldlayout
    it_fieldcat = fieldcatalog[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
    TOOL BAR
    i_save = 'A'
    IS_VARIANT = ' '
    it_events = eventstab[]
    IT_EVENT_EXIT =
    IS_PRINT =
    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. " DISPLAY_ALV_LIST
    *& Form POPULATE_ITAB1
    text
    --> p1 text
    <-- p2 text
    form populate_itab1.
    loop at t_mara.
    loop at t_makt where matnr = t_mara-matnr.
    loop at t_marc where matnr = t_mara-matnr.
    move-corresponding t_mara to itab1.
    move-corresponding t_makt to itab1.
    move-corresponding t_marc to itab1.
    append itab1.
    endloop.
    endloop.
    endloop.
    endform. " POPULATE_ITAB1
    *& Form FILL_EVENTSTAB
    text
    -->P_EVENTSTAB text *
    form fill_eventstab tables p_eventstab structure eventstab.
    WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
    INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
    AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
    EVENTS NAME.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_eventstab[]
    exceptions
    list_type_wrong = 1
    others = 2.
    BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
    THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
    WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
    FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
    IS DYNAMICALY CALLED.
    read table p_eventstab with key name = slis_ev_top_of_page.
    if sy-subrc = 0 .
    move 'TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_coverpage.
    if sy-subrc = 0 .
    move 'TOP_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_coverpage .
    if sy-subrc = 0 .
    move 'END_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_top_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_end_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_list_modify.
    if sy-subrc = 0 .
    move 'LIST_MODIFY' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_list.
    if sy-subrc = 0 .
    move 'TOP_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_page.
    if sy-subrc = 0 .
    move 'END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_list .
    if sy-subrc = 0 .
    move 'END_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    endform. " FILL_EVENTSTAB
    *& Form FILL_HEADINGTABLE
    text
    -->P_HEADING text *
    form fill_headingtable tables p_heading structure heading
    using tablename.
    case tablename.
    when 'HEADING'.
    p_heading-typ = 'H'.
    concatenate
    ' REPORT NAME:-' syrepid
    ' ABB Industry Pte Ltd' into p_heading-info.
    append p_heading.
    write sy-datum using edit mask '__/__/____' to sydatum.
    concatenate
    ' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
    into p_heading-info.
    append p_heading.
    when 'HEADING1'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING2'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING3'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
    append p_heading.
    when 'HEADING4'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-END-OF-PAGE'.
    append p_heading.
    WHEN 'HEADING5'.
    P_HEADING-TYP = 'H'.
    P_HEADING-INFO = 'LIST-MODIFY'.
    APPEND P_HEADING.
    when 'HEADING6'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-PAGE'.
    append p_heading.
    when 'HEADING7'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-LIST'.
    append p_heading.
    when 'HEADING8'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-LIST'.
    append p_heading.
    endcase.
    endform. " FILL_HEADINGTABLE
    FORM TOP_OF_PAGE *
    form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading[]
    exceptions
    others = 1.
    endform.
    *& Form FILL_COLORSTRUCT
    text
    -->P_COLORSTRUCT text *
    form fill_colorstruct using p_colorstruct type slis_coltypes .
    p_colorstruct-heacolfir-col = 6.
    p_colorstruct-heacolfir-int = 1.
    p_colorstruct-heacolfir-inv = 1.
    endform. " FILL_COLORSTRUCT
    FORM TOP_OF_COVERPAGE *
    form top_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading1[]
    exceptions
    others = 1.
    endform.
    FORM END_OF_COVERPAGE *
    form end_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading2[]
    exceptions
    others = 1.
    endform.
    FORM FOREIGN_TOP_OF_PAGE *
    form foreign_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading3[]
    exceptions
    others = 1.
    endform.
    FORM FOREIGN_END_OF_PAGE *
    form foreign_end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading4[]
    exceptions
    others = 1.
    endform.
    FORM LIST_MODIFY *
    *FORM LIST_MODIFY.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEADING5[]
    EXCEPTIONS
    OTHERS = 1.
    *ENDFORM.
    FORM END_OF_PAGE *
    form end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading6[]
    exceptions
    others = 1.
    endform.
    FORM END_OF_LIST *
    form end_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading7[]
    exceptions
    others = 1.
    endform.
    FORM TOP_OF_LIST *
    form top_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading8[]
    exceptions
    others = 1.
    endform.
    *--- End of Program
    Thanks,
    Shankar

  • Problem While Saving the editable ALV GRID

    Dear Experts,
    I have a scenario in which i am display the ALV(using class) with some data in the custom container of module pool screen in the non-editable mode.Also i have save and edit buttons.If i click the edit button i have written the code to edit the some columns in the ALV grid, it is working fine.After editing it,when i click the save button then ALV has to refreshed with edited data and then it should go to non editable mode but it is not working.I have written the code for changing the editable ALv to non editable mode as follows :
      call method c_alvgd->set_ready_for_input
        exporting
          i_ready_for_input = 0.
    *****Row and column of the alv are refreshed after changing values
      stable-row = 'X'.
      stable-col = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      call method c_alvgd->refresh_table_display
        exporting
          is_stable = stable
        exceptions
          finished  = 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.
    Could you Suggest me solution for this issue ?
    Thanks & Regards,
    R.Dhineshraj.

    Dhinesh,
    I suppose that you are able to get your changes values on screen but not able to get your field in DISPLAY mode from editable mode, let me know if this is not your problem.
    When you press SAVE, after the PAI, again PBO will run and hence the editable code for that field will overwrite which will keep it editable.
    So, do something like this.
    data: gv_edit value 'X'.....  "global variable in TOP include
    PBO....
    loop at ...
    if gv_edit = 'X'.
    CALL METHOD lo_alv->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
    else.
    CALL METHOD lo_alv->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
    endif.
    endloop.
    PAI.
    when 'SAVE'.
    gv_edit =  space.
    When 'EDIT'.
    gv_edit = 'X'.
    Regards,
    Diwakar

  • The Visible attribute on alv grid column is not changed after Change Layout

    Setup:
    I have a program that displays output in an ALV grid (using cl_salv_table).
    The ALV grid is displayed within a custom control on a subscreen.
    I have 4 subscreens being used on a tabstrip control.  So I have 4 ALV grids total (one on each subscreen).
    On each ALV grid, I have set the set_layout_change function to true so that the user can hide and unhide columns etc. on each grid via the button on the alv grid toolbar.
    I also allow the user to dowload the contents of all 4 grids to excel.  To do this I have a custom button that when clicked goes to each ALV grid - gets the column metadata (via cl_salv_columns_table-get() ) and checks the visibility to determine if the column should be downloaded or not (via cl_salv_column-is_visible() ) to excel.
    The Problem:
    As I said I have 4 grids being displayed via a tab control.  Let's say the user is on tab 1 and unhides some columns on the alv grid 1 via the Change Layout... button.  And then the user navigates to tab 2.  If they click the download button at that point - when the download code is run and it checks the visibility of the columns on alv grid 1 - the changes that were made via the Change Layout... button have not synchronized yet.  When I call is_visible() for a column that was unhid it still comes back as false. 
    The only way I have found to remedy this is to make the user click on a button on the alv grid's toolbar before navigating to a different tab to force the synchronization between the changes made and the backend column metadata.  However, this is not the best option and requires training for the user that they have to do this for the download to work correctly. 
    The Question:
    1) why is the Change Layout... button not automatically synchronizing the changes it made to the back end?  Is there a way to make it do this?
    2) OR, is there a way that I can force the synchronization within the code and not force the user to click a button on the alv grid?  If there is a way to force the synchronization - where do I put that code?  As far as I can tell, when I switch between tabs - I am unable to catch that action in my PAI events.
    Thanks in advance for any help.

    I was able to resolve this issue with a satisfactory solution.
    In my program I had a local class definition to handle the grids' events.  When the synchronization wasn't working I only had two events defined: for link_click and added_functions. 
    I created another definition for event after_salv_function:
                   on_after_salv_function for event after_salv_function of cl_salv_events importing e_salv_function
    There is no code in the method implementation - but adding this event handler now causes a synchronization to occur after the Change Layout is done.

  • How change standard field lable in alv grid display

    Hi Experts,
        How are you doing! I am having some doubts in the alv grid display, I am new to this concepts.
    I want to display field  lable manually, actually its taking from table field discription but I want to display one field name manually.
    example code.
    ls_fldcat-fieldname = 'BPKIND'.
      ls_fldcat-ref_tabname = 'BUT000'.
      ls_fldcat-ref_fieldname = 'BPKIND'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'PARTNER2'.
      ls_fldcat-ref_tabname = 'BUT051'.
      ls_fldcat-ref_fieldname = 'PARTNER2'.
    Here I dont want to display 'PARTNER2' I need 'KEY ACCOUNT MANAGER'.
    Please send me how to do this.
    Surya Ramireddy.

    Hi
      Please check out this program.
    Type-pools: slis.
    Tables: likp.
    Data: Begin of i_likp occurs 0,
            vbeln like likp-vbeln,
            ernam like likp-ernam,
            erzet like likp-erzet,
            erdat like likp-erdat,
          End of i_likp.
    Data: it_fieldcat type slis_t_fieldcat_alv,
          wa_fieldcat type SLIS_FIELDCAT_ALV,
          it_events type slis_t_event.
    Selection-screen: Begin of block b1 with frame title text-001.
      select-options: s_vbeln for likp-vbeln.
    Selection-screen: End of block b1.
    start-of-selection.
    perform get_sales_header_data.
    end-of-selection.
    perform field_catalogue.
    perform modify_field_catalogue.
    perform display_alv_grid_display.
    *&      Form  get_sales_header_data
          text
    -->  p1        text
    <--  p2        text
    form get_sales_header_data .
    select vbeln
           ernam
           erzet
           erdat
           into table i_likp
           from likp
           where vbeln in s_vbeln.
    endform.                    " get_sales_header_data
    *&      Form  field_catalogue
          text
    -->  p1        text
    <--  p2        text
    form field_catalogue .
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'I_LIKP'
       I_INCLNAME                   = sy-repid
      CHANGING
        ct_fieldcat                  = it_fieldcat
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    endform.                    " field_catalogue
    *&      Form  modify_field_catalogue
          text
    -->  p1        text
    <--  p2        text
    form modify_field_catalogue .
    loop at it_fieldcat into wa_fieldcat.
    case wa_fieldcat-fieldname.
      when 'VBELN'.
       wa_fieldcat-col_pos = 1.
       wa_fieldcat-seltext_l = 'Sales Doc Header No'.
       wa_fieldcat-emphasize = 'C100'.
      when 'ERNAM'.
       wa_fieldcat-col_pos = 2.
       wa_fieldcat-seltext_l = 'Created By'.
       wa_fieldcat-emphasize = 'C200'.
      when 'ERZET'.
       wa_fieldcat-col_pos = 3.
       wa_fieldcat-seltext_l = 'Entry Time'.
       wa_fieldcat-emphasize = 'C300'.
      when 'ERDAT'.
       wa_fieldcat-col_pos = 4.
       wa_fieldcat-seltext_l = 'Created On'.
       wa_fieldcat-emphasize = 'C400'.
      endcase.
      modify it_fieldcat from wa_fieldcat.
    endloop.
    endform.                    " modify_field_catalogue
    *&      Form  display_alv_grid_display
          text
    -->  p1        text
    <--  p2        text
    form display_alv_grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IT_FIELDCAT                       = IT_FIELDCAT
      TABLES
        t_outtab                          = i_likp
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    endform.                    " display_alv_grid_display
    Regards
    Haritha.

  • Subtotals text in ALV

    Hi All,
         I want subtotals text in ALV GRID. For this iam seeing a standard program 'BCALV_TEST_FULLSCREEN'.Iam giving subtotal text on selection screen,but its not displayed in output.How to view the text.
    When i executed another program BCALV_TEST_LIST, iam able to get the subtotal text in output, what ever i give the text on the selction screen.
    Regards,
    Kiran I

    Hi,
    Chk out this:
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    Best Regards,
    Anjali

  • ALV Grid: Unregister keyboard events?

    Hi guys,
    once again I've got some trouble with my ALV-grid control.
    In order to implement my own functionality for removing and adding lines to my alv grid I removed the standard-buttons from the toolbar and added my own.
    Unfortunately the user can still remove lines from the alv by pressing the DEL key on the keyboard.
    Adjusting the layout by setting   ps_layout-no_rowins   =  'X' and ps_layout-no_rowmove  =  'X' doesn't work for me since the alv contains a field CHDATE to show the date when the line was last edited. If the user presses the DEL key there's no way for me to adjust this field.
    So, does anyone have an idea how to "unregister" these keyevents?
    Any help is much appreciated!
    Best regards,
    ron

    Hi guys,
    i just found a way to prevent the deletion of a line by pressing DEL on the keyboard.
    All you have to do is include an additional field (type LVC_T_STYL) to your outtab.
    This structure include the following fields:
    FIELDNAME     LVC_FNAME
    STYLE     LVC_STYLE
    STYLE2     LVC_STYLE
    STYLE3     LVC_STYLE
    STYLE4     LVC_STYLE
    MAXLEN     INT4
    This structures is normally used to set the style for a cell by specifying the FIELDNAME.
    When FIELDNAME is initial the style works for the line. So instead of changing the fieldname just leave it blank and change STYLE to cl_gui_alv_grid=>MC_STYLE_NO_DELETE_ROW
    This way the line can neither be removed with the standard "REMOVE LINE"-button nor by pressing DEL.
    Keep in mind that it doesn't work when you change the layout to layout-no_rowins   =  'X' and layout-no_rowmove  =  'X'.
    Regards,
    Ron

  • ALV Grid Handle Edit Event (Lost Focus)

    Hi all,
    I have some problems with the ALV Grid.
    Target:
    I have an ALV Grid with editable Column. If the user insert, update or delete the content of the column and leave the column (column lost focus) i'd like to do somthing - this means I need a event for this action. Can anybody help me to solve this problem?
    Thanks Stefan

    Use Event data_changed and data_changed_finished of the cl_gui_alv_grid.Then all you have to do is registering your event to the ALV and fill the methods with what you want to do.In ALV Grid, There is no event to capture the lost focus of a column if you don't modify it.
    CLASS lcl_event_receiver DEFINITION.
        METHODS:
    *$ Check the change
           handle_data_changed FOR EVENT data_changed
                                   OF cl_gui_alv_grid
                               IMPORTING er_data_changed
                                         e_ucomm
                                         e_onf4
                                         e_onf4_before
                                         e_onf4_after,
           handle_data_changed_finished
                               FOR EVENT data_changed_finished
                                   OF cl_gui_alv_grid
                                IMPORTING e_modified
                                         et_good_cells
                                         sender,
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION

  • Multiple selection of  e_ucomm in ALV Grid toolbar

    Dear SAP friends,
    I have created HR report.
    On the selection screen the User enters some initial data  and ALV Grid get displayed.
    In event Handle_toolbar the program adds a custom button to standard ALV grid toolbar named "ABSENCE/ATTENDANCE".
    In event handle_menu_button the program adds functions to this button.
    Then in event handle_user_command depending on the function selected "e_ucomm" the program repopulates the ALV Grid.
    METHOD handle_toolbar.
    * Append a separator to standard toolbar
        CLEAR gs_toolbar.
        gs_toolbar-butn_type = 3.
        APPEND gs_toolbar TO e_object->mt_toolbar.
        CLEAR gs_toolbar.
        gs_toolbar-function  = 'ABSENCE/ATTENDANCE'.
        gs_toolbar-icon      = icon_position_hr.
        gs_toolbar-quickinfo = 'Absence/Attendance Type'.
        gs_toolbar-butn_type = 2.               " 2-Menu type, 0-single button type
        gs_toolbar-disabled  = space.
        APPEND gs_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
      METHOD handle_menu_button.
    * Handle own menubuttons
        IF e_ucomm = 'ABSENCE/ATTENDANCE'.
         LOOP AT it_aa INTO it_aa_ln.
           MOVE it_aa_ln-type TO w-fcode.
          CONCATENATE   it_aa_ln-type '=' it_aa_ln-text
            INTO w-text
              SEPARATED BY SPACE.
          CALL METHOD e_object->add_function
            EXPORTING
              fcode = w-fcode
              text  = w-text.
         ENDLOOP.
        ENDIF.
      ENDMETHOD.                    "handle_menu_button
      METHOD handle_user_command.
        MOVE e_ucomm TO w-abstype.
        PERFORM abs_att USING w-abstype.
      ENDMETHOD.                    "handle_user_command
    Is there a way to select more than one line or e_ucomm in other words at a time?
    I would like to give my user a choice of let's say one report with three types of absences at a time rather than three reports with one type each.
    Thanks,
    Tatyana

    The whole point of a toolbar button is to do a specific function.
    What I would actually do here is in your menu button add another option say "User Choice" and when this is clicked throw up another screen say  another ALV grid where the user can choose the various combinations  or do it via a POPUP. A second grid IMO would be the best way to do it as the user can select easily specific rows.
    You can either display the 2nd grid in a 2nd custom container on your main screen where you are showing the ALV grid or pass control  to a new screen / program.  Using a 2nd container is better as you still will have your instance of the original grid available.
    Cheers
    Jimbo

  • Changing font size(bold) or color of a particular row in ALV Grid Digplay

    Hi Experts ,
    I am having a requirment to highlight some particular rows in ALV Grid Display . To achieve this i need to change font size or make it bold or change color of that row .
    Please give me some inputs .
    Thanks in Advance.
    Vijyeta

    Hi
    Coloring An Entire Row
    Coloring a row is a bit (really a bit) more complicated. , you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row.
    First you have to declaration of our list data table u201Cgt_listu201D.
    DATA BEGIN OF gt_list OCCURS 0 .
    INCLUDE STRUCTURE SFLIGHT .
    DATA rowcolor(4) TYPE c .
    DATA END OF gt_list .
    Adding the field that will contain row color data
    As you guess, you should fill the color code to this field.  But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field u201CINFO_FNAMEu201D of the layout structure.
    e.g.
    ps_layout-info_fname = <field_name_containing_color_codes>. u201Ce.g. u2018ROWCOLORu2019
    You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
    Try this link also:
    Possible functionalities in ALV
    Regards
    Neha

Maybe you are looking for