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

Background job scheduling

Former Member
0 Likes
708

Hi Gurus,

I have a program which is Job scheduled for every 15 minutes.

This in turn will update some transaction.

The requirement for me is when a job is running in background and if it is taking more than 15 mins than another job which is scheduled every 15 mins will get started.

In this case I have to check if any previous scheduled job is still running or not. If it is running than I should leave the program leaving or cancelling the new scheduled job and let the previous running. If there is no previous job running then the new scheduled job should run.This goes on for the next scheduled job also. This is applicable for all the ongoing shceduled jobs.

Can anyone tell me what coding needs to be done (with code) for the problem I am facing.

Regards,

Mac

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
677

CALL FUNCTION 'BP_FIND_JOBS_WITH_PROGRAM'

EXPORTING

ABAP_PROGRAM_NAME = '<your report name here>'

STATUS = 'R'

TABLES

JOBLIST = t_joblist.

Now check the number of lines of table t_joblist. If more than one line in the table, then your prog is still running in the background and you know you have to exit the program.

Hope this helps,

Rolf

Hi Gurus,

I have a program which is Job scheduled for every 15 minutes.

This in turn will update some transaction.

The requirement for me is when a job is running in background and if it is taking more than 15 mins than another job which is scheduled every 15 mins will get started.

In this case I have to check if any previous scheduled job is still running or not. If it is running than I should leave the program leaving or cancelling the new scheduled job and let the previous running. If there is no previous job running then the new scheduled job should run.This goes on for the next scheduled job also. This is applicable for all the ongoing shceduled jobs.

Can anyone tell me what coding needs to be done (with code) for the problem I am facing.

Regards,

Mac

3 REPLIES 3
Read only

Former Member
0 Likes
678

CALL FUNCTION 'BP_FIND_JOBS_WITH_PROGRAM'

EXPORTING

ABAP_PROGRAM_NAME = '<your report name here>'

STATUS = 'R'

TABLES

JOBLIST = t_joblist.

Now check the number of lines of table t_joblist. If more than one line in the table, then your prog is still running in the background and you know you have to exit the program.

Hope this helps,

Rolf

Read only

former_member784222
Active Participant
0 Likes
677

Hi,

In the start condition of a job, you have option to name a predecessor job after which your job has to run.

Have 2 jobs having the same steps and in start condition of job 1 give the name of job2 and in start condition of job2 give job 1.

Hope this solves your problem.

regards,

Mouli.

Read only

Former Member
0 Likes
677

Hi

If u know the background job name, in program you can check whether that particular job is running or not by checking in TBTCO table passing job name and status as 'R' and if record found exit.

sample code:

SELECT jobcount INTO TABLE tb_jobcount

FROM tbtco

WHERE jobname = <wf_job_name>

AND status EQ 'R'.

IF sy-subrc = 0.

CLEAR wf_jobs.

DESCRIBE TABLE tb_jobcount LINES wf_jobs.

IF wf_jobs > 1.

EXIT.

ENDIF.

ENDIF.