Friday, November 23, 2007

sap ABAP program for 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


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

No comments:

Blog Archive