<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: problem with automatic ALV refresh in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886022#M371626</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are on release 4.7 or better, then implement this program.  It will show how to do an automatic refresh for ALV grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please copy and paste this code and run it, every 3 seconds a new record will be written to the ALV Grid.  Again, this assumes that the class CL_GUI_TIMER exists in your system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


REPORT zrich_0002.

TYPE-POOLS : slis.

DATA: BEGIN OF itab OCCURS 0,
      fld1 TYPE i,
      fld2 TYPE i,
      END OF itab.


*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.

ENDCLASS.                    "lcl_event_handler DEFINITION


DATA: gui_timer TYPE REF TO cl_gui_timer.
DATA: event_handler TYPE REF TO lcl_event_handler.
DATA: timeout TYPE i VALUE '3'.


START-OF-SELECTION.

  CREATE OBJECT gui_timer.

  SET HANDLER event_handler-&amp;gt;on_finished FOR gui_timer.

  gui_timer-&amp;gt;interval = timeout.
  CALL METHOD gui_timer-&amp;gt;run.

  PERFORM write_list.

*----------------------------------------------------
* FORM  alv_user_command
*----------------------------------------------------
FORM alv_user_command USING r_ucomm  TYPE sy-ucomm
                             rs_selfield  TYPE slis_selfield.

  PERFORM read_data.
  rs_selfield-refresh = 'X'.

ENDFORM.                    "alv_user_command

*----------------------------------------------------
* FORM  write_list
*----------------------------------------------------
FORM write_list.

  DATA: fieldcat TYPE slis_t_fieldcat_alv.
  DATA: repid TYPE sy-repid.

  repid = sy-repid.

  PERFORM read_data.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = repid
      i_internal_tabname     = 'ITAB'
      i_inclname             = repid
    CHANGING
      ct_fieldcat            = fieldcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      it_fieldcat             = fieldcat
      i_callback_program      = repid
      i_callback_user_command = 'ALV_USER_COMMAND'
    TABLES
      t_outtab                = itab
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.


ENDFORM.                    "write_list

*---------------------------------------------------------------------*
*       FORM read_data                                                *
*---------------------------------------------------------------------*
FORM read_data.

* Use your own database table here.
  itab-fld1 = itab-fld1 + 1.
  itab-fld2 = itab-fld2 + 1.
  APPEND itab.

ENDFORM.                    "read_data

*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.

  METHOD on_finished.

* Start Timer again
    gui_timer-&amp;gt;interval = timeout.
    CALL METHOD gui_timer-&amp;gt;run.

* cause PAI
    CALL METHOD cl_gui_cfw=&amp;gt;set_new_ok_code
      EXPORTING
        new_code = 'REFR'.

  ENDMETHOD.                    "on_finished

ENDCLASS.                    "lcl_event_handler IMPLEMENTATION

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Feb 2007 18:46:37 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2007-02-01T18:46:37Z</dc:date>
    <item>
      <title>problem with automatic ALV refresh</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886021#M371625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been reading the forums for automatic alv refresh.&lt;/P&gt;&lt;P&gt;Still, i couldnt get my alv refreshed automatically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen the blog of Rich H for automatic timer. &lt;/P&gt;&lt;P&gt;Can u guys just explain it with a small example ( just started learning oops concept).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Feb 2007 18:35:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886021#M371625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-01T18:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: problem with automatic ALV refresh</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886022#M371626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are on release 4.7 or better, then implement this program.  It will show how to do an automatic refresh for ALV grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please copy and paste this code and run it, every 3 seconds a new record will be written to the ALV Grid.  Again, this assumes that the class CL_GUI_TIMER exists in your system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


REPORT zrich_0002.

TYPE-POOLS : slis.

DATA: BEGIN OF itab OCCURS 0,
      fld1 TYPE i,
      fld2 TYPE i,
      END OF itab.


*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS: on_finished FOR EVENT finished OF cl_gui_timer.

ENDCLASS.                    "lcl_event_handler DEFINITION


DATA: gui_timer TYPE REF TO cl_gui_timer.
DATA: event_handler TYPE REF TO lcl_event_handler.
DATA: timeout TYPE i VALUE '3'.


START-OF-SELECTION.

  CREATE OBJECT gui_timer.

  SET HANDLER event_handler-&amp;gt;on_finished FOR gui_timer.

  gui_timer-&amp;gt;interval = timeout.
  CALL METHOD gui_timer-&amp;gt;run.

  PERFORM write_list.

*----------------------------------------------------
* FORM  alv_user_command
*----------------------------------------------------
FORM alv_user_command USING r_ucomm  TYPE sy-ucomm
                             rs_selfield  TYPE slis_selfield.

  PERFORM read_data.
  rs_selfield-refresh = 'X'.

ENDFORM.                    "alv_user_command

*----------------------------------------------------
* FORM  write_list
*----------------------------------------------------
FORM write_list.

  DATA: fieldcat TYPE slis_t_fieldcat_alv.
  DATA: repid TYPE sy-repid.

  repid = sy-repid.

  PERFORM read_data.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = repid
      i_internal_tabname     = 'ITAB'
      i_inclname             = repid
    CHANGING
      ct_fieldcat            = fieldcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      it_fieldcat             = fieldcat
      i_callback_program      = repid
      i_callback_user_command = 'ALV_USER_COMMAND'
    TABLES
      t_outtab                = itab
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.


ENDFORM.                    "write_list

*---------------------------------------------------------------------*
*       FORM read_data                                                *
*---------------------------------------------------------------------*
FORM read_data.

* Use your own database table here.
  itab-fld1 = itab-fld1 + 1.
  itab-fld2 = itab-fld2 + 1.
  APPEND itab.

ENDFORM.                    "read_data

*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.

  METHOD on_finished.

* Start Timer again
    gui_timer-&amp;gt;interval = timeout.
    CALL METHOD gui_timer-&amp;gt;run.

* cause PAI
    CALL METHOD cl_gui_cfw=&amp;gt;set_new_ok_code
      EXPORTING
        new_code = 'REFR'.

  ENDMETHOD.                    "on_finished

ENDCLASS.                    "lcl_event_handler IMPLEMENTATION

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REgards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Feb 2007 18:46:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886022#M371626</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2007-02-01T18:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: problem with automatic ALV refresh</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886023#M371627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;See this link, the 12 point explaines with code ..&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.erpgenie.com/abap/controls/alvgrid.htm#Refresh%20grid%20display" target="test_blank"&gt;http://www.erpgenie.com/abap/controls/alvgrid.htm#Refresh%20grid%20display&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the below links for examples&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/how-to-refresh-alv-list-grid-once-it-is-displayed.htm" target="test_blank"&gt;http://www.sap-img.com/abap/how-to-refresh-alv-list-grid-once-it-is-displayed.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2919498"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Feb 2007 18:49:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886023#M371627</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-01T18:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: problem with automatic ALV refresh</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886024#M371628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for helping me guys....&lt;/P&gt;&lt;P&gt;the code worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again...........&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2007 11:57:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-automatic-alv-refresh/m-p/1886024#M371628</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-02T11:57:07Z</dc:date>
    </item>
  </channel>
</rss>

