2008 Jul 01 11:50 AM
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
2008 Jul 01 12:05 PM
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
2008 Jul 01 12:05 PM
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
2008 Jul 01 12:13 PM
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.
2008 Jul 01 12:22 PM
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.