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 based on events

Former Member
0 Kudos

Hi,

We are on 4.6 C.

We have a background job that has two ABAP programs.

We need to start the 2nd ABAP program only after the first one has run successfully.

If the second ABAP program does not run, the the job should have a status "FINISHED".

Help appreciated.

Thanks

Mala

3 REPLIES 3

Former Member
0 Kudos

I am assuming that you have these two ABAP programs as two steps in your job. The only way you can stop the second step from running is if the first step cancels due to an error condition. When that happens the whole job goes into CANCELLED status, not FINISHED. If you don't the job to go to a CANCELLED status, yet stop the second step from executing if the first step has errors, then you need to share the error status somehow(memory or database or spool etc) between the two.

First step executes, encounters an error condition, issues a message about the error condition but not an error message, sets the status to error where the other program will read from. The second one starts, checks the status, sees that it is error, stops going any further and completes normally with a message(not an error message).

This way you can stop the second one from being executed, at the same time have the job status of 'FINISHED'.

Srinivas

Events will work if you have them as two jobs instead of steps of the same job.

Former Member
0 Kudos

Define two background job for different program.

JOBA and JOBB by using SM36.

In the start condition of JOBB you can mention start second job After JOB JOBA by using "AFTER JOB"

com_2018
Participant
0 Kudos

Hi,

How to schedule a background Job based on events,please refer to the follow SAP help:

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,

collysun