Code: Alles auswählen.
REPORT ytest_timer_test.
DATA: timer TYPE REF TO CL_GUI_TIMER.
data: timeout_interval type i value '3'.
data dtime type tims.
DATA val TYPE char10.
DATA valint TYPE d.
*----------------------------------------------------------------------*
* VARIABLES *
*----------------------------------------------------------------------*
DATA: okcode TYPE sy-ucomm.
*---------------------------------------------------------------------*
* CLASS lcl_application DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_application definition.
public section.
methods:
time_out
for event FINISHED
of CL_GUI_TIMER.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_application IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_application implementation.
method time_out.
****Resond to the double click on an item in the ALV Grid -
****Start Playing the song that the user selected.
data rc type i.
break bcuser.
* Start Timer again
timer->interval = timeout_interval.
call method timer->run.
* cause PAI
* call method cl_gui_cfw=>set_new_ok_code
* exporting
* new_code = 'REFR'.
****Trigger an OK_Code - This will cause the PBO/PAI to
****fire. Otherwise the title bar doesn't get updated.
* call method cl_gui_cfw=>set_new_ok_code
* exporting new_code = 'ENT'
* importing rc = rc.
endmethod.
endclass.
data: g_application type ref to lcl_application.
START-OF-SELECTION.
dtime = sy-uzeit.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'S1'.
* SET TITLEBAR 'xxx'.
IF timer IS INITIAL.
****Create the local event callback class
if g_application is initial.
create object g_application.
endif.
CREATE OBJECT timer.
timer->interval = timeout_interval.
****Set Event handler for Timer
set handler g_application->time_out for timer.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE okcode.
WHEN 'RUN'.
CALL METHOD timer->run
EXCEPTIONS
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.
WHEN 'BCK'.
IF NOT timer IS INITIAL.
CALL METHOD timer->free.
FREE timer.
ENDIF.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT