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 manual refreshing.

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.
      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 last published in November 2002

Dig Deeper on SAP ABAP

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close