Skip to Content
author's profile photo Former Member
Former Member

ALV Grid

How can I implement "select all" and "deselect all" functionality in ALV Grid?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 07:34 AM

    Hi

    You can refresh the ALV in the user_call_back routine. This user_call_back routine is the form where you usually operate the user commands

    FORM handle_ucomm USING r_ucomm LIKE sy-ucomm

    r_selfld TYPE slis_selfield.

    CASE r_ucomm.

    WHEN 'SELECT ALL'

    modify data internal table .

    r_selfld-refresh = 'X'.

    endcase.

    <b>Reward if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I hv used this code. This works but the Alv list is reprinted n bcoz of that screen flicks for a second...can this flicking of screen be removed?

      WHEN '&SELECTALL'.

      CLEAR wa_sub.

      LOOP AT it_sub INTO wa_sub.

      wa_sub-cbox = 'X'.

      MODIFY it_sub FROM wa_sub.

      CLEAR wa_sub.

      ENDLOOP.

      CLEAR wa_sub.

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 07:37 AM

    Hi

    /community [original link is broken]

    /community [original link is broken]

    <b>Reward if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 09:46 AM

    hi,

    try this

    *----


    • TYPE-POOLS

    *----


    TYPE-POOLS: slis. " Type pool for ALV

    *----


    • Tables

    *----


    TABLES: vbak, vbap.

    *----


    • INTERNAL TABLES

    *----


    DATA: BEGIN OF g_t_itab OCCURS 0,

    sel TYPE c,

    vbeln LIKE vbak-vbeln,

    erdat LIKE vbak-erdat,

    vbtyp LIKE vbak-vbtyp,

    vkorg LIKE vbak-vkorg,

    vtweg LIKE vbak-vtweg,

    spart LIKE vbak-spart,

    netwr LIKE vbak-netwr,

    kunnr LIKE vbak-kunnr,

    END OF g_t_itab.

    DATA: BEGIN OF g_t_item OCCURS 0,

    vbeln LIKE vbap-vbeln,

    posnr LIKE vbap-posnr,

    matnr LIKE vbap-matnr,

    arktx LIKE vbap-arktx,

    END OF g_t_item.

    • Data fields used for ALV call - simple list

    DATA : g_f_repid LIKE sy-repid.

    DATA : g_t_fieldcat TYPE slis_t_fieldcat_alv.

    DATA : g_r_fieldcat TYPE slis_fieldcat_alv.

    DATA : g_t_events TYPE slis_t_event.

    DATA : g_r_events TYPE slis_alv_event.

    DATA : g_r_layout TYPE slis_layout_alv.

    DATA : g_r_x_variant LIKE disvariant.

    DATA : g_r_variant LIKE disvariant.

    DATA : g_f_exit(1) TYPE c.

    DATA : g_f_save(1) TYPE c.

    *----


    • SELECTION SCREEN

    *----


    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.

    SELECTION-SCREEN END OF BLOCK b1.

    *----


    • START OF SELECTION

    *----


    START-OF-SELECTION.

    PERFORM get_data.

    *----


    • END OF SELECTION

    *----


    END-OF-SELECTION.

    PERFORM set_alv_parameters.

    PERFORM display_list.

    &----


    *& Form get_data

    &----


    • Get data from DB tables

    ----


    FORM get_data.

    CLEAR: g_t_itab.

    REFRESH: g_t_itab.

    SELECT vbeln erdat vbtyp vkorg vtweg spart netwr kunnr

    FROM vbak

    INTO CORRESPONDING FIELDS OF TABLE g_t_itab

    WHERE

    vbeln IN s_vbeln.

    ENDFORM. " get_data

    &----


    *& Form set_alv_parameters

    &----


    • Set alv parameters , layout, events, fieldcatlog

    ----


    FORM set_alv_parameters.

    PERFORM set_filedcatlog.

    • Events

    REFRESH : g_t_events.

    CLEAR : g_r_events.

    • Top of Page event for standard header

    g_r_events-name = 'TOP_OF_PAGE'.

    g_r_events-form = 'TOP_OF_PAGE'.

    APPEND g_r_events TO g_t_events.

    ENDFORM. " set_alv_parameters

    &----


    *& Form display_list

    &----


    • text

    ----


    FORM display_list.

    g_f_repid = sy-repid.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = g_f_repid

    • i_callback_user_command = 'USER_COMMAND'

    • is_layout = g_r_layout

    it_fieldcat = g_t_fieldcat[]

    it_events = g_t_events[]

    TABLES

    t_outtab = g_t_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_list

    &----


    *& Form set_filedcatlog

    &----


    • text

    ----


    FORM set_filedcatlog.

    DATA: l_r_fieldcat TYPE slis_fieldcat_alv. " For column heading

    CLEAR : g_t_fieldcat,

    g_t_fieldcat[].

    • Sales Order

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'VBELN'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'VBELN'.

    l_r_fieldcat-no_out = ' '.

    l_r_fieldcat-input = 'X'.

    • l_r_fieldcat-edit = 'X'. "For Push buttons

    l_r_fieldcat-key = 'X'.

    l_r_fieldcat-col_pos = 2.

    • l_r_fieldcat-seltext_m = 'Sales Order'.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • Creation date

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'ERDAT'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'ERDAT'.

    l_r_fieldcat-col_pos = 3.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • document category

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'VBTYP'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'VBTYP'.

    l_r_fieldcat-col_pos = 4.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • Sales organization

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'VKORG'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'VKORG'.

    l_r_fieldcat-col_pos = 5.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • Distribution channel

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'VTWEG'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'VTWEG'.

    l_r_fieldcat-col_pos = 6.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • Division

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'SPART'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'SPART'.

    l_r_fieldcat-col_pos = 7.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • Net Value

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'NETWR'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'NETWR'.

    l_r_fieldcat-do_sum = 'X'.

    l_r_fieldcat-col_pos = 8.

    l_r_fieldcat-emphasize = 'C500'.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    • Distribution channel

    l_r_fieldcat-tabname = 'G_T_ITAB'.

    l_r_fieldcat-fieldname = 'KUNNR'.

    l_r_fieldcat-ref_tabname = 'VBAK'.

    l_r_fieldcat-ref_fieldname = 'KUNNR'.

    l_r_fieldcat-col_pos = 9.

    APPEND l_r_fieldcat TO g_t_fieldcat.

    CLEAR l_r_fieldcat.

    ENDFORM. " set_filedcatlog

    ----


    • FORM top_of_page *

    ----


    FORM top_of_page.

    DATA : l_r_listheader TYPE slis_t_listheader,

    l_r_line TYPE slis_listheader.

    CLEAR l_r_line.

    l_r_line-typ = 'H'.

    l_r_line-info = 'Sales details'.

    APPEND l_r_line TO l_r_listheader.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = l_r_listheader

    • I_LOGO =

    • I_END_OF_LIST_GRID =.

    .

    ENDFORM. "top_of_page

    here u will get one button for select deselect all in grid at upper-left side....

    Its because of <b>EDIT</b> option in fieldcat.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.