后台JOB监控(前台执行)

2022-01-10 08:13:36 浏览数 (1)

代码语言:javascript复制
REPORT zup.


*STATUS = 'R'.运行  'F' 完成  'A' 取消
DATA:message TYPE string.
DATA:BEGIN OF gt_job OCCURS 0,
       jobname  TYPE tbtcp-jobname,
       jobcount TYPE tbtcp-jobcount,
       status   TYPE tbtcp-status,
 END OF gt_job.

INCLUDE ole2incl.

DO 10000 TIMES.

 WAIT UP TO 30 SECONDS.

 IF gt_job[] IS INITIAL.
 SELECT jobname,jobcount,status INTO TABLE @DATA(lt_job)
 FROM tbtcp
 WHERE sdldate >= '20220103'
 AND status = 'R'.
 ELSE.
 SELECT jobname,status INTO TABLE @lt_job
 FROM tbtcp
 FOR ALL ENTRIES IN @gt_job
 WHERE sdldate >= '20220103'
 AND jobname = @gt_job-jobname
 .
 ENDIF.
 LOOP AT lt_job INTO DATA(ls_job).
 READ TABLE gt_job WITH KEY jobname = ls_job-jobname jobcount = ls_job-jobcount.
 IF sy-subrc EQ 0.
 IF ls_job-status NE gt_job-status.
 CASE ls_job-status.
 WHEN 'R'.
 message = '后台任务' && ls_job-jobname && '已运行'.
 WHEN 'A'.
 message = '后台任务' && ls_job-jobname && '已取消'.
 DELETE gt_job INDEX sy-tabix.
 WHEN 'F'.
 message = '后台任务' && ls_job-jobname && '已完成'.
 DELETE gt_job INDEX sy-tabix.
 WHEN OTHERS.
 ENDCASE.
 PERFORM notice_voice USING message.
 ENDIF.
 ELSE.
 APPEND ls_job TO gt_job.
 CASE ls_job-status.
 WHEN 'R'.
 message = '后台任务' && ls_job-jobname && '已启动'.
 WHEN 'A'.
 message = '后台任务' && ls_job-jobname && '已取消'.
 DELETE gt_job WHERE jobname = ls_job-jobname.
 WHEN 'F'.
 message = '后台任务' && ls_job-jobname && '已完成'.
 DELETE gt_job WHERE jobname = ls_job-jobname.
 WHEN OTHERS.
 ENDCASE.
 PERFORM notice_voice USING message.
 ENDIF.
 ENDLOOP.


ENDDO.


FORM notice_voice USING VALUE(text).
 DATA: ole   TYPE ole2_object,
        voice TYPE ole2_object.

 CREATE OBJECT voice 'SAPI.SpVoice'.

 SET PROPERTY OF voice 'Volume' = 100."音量0 -100

 SET PROPERTY OF voice 'Rate' = 1."速度 -10 - 10

 CALL METHOD OF voice 'Speak' = ole"读
 EXPORTING #1 = text.

 FREE OBJECT voice.
ENDFORM.

0 人点赞