‎2011 Nov 16 10:03 PM
Hi Experts,
I need a program or a FM that would give me the list of active batch jobs and also the time they were running
for.
Plz help me out
‎2011 Nov 16 11:02 PM
Hi,
You can query table TBTCO with the JOBNAME and status. Different status will give you details of the job. (R = running, F = Finished etc).
Regards,
‎2011 Nov 16 11:02 PM
Hi,
You can query table TBTCO with the JOBNAME and status. Different status will give you details of the job. (R = running, F = Finished etc).
Regards,
‎2011 Nov 16 11:09 PM
Use BP_JOBLIST_PROCESSOR. Its interface is identical to SM37.
‎2011 Nov 17 6:51 AM
hi,
you need to write query like this.
SELECT COUNT(*) FROM tbtco INTO l_jcnt WHERE jobname = l_jname AND status = 'R'.
IF sy-subrc EQ 0 AND l_jcnt <> 1.
WRITE:/ 'Another job running for ', p_XXX.
STOP.
ENDIF.
l_jcnt = job name.
Edited by: angel2409 on Nov 17, 2011 7:51 AM
‎2020 Mar 10 3:57 PM
I have created a test program and found working.
Many Thanks.
SELECT *
FROM tbtco
INTO TABLE @DATA(lt_tbtco)
WHERE jobname = 'ZTEST_111222'
AND status = 'R'.
DATA lv_lines TYPE i.
lv_lines = lines( lt_tbtco ) .
IF lv_lines > 1.
MESSAGE 'Background Job has already been running' TYPE 'E'.
ELSE.
WAIT UP TO 10 SECONDS.
*& Write your Logic here
ENDIF.
‎2011 Nov 17 7:08 AM
You Just follow the below code, It is exactly same as your requirement.
TYPES: BEGIN OF ty_itbl,
jobname TYPE tbtcp-jobname,
jobcount TYPE tbtcp-jobcount,
stepcount TYPE i,"tbtcp-stepcount,
sdldate TYPE tbtcp-sdldate,
sdltime TYPE tbtcp-sdltime,
sdluname TYPE tbtcp-sdluname,
status TYPE tbtco-status,
END OF ty_itbl.
DATA : wt_itbl TYPE TABLE OF ty_itbl,
wa_itbl TYPE ty_itbl.
SELECT a~jobname
a~jobcount
a~stepcount
a~sdldate
a~sdltime
a~sdluname
b~status
INTO CORRESPONDING FIELDS OF TABLE wt_itbl
FROM tbtcp AS a
INNER JOIN tbtco AS b
ON b~jobname EQ a~jobname
AND b~jobcount EQ a~jobcount
WHERE a~progname IN wp_prog
AND a~sdldate IN wp_date
AND b~status eq <STATUS>. "<-Give the Active Status here