ABAP Timers and Auto-refresh

This ABAP program will automatically update a report every 30 seconds while it is on the screen 
at the same time keeping the GUI screen buttons active.

Submitted by : SAP Basis, ABAP Programming and Other IMG Stuff
               http://www.erpgreat.com

First, create a function module in SE37 to wait 30 seconds. 

Make sure the function attribute is marked as RFC capable.
(in the Processing type section - tick Remote-enabled module)

FUNCTION Z_WAIT_30_SECS.

DATA: ZTIME LIKE SY-UZEIT.

GET TIME.

ZTIME = SY-UZEIT + 30.

DO.
  GET TIME.
  IF SY-UZEIT >= ZTIME.
     EXIT.
   ENDIF.
ENDDO.

ENDFUNCTION.

Then create this test program.

REPORT ZREFRESH LINE-SIZE 132 no standard page heading.

DATA: ZNUM LIKE SY-TABIX.

GET TIME.
WRITE: /01 'Update Number:', ZNUM, SY-UZEIT.

CALL FUNCTION 'Z_WAIT_30_SECS'
   STARTING NEW TASK 'IF'
   PERFORMING START_REFRESH ON END OF TASK.

AT USER-COMMAND.
IF SY-UCOMM = 'REFR'.

   SY-LSIND = SY-LSIND - 1.
   ADD 1 TO ZNUM.
   GET TIME.
   WRITE: /01 'Update Number:', ZNUM, SY-UZEIT.

   CALL FUNCTION 'Z_WAIT_30_SECS'
     STARTING NEW TASK 'IF'
     PERFORMING START_REFRESH ON END OF TASK.

ENDIF.

*----------------------------------------------------------------
* Program Subroutines
*----------------------------------------------------------------
FORM START_REFRESH USING TASKNAME.
* The SET USER-COMMAND initiates the communication back to the program
  SET USER-COMMAND 'REFR'.

ENDFORM.
*-- End of Program

Read Also
Simple Program that Create Internal Table Dynamically

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP ERP Modules, Basis, ABAP and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.