程序做好之后,用一个session专门跑这个程序,就不会因为超时挂掉了。因为它会一分钟和前台交互一次。
REPORT ztimeout.
PARAMETERS seconds TYPE i.
DATA: base TYPE i,
span TYPE i,
ms TYPE i,
text_clock TYPE string,
timer TYPE REF TO if_abap_runtime.
AT SELECTION-SCREEN.
IF seconds > 3600.
MESSAGE 'Please input seconds lower than 3600 (1 hour).' TYPE 'E'.
ENDIF.
START-OF-SELECTION.
ms = seconds * 1000 . " Maybe different in other OS, we have used win2003
timer = cl_abap_runtime=>create_lr_timer( ).
base = timer->get_runtime( ) / 1000.
DO.
DO 100 TIMES.
span = timer->get_runtime( ) / 1000 - base.
IF span > ms.
MESSAGE 'Time is up.' TYPE 'S'.
LEAVE PROGRAM.
ENDIF.
text_clock = span.
CONCATENATE 'We have spend' text_clock 'milliseconds.'
INTO text_clock SEPARATED BY ' '.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = sy-index
text = text_clock.
WAIT UP TO 60 SECONDS. " Maybe use more long waiting time
ENDDO.
ENDDO.
阅读(733) | 评论(0) | 转发(0) |