Skip to Content
author's profile photo
Former Member

ALV REFRESH

Hai

how to refresh ALV grid values?

calling bELOW FM alone did not get refresh. do we have to

call routine again.?

CALL METHOD go_grid->refresh_table_display.

CALL METHOD cl_gui_cfw=>flush.

Chandra

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Jan 10, 2005 at 06:27 AM

    Thanks for your reply.

    I changed 'REFRESH' as Functional code and tried as below.

    But it did not works. Unless i call the (Select *) command call again using PERFORM LOADDATA.

    I checked all examples..but still doubt.could you please confirm..

    Refer code below.

    CASE e_ucomm.

    WHEN 'REFRESH'.

    • Perform Loaddata.

    CALL METHOD go_grid->refresh_table_display.

    CALL METHOD cl_gui_cfw=>flush.

    Note:

    Above two lines alone does not Refresh the Grid including Structure values?

    Regards

    Chandra kumar

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 09, 2005 at 08:28 PM

    Hi Chandra

    Your question lacks some information to be answered. It is important to know where and how you call the method. You may have somethings wrong while you are building ALV grid. However, I suggest you to inspect the tutorial "An" target="_blank">www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference For ALV Grid Control".

    <i>And as a last thing, let me introduce you the SDN forums pointing system: You can assign points to posts you find helpful while solving your question. You can reward points by clicking the yellow star icon at header of each reply post. You can reward;

    - one 10 points (solved)

    - two 6 points (very helpful answer)

    - many 2 points (helpful answer)</i>

    Kind Regards...

    *--Serdar

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Jan 10, 2005 at 04:27 AM

    hai let me post the code below

    i have writen Refresh code in EVEN HANDLER place.

    When i click Refresh button at ALVgrid, it should refresh

    the grid values.

    REPORT ZALVTEST .

    TYPE-POOLS: icon. TABLES: ZSFLIGHT.

    CLASS lcl_event_receiver DEFINITION DEFERRED.

    DATA: gi_sflight TYPE STANDARD TABLE OF sflight.

    DATA: ok_code LIKE sy-ucomm,

    g_wa_sflight LIKE sflight.

    DATA:go_grid TYPE REF TO cl_gui_alv_grid,

    go_custom_container TYPE REF TO cl_gui_custom_container,

    o_event_receiver TYPE REF TO lcl_event_receiver.

    CLASS lcl_event_receiver DEFINITION.

    PUBLIC SECTION.

    METHODS:

    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

    IMPORTING

    e_object e_interactive,

    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid

    IMPORTING e_ucomm.

    ENDCLASS.

    • CLASS lcl_event_receiver IMPLEMENTATION

    CLASS lcl_event_receiver IMPLEMENTATION.

    METHOD handle_toolbar.

    • Event handler method for event toolbar.

    CONSTANTS:

    • Constants for button type

    c_button_normal TYPE i VALUE 0,

    c_menu_and_default_button TYPE i VALUE 1,

    c_menu TYPE i VALUE 2,

    c_separator TYPE i VALUE 3,

    c_radio_button TYPE i VALUE 4,

    c_checkbox TYPE i VALUE 5,

    c_menu_entry TYPE i VALUE 6.

    DATA:

    ls_toolbar TYPE stb_button.

    • Append seperator to the normal toolbar

    CLEAR ls_toolbar.

    MOVE c_separator TO ls_toolbar-butn_type..

    APPEND ls_toolbar TO e_object->mt_toolbar.

    • Append a new button that to the toolbar. Use E_OBJECT of

    • event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.

    • This class has one attribute MT_TOOLBAR which is of table type

    • TTB_BUTTON. The structure is STB_BUTTON

    CLEAR ls_toolbar.

    MOVE 'REFRESH' TO ls_toolbar-function.

    MOVE icon_REFRESH TO ls_toolbar-icon.

    MOVE 'Change flight' TO ls_toolbar-quickinfo.

    MOVE 'Refresh' TO ls_toolbar-text.

    MOVE ' ' TO ls_toolbar-disabled.

    APPEND ls_toolbar TO e_object->mt_toolbar.

    ENDMETHOD.

    METHOD handle_user_command.

    • Handle own functions defined in the toolbar

    CASE e_ucomm.

    WHEN 'CHANGE'.

    • Perform Loaddata.

    CALL METHOD go_grid->refresh_table_display.

    CALL METHOD cl_gui_cfw=>flush.

    • LEAVE TO SCREEN 0.

    ENDCASE.

    ENDMETHOD.

    ENDCLASS.

    START-OF-SELECTION.

    CALL SCREEN 300.

    MODULE STATUS_0300 OUTPUT.

    • Create objects

    IF go_custom_container IS INITIAL.

    CREATE OBJECT go_custom_container

    EXPORTING container_name = 'ZCUSTOM'.

    CREATE OBJECT go_grid

    EXPORTING

    i_parent = go_custom_container.

    CREATE OBJECT o_event_receiver.

    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.

    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.

    Perform Loaddata.

    ENDIF.

    ENDMODULE. " STATUS_0300 OUTPUT

    FORM Loaddata.

    • Read data from table SFLIGHT

    SELECT * FROM sflight INTO TABLE gi_sflight.

    • Load data into the grid and display them

    CALL METHOD go_grid->set_table_for_first_display

    EXPORTING i_structure_name = 'SFLIGHT'

    CHANGING it_outtab = gi_sflight.

    CALL METHOD go_grid->set_toolbar_interactive.

    ENDFORM.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      You have mentioned 'REFRESH' in function code, but in handle_user_command you have mentioned 'CHANGE'. For obvious reasons, this would not work.

      And the link Serdar has given is very good. I use it pretty much everyday. Secondly for ALV related, especially, grid issues, there are lots of programs available.

      Check BCALVGRID* in SE38.

      Regards,

      Subramanian V.