cancel
Showing results for 
Search instead for 
Did you mean: 

Recurring background job

Former Member
0 Kudos

Hi,

I have a requirement of executing a standard report program in background forever. Meaning as soon as the first execution of background job is over, another execution of same program should start and this should go on and on. I could not find any option to achieve this using SM36.

Is there any way of achieving this?

Accepted Solutions (1)

Accepted Solutions (1)

Juwin
Active Contributor
0 Kudos

You use SAP events to do this.

Further read: Scheduling background job by triggering an event - ABAP Development - SCN Wiki for more information.

How to do this:

Create a custom event in SM62.

Create a background job in SM36, with 1st step as the required program and 2nd step as BTC_EVENT_RAISE.

Release the background job, as a periodic job, with a start condition dependent on event created in SM62.

Run BTC_EVENT_RAISE once manually, giving the event name.

The manual execution will trigger the event, which will activate the job. When the 2nd step of the job runs, it will trigger the event again, causing the job to be activated again.... and so on.

Thanks, Juwin

Former Member
0 Kudos

Hi Juwin,

Thanks for the solution. This is exactly what I needed but I am facing an issue now.

The job is running forever now. One execution after another. How do I stop it? It seems uncontrolled.

PeterJonker
Active Contributor
0 Kudos

Isn't that exactly what you wanted ? You said:

"as the first execution of background job is over, another execution of same program should start and this should go on and on"

Well that is what is happening now.

You can stop it by selecting the active job and choose abort/stop active job from the menu

Former Member
0 Kudos

Hi Peter,

This is what I wanted but the job execution is uncontrolled for me now. I can not abort/stop active job now as the job is taking less than a second to execute. As a result by the time I select active job and click on stop, the job execution is already over.

Patrick_vN
Active Contributor
0 Kudos

You may be able to delete the event?

PeterJonker
Active Contributor
0 Kudos

Hi Sagar,

I think Patrick suggestion to delete the event is the best solution.

You better change your job by having the 2nd step as a custom program. In there you can add a statement wait for 20 seconds (or whatever time you choose) before raising the event.

You then will have the option to stop the active job.

Juwin
Active Contributor
0 Kudos

Search for the "Released" job in SM37, without giving any start or end times. You will find only one with that name. Select that job and choose menu option Released->Scheduled. This will stop the job.

Thanks,

Juwin

Former Member
0 Kudos

Hi Patrick and Peter,

Deleting the event is not an option. While deleting it says 'the event is used in a job'.

raymond_giuseppi
Active Contributor
0 Kudos

Change the variant used in the BTC_EVENT_RAISE step, so it will raise another dummy event.

Regards,

Raymond

Juwin
Active Contributor
0 Kudos

I have already given you the answer for this down below. Have you tried that yet?

Thanks, Juwin

Answers (2)

Answers (2)

Former Member
0 Kudos

Also just to add : if you dont want any custom logic to be built, you can check with your Basis team if they can write some sort of unix scripting [shell script] to achieve this and in that case they control the scheduling and we dont need to use SM36 again..

if not thirt party schedulers are aso available..just an option though..

PeterJonker
Active Contributor
0 Kudos

One option that comes to mind is to schedule a jo with your program AND a custom program.

The custom program should just raise an event and then you can schedule the job after event (the event you are raising in step 2 of the job).

Then create two jobs, one with both programs (step 1 and step 2)scheduled by date time and one with the same programs scheduled after event.

Once the first scheduled job (date time ) starts the 2nd step will raise the event which will start the job scheduled after event. This 2nd job will start now every time again.