‎2010 Dec 08 9:56 AM
My Programm reads data from external csv files and displays the data to import as cl_salv_table. The user can then select the lines of data to import and and press an "import" button. Now IDocs are generated to actually do the import. Data of the table should now be regularly refreshed with the IDoc Number and Status. This works manually when i implement a "refresh" button. However using a timer event only updates the data in the internal table but the gui is not refreshed (i call the same function to actually perform the refresh).
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column,
on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function,
handle_timer FOR EVENT finished OF cl_gui_timer.
ENDCLASS.
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
CASE column.
WHEN 'MATNR'.
"PERFORM show_matnr USING row column.
ENDCASE.
ENDMETHOD.
METHOD on_user_command.
CASE e_salv_function.
WHEN '&IMPORT'.
PERFORM import USING pa_ls.
WHEN '&REFRESHG'.
PERFORM update_idocnr USING pa_ls
g_currentsystem
g_credat
g_cretim.
WHEN '&TEST'.
PERFORM update.
ENDCASE.
ENDMETHOD.
METHOD handle_timer.
gr_timer->run( ).
PERFORM update_idocnr USING pa_ls
g_currentsystem
g_credat
g_cretim.
cl_gui_cfw=>flush( ).
ENDMETHOD.
ENDCLASS.
.......
*-----Events
gr_events_table = gr_table->get_event( ).
CREATE OBJECT gr_events.
SET HANDLER gr_events->on_link_click FOR gr_events_table.
SET HANDLER gr_events->on_user_command FOR gr_events_table.
*-----Timer für Refresh Grid
CREATE OBJECT gr_timer.
SET HANDLER gr_events->handle_timer FOR gr_timer.
gr_timer->interval = 10.
gr_timer->run( ).
......
*---- Function to update internal table.
FORM update_idocnr USING i_sndprn TYPE edi_sndprn
i_rcvprn TYPE edi_rcvprn
i_credat TYPE edi_ccrdat
i_cretim TYPE edi_ccrtim.
TYPES: ty_edidd TYPE STANDARD TABLE OF edid4 WITH DEFAULT KEY.
TYPES: BEGIN OF ty_edidata,
docnum TYPE edi_docnum,
status TYPE edi_status,
edidd TYPE ty_edidd,
END OF ty_edidata.
DATA: lit_idocs_edidd TYPE STANDARD TABLE OF ty_edidata.
DATA: lst_e1mastm TYPE e1mastm.
DATA: l_found TYPE sap_bool VALUE false.
DATA: l_lines TYPE sy-tabix.
DATA: lr_selections TYPE REF TO cl_salv_selections,
lt_rows TYPE salv_t_row.
FIELD-SYMBOLS: <fs_edidd_data> TYPE edid4,
<fs_edidd> TYPE ty_edidata,
<fs_rows> TYPE LINE OF salv_t_row.
*----- Selektion der erstellten IDOC´s in interne Tabelle
SELECT docnum status FROM edidc INTO CORRESPONDING FIELDS OF TABLE lit_idocs_edidd
WHERE sndprn = i_sndprn AND rcvprn = i_rcvprn AND mestyp = k_mestyp
AND idoctp = k_idoctyp AND credat >= i_credat AND cretim >= i_cretim.
LOOP AT lit_idocs_edidd ASSIGNING <fs_edidd>.
SELECT * FROM edid4 INTO TABLE <fs_edidd>-edidd
WHERE docnum = <fs_edidd>-docnum.
ENDLOOP.
*----- Anzeige Tabelle durchgehen und prüfen ob IDocNr vorhanden
lr_selections = gr_table->get_selections( ).
*-----Markierte Zeilen
lt_rows = lr_selections->get_selected_rows( ).
DESCRIBE TABLE lt_rows LINES l_lines.
IF l_lines GT 0.
LOOP AT lt_rows ASSIGNING <fs_rows>.
READ TABLE git_displaydata ASSIGNING <fs_displaydata> INDEX <fs_rows>.
l_found = false.
LOOP AT lit_idocs_edidd ASSIGNING <fs_edidd>.
LOOP AT <fs_edidd>-edidd ASSIGNING <fs_edidd_data>.
IF <fs_edidd_data>-segnam = 'E1MASTM'.
MOVE <fs_edidd_data>-sdata TO lst_e1mastm.
IF lst_e1mastm-matnr = <fs_displaydata>-matnr AND
lst_e1mastm-werks = <fs_displaydata>-werks AND
lst_e1mastm-stlan = <fs_displaydata>-stlan AND
lst_e1mastm-stlal = <fs_displaydata>-stlal.
*----- Passendes IDoc gefunden
<fs_displaydata>-idocnr = <fs_edidd>-docnum.
<fs_displaydata>-idocst = <fs_edidd>-status.
IF <fs_displaydata>-idocst = 41.
<fs_displaydata>-status = icon_green_light.
ELSE.
<fs_displaydata>-status = icon_red_light.
ENDIF.
l_found = true.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDIF.
gr_table->refresh( refresh_mode = if_salv_c_refresh=>full ).
ENDFORM.
‎2010 Dec 13 6:00 AM
I could solve the problem by simulating the keypress on the refresh button.
METHOD handle_timer.
gr_timer->run( ).
cl_gui_cfw=>set_new_ok_code( new_code = '&REFRESHG' ).
ENDMETHOD. "handle_timer
‎2010 Dec 11 10:37 PM
The timer event calls a different method. The manual method uses UPDATE.
Check in debugger.
Regards,
Clemens
‎2010 Dec 13 5:58 AM
What do you mean with "different" methods. In debugger, everything looks fine. The underlying data table is updated in both cases, but the refresh doesn´t work when called from within in timer event.
‎2010 Dec 13 6:00 AM
I could solve the problem by simulating the keypress on the refresh button.
METHOD handle_timer.
gr_timer->run( ).
cl_gui_cfw=>set_new_ok_code( new_code = '&REFRESHG' ).
ENDMETHOD. "handle_timer