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

how to check background job is active

Active Contributor
0 Kudos

Dear Experts,

I have created a Z program which  schedules a standard program(say SAPREPORT) in background via Job_open, submit program, Job_close. I am reading the table tbtco with jobname and status 'R' to identify if the standard job scheduled in background via submit statement is running or not.

This program works fine if I execute the the Z program in foreground but I need to schedule this as well in background. When I schedule the z program as batch job it is not able to find any entry (sy-subrc = 4) in tbtco table with status R and thus schedules the standard program job again. I am not sure why the program is unable to read the tbtco entry when run as background, I can see the entry when I check thought se11.

The idea is to prevent the standard program from being run in parallel. Please help as how this can be achieved. Thanks.


Active Participant
0 Kudos

Hi Srinivas,

You can make alternatively make use of the SAP Standard Function Module : BP_JOB_SELECT

which will get all the Background Jobs for you.

This is also used in the Standard T-Code : SMX, so you can trust that it works.



0 Kudos

Hi Shyam,

Unfortunately it doesn't seem to work. If i execute the fm and check directly it returns the running jobs but when same is done via z program which itself is running as background job it does not find any running instance for the standard job which has been scheduled. All these standard FM seem to get the value if the z program is run in foreground. Any other solution? Thanks

Additionally I have also tried the FM BP_FIND_JOBS_WITH_PROGRAM and direct select from tbtco.

An interesting thing to note is the z program which is scheduled as background job keeps waiting (delay increases) till the standard scheduled program job has completed.

     jobselect_dialog          = 'N'
    JOBSEL_PARAM_IN           = l_jselect
*   ENDDATE                   = '        '
*   ENDTIME                   = '      '
    SELECTION                 = 'AL'
*   ADK_MODE                  = ' '
    JOBSEL_PARAM_OUT          = l_jselect
*   LOCAL_CLIENT              =
    NR_OF_JOBS_FOUND          = count
     jobselect_joblist         = l_joblist
*   JOBNAME_EXT_SEL           =
*   USERNAME_EXT_SEL          =
*   ERROR_CODE                =
    JOBNAME_MISSING           = 2
    NO_JOBS_FOUND             = 3
    USERNAME_MISSING          = 5
    OTHERS                    = 6

0 Kudos


    Try to schedule your program with the following function modules in sequence.

1) Call function module JOB_OPEN.

2) Use SUBMIT statement and submit your current report.

3) Call function module JOB_CLOSE.

4) Use function module BP_JOB_READ in DO and ENDDO loop to get the job details.

Please find the sample code in the attachment.

Thanks & Regards

Bala Krishna

0 Kudos


Check the system variable SY-BATCH.