*** We've got a standart FM to check a BG Jobs state SUBST_GET_JOBSTATE
*** Below you can see my code
*** I've the job name MY_JOB_NAME and i am searching
*** if there is any active job still running for 2 days. if you have
*** program name then just use progname field instead of jobname.
TABLES : tbtco.
data : lt_tbtcp type table of tbtcp with header line.
data : lv_datum type sy-datum.
data : lv_message type string.
data: lv_running.
** Check For A reasonable period
lv_datum = sy-datum - 3.
CLEAR : lv_running.
select *
into corresponding fields of table lt_tbtcp
from tbtcp
where jobname eq 'MY_JOB_NAME'
and sdldate gt lv_datum.
loop at lt_tbtcp.
select single * from tbtco
where jobname = lt_tbtcp-jobname
and jobcount = lt_tbtcp-jobcount.
check sy-subrc eq 0.
if tbtco-status eq 'R'.
"JOB is running
message 'JOB is running' type 'I'.
lv_running = 'X'.
exit.
endif.
endloop.
if lv_running = 'X'.
" We have a running job with the specified parameters
endif.
No comments:
Post a Comment