Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

program or function module to get active Batch jobs

Former Member
0 Likes
3,819

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,100

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,

5 REPLIES 5
Read only

Former Member
0 Likes
2,101

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,

Read only

Former Member
0 Likes
2,100

Use BP_JOBLIST_PROCESSOR. Its interface is identical to SM37.

Read only

Former Member
0 Likes
2,100

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

Read only

0 Likes
2,100

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.

Read only

surajarafath
Contributor
0 Likes
2,100

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