2013 Feb 17 5:03 PM
Hi all,
I have used the system data to take the system time and displayit in my program.......but I want this clock to work and refresh when the system time change.... I try to find it through surfing the internet but I didn't found any solution....could any budy help??
Best regards,
Huda
2013 Feb 18 2:36 PM
Hi,
This code may help you...
PARAMETERS : p_time TYPE t DEFAULT 300.
*----------------------------------------------------------------------*
* CLASS my DEFINITION
*----------------------------------------------------------------------*
* Class to handle the FINSHED Event Raised by CL_GUI_TIMER
*----------------------------------------------------------------------*
CLASS my DEFINITION.
PUBLIC SECTION.
METHODS : run_handler FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "my DEFINITION
DATA timer TYPE REF TO cl_gui_timer.
DATA myh TYPE REF TO my.
*----------------------------------------------------------------------*
* CLASS my IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS my IMPLEMENTATION.
METHOD run_handler.
CALL METHOD timer->run.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFR'.
ENDMETHOD. "run_handler
ENDCLASS. "my IMPLEMENTATION
AT SELECTION-SCREEN OUTPUT.
p_time = p_time - 1.
CREATE OBJECT timer.
CREATE OBJECT myh.
timer->interval = '1'.
CALL METHOD timer->run.
SET HANDLER myh->run_handler FOR ALL INSTANCES.
2013 Feb 17 5:06 PM
i found this code but I didn't understand it ...and I don't want the big clock I want 08:02:12 refrsh it self when the system time change
http://code.google.com/p/nes-abapgames/
CONSTANTS c_pi TYPE f VALUE '3.1415926535897932'.
START-OF-SELECTION.
SET PF-STATUS 'POPU' OF PROGRAM 'SAPLSPO1'.
SET USER-COMMAND '~'.
PERFORM f_clock.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN '~'.
PERFORM f_clock.
WHEN OTHERS.
LEAVE PROGRAM.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form f_clock
*&---------------------------------------------------------------------*
FORM f_clock.
DATA: BEGIN OF e_time,
h(2) TYPE n,
m(2) TYPE n,
s(2) TYPE n,
END OF e_time.
DATA: vl_radian TYPE f,
vl_degree TYPE f,
vl_row TYPE i,
vl_col TYPE i,
vl_num(2),
vl_x TYPE i,
vl_y TYPE i.
sy-lsind = 0.
WRITE:/15 sy-uline(91).
DO 34 TIMES.
SKIP TO LINE sy-index.
WRITE:15 sy-vline,
105 sy-vline.
ENDDO.
WRITE:/15 sy-uline(91).
SKIP TO LINE 18.
WRITE AT 56 sy-uzeit.
e_time = sy-uzeit.
IF e_time-h > 12.
e_time-h = e_time-h - 12.
ENDIF.
vl_radian = c_pi / 180.
DO 12 TIMES.
vl_degree = sy-index * 360 / 12.
vl_row = 18 - ( 16 * ( cos( vl_degree * vl_radian ) ) ).
vl_col = 60 + ( 40 * ( sin( vl_degree * vl_radian ) ) ).
vl_num = sy-index.
SKIP TO LINE vl_row.
WRITE AT vl_col vl_num COLOR 1 INVERSE.
ENDDO.
DO 7 TIMES.
vl_degree = e_time-s * 360 / 60.
vl_y = 16 - ( 2 * sy-index ).
vl_x = 38 - ( 4 * sy-index ).
vl_row = 18 - ( vl_y * ( cos( vl_degree * vl_radian ) ) ).
vl_col = 60 + ( vl_x * ( sin( vl_degree * vl_radian ) ) ).
SKIP TO LINE vl_row.
WRITE AT vl_col '*' COLOR 7 INVERSE INTENSIFIED.
ENDDO.
DO 7 TIMES.
vl_degree = ( e_time-m + e_time-s / 60 ) * 360 / 60.
vl_y = 16 - ( 2 * sy-index ).
vl_x = 38 - ( 4 * sy-index ).
vl_row = 18 - ( vl_y * ( cos( vl_degree * vl_radian ) ) ).
vl_col = 60 + ( vl_x * ( sin( vl_degree * vl_radian ) ) ).
SKIP TO LINE vl_row.
WRITE AT vl_col 'O' COLOR 5 INVERSE INTENSIFIED.
ENDDO.
DO 5 TIMES.
vl_degree = ( e_time-h + e_time-m / 60 ) * 360 / 12.
vl_y = 12 - ( 2 * sy-index ).
vl_x = 30 - ( 4 * sy-index ).
vl_row = 18 - ( vl_y * ( cos( vl_degree * vl_radian ) ) ).
vl_col = 60 + ( vl_x * ( sin( vl_degree * vl_radian ) ) ).
SKIP TO LINE vl_row.
WRITE AT vl_col 'o' COLOR 4 INVERSE INTENSIFIED.
ENDDO.
PERFORM f_call_rfc_wait.
ENDFORM. "f_clock
*&---------------------------------------------------------------------*
*& Form f_call_rfc_wait
*&---------------------------------------------------------------------*
FORM f_call_rfc_wait .
CALL FUNCTION 'RFC_PING_AND_WAIT' STARTING NEW TASK '0001'
PERFORMING f_end_task ON END OF TASK
EXPORTING
seconds = 1
EXCEPTIONS
OTHERS = 1.
ENDFORM. "f_call_rfc_wait
*&---------------------------------------------------------------------*
*& Form f_end_task
*&---------------------------------------------------------------------*
* -->P_TASKNAME text
*----------------------------------------------------------------------*
FORM f_end_task USING p_taskname.
SET USER-COMMAND '~'.
ENDFORM. "f_end_task
Message was edited by: huda basloom the Code
2013 Feb 18 5:12 AM
Please see whether this sample code helps and gives you any option.
REPORT ZTEST_GK1.
PARAMETERS : p_time type syuzeit DEFAULT sy-uzeit.
*Class to handle the FINSHED Event Raised by CL_GUI_TIMER
CLASS my DEFINITION.
PUBLIC SECTION.
METHODS : run_handler FOR EVENT finished OF cl_gui_timer.
ENDCLASS.
DATA timer TYPE REF TO cl_gui_timer.
DATA myh TYPE REF TO my.
CLASS my IMPLEMENTATION.
METHOD run_handler.
CALL METHOD timer->run.
call method CL_GUI_CFW=>SET_NEW_OK_CODE
EXPORTING
new_code = 'REFR'.
ENDMETHOD.
ENDCLASS.
at SELECTION-SCREEN OUTPUT.
p_time = sy-uzeit.
CREATE OBJECT timer.
CREATE OBJECT myh.
timer->interval = '0.5'.
CALL METHOD timer->run.
SET HANDLER myh->run_handler FOR ALL INSTANCES.
Regards,
Gokul
2013 Feb 17 5:09 PM
2013 Feb 17 5:49 PM
I do use SY-UZEIT. what I mean is that I want it refresh it self while the program is running
Thank you
2013 Feb 17 6:05 PM
2013 Feb 17 6:15 PM
I read about it ....what I understand that it will refresh the whole fram so the other fields will refresh and I woudent be able to enter the user name and Id ..........
2013 Feb 17 6:38 PM
2013 Feb 18 3:25 AM
Hi Huda,
You might need to say a bit more about exactly where you plan on using this clock.
The problem with an abap-based solution is that any event or trigger which you use to update the time that is getting displayed will result in the server being hit. This is terribly inefficient.
What you really want to do is transfer this processing to the client and as such you could consider using a BSP, or Flash/HTML island or using a Web Dynpro with an iframe, and load a javascript clock mime object as the source of the iframe. Depending on what technology is available to you with your version of SAP.
Cheers
Alex
2013 Feb 18 2:36 PM
Hi,
This code may help you...
PARAMETERS : p_time TYPE t DEFAULT 300.
*----------------------------------------------------------------------*
* CLASS my DEFINITION
*----------------------------------------------------------------------*
* Class to handle the FINSHED Event Raised by CL_GUI_TIMER
*----------------------------------------------------------------------*
CLASS my DEFINITION.
PUBLIC SECTION.
METHODS : run_handler FOR EVENT finished OF cl_gui_timer.
ENDCLASS. "my DEFINITION
DATA timer TYPE REF TO cl_gui_timer.
DATA myh TYPE REF TO my.
*----------------------------------------------------------------------*
* CLASS my IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS my IMPLEMENTATION.
METHOD run_handler.
CALL METHOD timer->run.
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFR'.
ENDMETHOD. "run_handler
ENDCLASS. "my IMPLEMENTATION
AT SELECTION-SCREEN OUTPUT.
p_time = p_time - 1.
CREATE OBJECT timer.
CREATE OBJECT myh.
timer->interval = '1'.
CALL METHOD timer->run.
SET HANDLER myh->run_handler FOR ALL INSTANCES.
2013 Feb 18 6:37 PM