Skip to Content
author's profile photo Former Member
Former Member

How can i run a sub-program within a prog. after every 2 min.

Hi All,

My prob. is i want to run a pice of code written in same prog. after every say 2 min.

like in web site when we watch cricket match it modify user screen auto after few time.

same thing i want to do in my module pool

pl. guide me.

Thanks,

Mukesh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Oct 31, 2009 at 09:05 AM

    Hi,

    You can write the code with WAIT sttement.

    WAIT UP TO 120 SECONDS

    IF sy-subrc = 0.

    Your peice of code which to be executed

    ENDIF.

    OR FM C14Z_WAIT_N_SECONDS

    OR tryw tih code simliar like this.

    DO

    check start time.

    lapsed time = current time - start time.

    if lapsed time ge 120 secs.

    [Your peice of code which to be executed]

    exit.

    ENDDO.

    ~Pramod

    Edited by: PKUPADHYAY on Oct 31, 2009 10:06 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks for the same.

      but this is not a my prob. my prob. is i have a user entry screen (Dilog Module prog.) where user is entring some thing.

      in this menu i have few fileds that filed from data base. my prob. is during data feeding these filed auto refresh their values after few time as wrote in prob.

      because thos data filed values are updating by some one else and this user want to see latest data field values.

      mukesh

  • Posted on Oct 31, 2009 at 12:52 PM

    Hi MUKESH,

    for online programs, you can make use of the cl_gui_timer object and the GUI method set_new_okcode. Search SCN for AUTOREFRESH. I don't know why there is no blog on cl_gui_timer, maybe I will create sometimes.

    Because it is easy and a good way to cheat the inactivity auto logout.

    Here is some code originally taken for autorefreshing a grid list, please adapt it to your needs:

    DATA:
      gr_gui_timer               TYPE REF TO cl_gui_timer,
      gr_event_handler           TYPE REF TO lcl_event_handler.
    FORM init_autorefresh .
      IF pa_autow IS NOT INITIAL.
        CREATE OBJECT gr_gui_timer.
    
        SET HANDLER gr_event_handler->on_finished FOR gr_gui_timer.
    
        gr_gui_timer->interval = pa_autow.
        CALL METHOD gr_gui_timer->run.
      ELSEIF gr_gui_timer IS BOUND.
        gr_gui_timer->cancel( ).
      ENDIF.
    
    ENDFORM.                    " init_autorefresh
    
    *---------------------------------------------------------------------*
    *       CLASS lcl_event_handler IMPLEMENTATION
    *---------------------------------------------------------------------*
    CLASS lcl_event_handler IMPLEMENTATION.
    
      METHOD on_finished.
    
    * Start Timer again
        gr_gui_timer->interval = pa_autow.
        CALL METHOD gr_gui_timer->run.
    
    * cause PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = gc_cmd_refresh.
    
      ENDMETHOD.                    "on_finished
    
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      take this in addition to my last post, intergrate it in your module pool.

      CONSTANTS:
        gc_cmd_refresh          TYPE sy-ucomm VALUE 'REFRESH'.
      
      *---------------------------------------------------------------------*
      *       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

      I can't post the full program due to certain limits

      Regards,

      Clemens

      P.S. If you do not try, you will never get forward.

      Edited by: Clemens Li on Oct 31, 2009 2:46 PM

  • author's profile photo Former Member
    Former Member
    Posted on Nov 16, 2009 at 04:19 AM

    thanks solved

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.