2011 Nov 23 12:38 PM
Hi Guys,
I want to schedule a job in sm36 with a set step and variant..the easy part
However I want this job to repeat it self as soon as it finshes or have a 60second delay (not required) but it needs to be in an endless loop or for a set period of time/days
Monday to Friday etc
I could set the job to repeat it self every set amount of time, but I need to guarantee that the above job has completed before the next one starts.
ECC 6 701 patch 7
Sorry if this is posted elsewhere but I could not find it!
2011 Nov 24 3:51 PM
Periodic-event job
- Create a customer event in the system - Transaction SM64
- Create your job periodic-event on this event
- Add a last step with report [BTC_EVENT_RAISE|https://service.sap.com/sap/support/notes/919458] and a variant that raises your event
Now raise once the event calling report BTC_EVENT_RAISE or FM BP_EVENT_RAISE or method cl_batch_event=>raise...
Periodic job
Create a Z-program wrapper which
- call FM GET_JOB_RUNTIME_INFO to get its own job name
- call FM like BP_JOBLIST_PROCESSOR or select from TBTCO to get current status of job with this name (or other criteria)
- If already two jobs running (another and this one) -> exit
- else submit the required report
Create a periodic job with the wrapper
Regards,
Raymond
2011 Nov 23 12:45 PM
Try raising an event SAP_END_OF_JOB with the jobname as parameter at the end of execution and schedule the job to wait for this same event and parameter.
You could add the necessary code to a Z-program or - if it is a standard SAP program - schedule a second job step for this purpose.
You'll have to raise the event manually via SM62 once to get the ball rollin'...
Thomas
P.S. did not think of the "for a set period of days" part yet...
P.P.S. such things highlight the limitations of the standard SAP job scheduling, and are often solved by external scheduling tools
Edited by: Thomas Zloch on Nov 23, 2011 1:47 PM
2011 Nov 23 12:48 PM
Thanks Thomas
I was just looking at events as a possible work around - I will follow you helpful tip and report back
2011 Nov 23 1:22 PM
Hi Thomas
Cant seem to get the job to repeat it self, but I can get the job to run
Any ideas?
2011 Nov 24 3:33 PM
How are you raising the event? Did you schedule the job as "periodic"?
Thomas
2011 Nov 24 3:51 PM
Periodic-event job
- Create a customer event in the system - Transaction SM64
- Create your job periodic-event on this event
- Add a last step with report [BTC_EVENT_RAISE|https://service.sap.com/sap/support/notes/919458] and a variant that raises your event
Now raise once the event calling report BTC_EVENT_RAISE or FM BP_EVENT_RAISE or method cl_batch_event=>raise...
Periodic job
Create a Z-program wrapper which
- call FM GET_JOB_RUNTIME_INFO to get its own job name
- call FM like BP_JOBLIST_PROCESSOR or select from TBTCO to get current status of job with this name (or other criteria)
- If already two jobs running (another and this one) -> exit
- else submit the required report
Create a periodic job with the wrapper
Regards,
Raymond
2011 Nov 25 8:52 AM
Check if is convenient for you to make 2 copies for the same Job and to set the start condition after job
in each one the job name of the other.
Afer that just schedule immediately a job to run immediately with name the name of the first job
2011 Nov 25 9:24 AM
Well as a suggestion. To achieve this why dont u creafe a report for that.
1. First step u create a job. and store this job info in custom table along with the jobcount.
2. in the code itself add 2 more logics,
one to again recall the program after may be 5 seconds,
second make a if statement if job status fetched from custom table is finshed, then schedule the next job. i guess this is easy.
I hav implemented the same logic in my code also. and its working fine