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: 

How to schedule a background job using the Event concept..?

Former Member
0 Kudos

Hi Folks,

I have a requirement that, I need a schedule a background job.

Once after the previous job successful only, new job should get triggered. How to go ahead with this..?

For Eg, I am scheduling a job called ZTEST periodically for 1 minute. If the job is not get completing with in 1 minute, I dont want to start my new job. Only after the success of my old job, I want my new job to run.

Waiting for ur replies.

Regards,

Savi.

6 REPLIES 6

Former Member
0 Kudos

In SM36, choose option "After Job" in start condition.

Former Member
0 Kudos

Hi,

You can use events that have already been defined, or you can create new events for scheduling background jobs.

If you wish to use new events, do the following to implement the event scheduling:

Define and transport the event as a user event with transaction SM62.

You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.

If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.

Do this to transport an event:

Create a transport request.

Start the editor in the transport request and enter the following:

R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.

Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.

Save and release the transport request. Ensure that it is imported into your production system(s).

To trigger an event, add:

– the function module BP_EVENT_RAISE to your ABAP program, or

– the program SAPEVT to your external script, batch file, or program.

When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.

Schedule the jobs that are to run when your events are triggered.

You can schedule jobs for one-time start or to be started whenever an event is triggered.

Regards,

Raj.

Former Member
0 Kudos

Former Member
0 Kudos

Hi,

How about approching this way.

1. Define the event.

2. Define a JOB via SM36 with start condition as AFTER EVENT.

3. Raise the event accordingly.

Regards,

Shiva Kumar

0 Kudos

Hi,

In SM36 transaction:

1. Click on the Start Condition Button

2. Click on the After Event button in the subsequent subscreen

3. In the Event parameter give the value 'SAP_END_OFJOB' and the parameter value as your current job.

4. Check the periodic job checkbox.

This should work.

Regards,

Aravinda Sarma M.

0 Kudos

Hi

We got similar problems

One SAP standard job that collects statistics is scheduled to run hourly. However sometime the job overruns by many hours due to lack of resources. And since it is scheduled to run hourly you may find in say 4 hours same job running 4 times i.e 1- 3hours long, 1- two hours long, 1-one hour long andone just starting. The resources are thus further depleted.

So we thought we could use events or afte job conditions to make the scheduler start only one job however long it may take until this is successfully finished before starting a new one.

The After job condition did not work since we wanted the scheduler to check the status of job X, if successful then start job X again. That way only one job will ever be executed even if the job has delayed forover an hour. This did not work despite having the job in released status.

Then we tried the event condition. There is SAP std event SAP_END_JOB. We scheduled the job X to run after event [whose parameter is job X] and kick itself again. This did not work either. Now we create two jobs doing exactly the same thing but with different names and the event for one job X triggering the execution of the other X1. This is complicated as somehow one job X or X1 must have started in order to trigger the other one respectively. If you schedule with a period value the event condition is neglected. If you don't no job will start as each waits for the other's event

Please advise

Joseph Minja

British COuncil UK