Skip to Content
avatar image
-1
Former Member

How to Avoid same background job running twice

Dear Friends,

Can anybody tell how to avoid same job running twice at the same time. I made a report that is supposed to be run in background. But the report should run per job and new job only starts when there is no other active job is running. Please help in this regards.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Apr 27, 2017 at 11:40 AM

    Usually I add a first step with a program that checks for other instance of the background job currently running.

    * Current job information
      call function 'GET_JOB_RUNTIME_INFO'
        importing
          jobcount = gv_jobcount
          jobname  = gv_jobname
        exceptions
          others   = 0.
    * Don't allow concurrent run
      select single tbtco~jobname into gv_job
        from tbtco
        where jobname EQ gv_jobname
          and jobcount ne gv_jobcount " me
          and status = 'R'.
      if sy-subrc eq 0. " message in log and exit job

    You can also rely on some program name instead of job name, join tbtco with tbtcp.

    Another solution was to rely on some locking, but could be broken by some commit.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 27, 2017 at 11:21 AM

    Hi Ijaz

    try to set up the job with daily , weekly ... usually the time run report will not exceed one day.

    then it will not conflict

    Thanks,

    John

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 27, 2017 at 11:36 AM

    Hi!

    Also you can try to get job status by calling FM BP_JOB_SELECT_SM37B.

    Evgeny

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 28, 2017 at 07:42 AM

    Hi Ijaz,

    The report RSBTONEJOB2 can serve your purpose. This report is to ensure that only one instance of a job is running.

    Thanks

    Add comment
    10|10000 characters needed characters exceeded