Tip

Auto refresh a report and get real-time data

The following example should give an idea about how you can get real-time data every 10 seconds without refreshing the report manually. Here is a small example of Spfli showing time at the beginning. The users can modify the report according to their needs. The code for both the report and the function module is given below.
The code was written in 4.6c and should also work in 3.1h and 4.0b.


REPORT ZAUTO_REFRESH .
DATA: G_INIT_ONCE,
      OK_CODE(20),
      G_REF_FROM_TIMER.

DATA: BEGIN OF ITAB OCCURS 0,
        CARRID TYPE SPFLI-CARRID,
        CONNID TYPE SPFLI-CONNID,
        COUNTRYFR TYPE SPFLI-COUNTRYFR,
        CITYFROM TYPE SPFLI-CITYFROM,
        AIRPFROM TYPE SPFLI-AIRPFROM,
        COUNTRYTO TYPE SPFLI-COUNTRYTO,
        CITYTO TYPE SPFLI-CITYTO,
        AIRPTO TYPE SPFLI-AIRPTO,
        FLTIME TYPE SPFLI-FLTIME,
        DEPTIME TYPE SPFLI-DEPTIME,
        ARRTIME TYPE SPFLI-ARRTIME,
        DISTANCE TYPE SPFLI-DISTANCE,
        DISTID TYPE SPFLI-DISTID,
        FLTYPE TYPE SPFLI-FLTYPE,
        PERIOD TYPE SPFLI-PERIOD,
      END OF ITAB.


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 * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE ITAB.
      WRITE:/ SY-UZEIT.
      LOOP AT ITAB.
        WRITE:/ ITAB-CARRID,ITAB-CONNID.

    Requires Free Membership to View

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 * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> TASKNAME * *---------------------------------------------------------------------* 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. " WHEN_FINISHED ************************************************************************* Function Module for refreshing the report (in SE37) FUNCTION Z_ENQUE_SLEEP. *"---------------------------------------------------------------------- *"*"Local interface: *"---------------------------------------------------------------------- CALL FUNCTION 'ENQUE_SLEEP' EXPORTING SECONDS = 10. ENDFUNCTION.

This was first published in November 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.