Monday, April 4, 2011

Automatic refresh report

*&---------------------------------------------------------------------*
*& Report  ZAUTO_REFRESH_TEST
*& developed by: Salah Uddin
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZAUTO_REFRESH_TEST.
DATA: g_init_once,
      ok_code(20),
      g_ref_from_timer.

TYPES: BEGIN OF t_vbak,
  vbeln TYPE vbak-vbeln,
  erdat TYPE vbak-erdat,

 END OF t_vbak.

DATA: it_vbak TYPE STANDARD TABLE OF t_vbak INITIAL SIZE 0,
      wa_vbak TYPE t_vbak.


IF g_init_once <> 'X'.
  g_init_once = 'X'.
  CALL FUNCTION 'Z_ENQUE_SLEEP'
     STARTING NEW TASK 'WAIT'
     PERFORMING when_finished ON END OF TASK.

ENDIF.

WRITE:/ 'wait for 10 sec....'.

AT USER-COMMAND.
  CASE ok_code.
    WHEN 'FCT_R'.
      SELECT vbeln erdat
       UP TO 10 ROWS
        FROM vbak
        INTO TABLE it_vbak.
      WRITE:/ sy-uzeit. "Time
      LOOP AT it_vbak INTO wa_vbak.
        WRITE:/ wa_vbak-vbeln, wa_vbak-vbeln.
      ENDLOOP.
      sy-lsind = 0.
      IF g_ref_from_timer = 'X'.

        CALL FUNCTION 'Z_ENQUE_SLEEP'
          STARTING NEW TASK 'INFO'
          PERFORMING when_finished ON END OF TASK.

        g_ref_from_timer = ''.
      ENDIF.
  ENDCASE.


  FORM when_finished USING taskname.
  RECEIVE RESULTS FROM FUNCTION 'Z_ENQUE_SLEEP'.

  g_ref_from_timer = 'X'.

* Trigger an event to run the at user-command
  SET USER-COMMAND 'FCT_R'.
  ok_code = 'FCT_R'.
  sy-ucomm = 'FCT_R'.

ENDFORM.                 

No comments:

Post a Comment