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.
cancel
Showing results for 
Search instead for 
Did you mean: 

Background jobs in SAP

eamonn_osullivan
Explorer
0 Kudos
464

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!

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos
165

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

7 REPLIES 7

ThomasZloch
Active Contributor
0 Kudos
165

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

0 Kudos
165

Thanks Thomas

I was just looking at events as a possible work around - I will follow you helpful tip and report back

0 Kudos
165

Hi Thomas

Cant seem to get the job to repeat it self, but I can get the job to run

Any ideas?

0 Kudos
165

How are you raising the event? Did you schedule the job as "periodic"?

Thomas

raymond_giuseppi
Active Contributor
0 Kudos
166

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

Former Member
0 Kudos
165

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

Former Member
0 Kudos
165

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