General information about background jobs in SAP ERP

Hi all!

My name is Yuri, I am a SAP ERP consultant. Like any IT specialist, I am constantly looking for ways to automate work tasks.

One suitable tool is a background job. It allows you not to watch the execution of the program on the monitor, but to postpone the launch, for example, until the night, so as not to load the system with heavy operations during the day, to plan regular operations… In general, there are many advantages for any specialist who regularly sets tasks in SAP ERP.

Next, I’ll tell you how to create tasks in two ways and how to track them. And if you are just starting to understand SAP ERP, I will give you some useful tips that will greatly simplify your work and help you use the full potential of background jobs.

What is a background job

This is the task of the program: to launch and work independently, without a user. The advantage is obvious – while the program is running a background task, you can do other things.

Unfortunately, as happens in life, there are some limitations. For example, it is impossible to perform operations in the background that require data input from the user or display information on the screen, and you cannot run enjoy transactions in the background. But background jobs greatly help generate large reports and process large amounts of data.

How to create a background job from a report or program

There are several ways to create a background job. A faster option is to run the report, but specify that it should be generated in the background. Then the system will fill in some of the parameters in the task automatically (for example, the name). To do this, use the “Program – Background Execution” menu item, if available:

The system will ask for the launch condition, and fill in all other data itself. The conditions are:

● “Immediately.”

● “Date/time” – will start at the specified time. You can also set a “cut-off time” – for example, if a task is scheduled for 2 o’clock in the morning, for some reason it has not yet started by 3 o’clock, but there is no need to launch it so late, you can cut off such a “late” launch with this setting.

● “After Zdn” – will start after the end of another background job.

● “After the event” – will start when the event occurs.

● “During operating mode”—will start when the system enters the specified operating mode.

Here you can set the background task to repeat after certain periods. This is useful for programs that maintain the system or process data.

True, you cannot schedule a periodic job after another periodic job, because in fact, “after a job” is a special case of “after an event,” where the event is a SAP_END_OF_JOB with a unique pointer to the “job-condition”. Since the next time the conditional job is run, its key will be different, the old SAP_END_OF_JOB pointer will not work. But there are several solutions. For example, at the end of the “condition task”, add a call to a unique event (which is not used anywhere else) using BTC_EVENT_RAISE, and launch the task we need with the “after the event” condition.

How else can you create a background job?

You can create a background job without running the report itself, then you will have to fill in all the necessary job parameters, but more detailed settings are possible.

To do this, you need to use the “SM36 Background Request” transaction and create a new task (or copy an existing one). In this case, in addition to the launch conditions already described, you will need to specify other data. First of all: job name, job class (priority) and execution purpose:

The execution target is an instance or group of servers.

The job class does not affect execution, but is important at the time of launch. If several jobs are scheduled for the same time, then the system will launch them in order of priority: first A, then B, then C. It is also possible to allocate an instance only for background jobs of a certain class.

Next, we need to directly select the step or steps itself – what will be performed in our background task.

If a program or report requires any data to be filled in before execution, such data should be saved as an option. Please note: when we create a task through the “Program – Background Execution” menu, the current program is automatically recorded in the step, and the filling of the screen at the time of selecting the menu item is saved in the option.

In this option, you can use variables, for example, set the date not explicitly, but through a variable:

It is worth noting that you can select an ABAP program as a step, which makes quite complex execution logic possible. For example, we need to schedule a regular launch of an operation whose execution time is not known in advance, but we also need to make sure that only one such operation is executed at a time. The RSBTONEJOB2 program will help us with this; we schedule its launch in a background job (and not the operation we need), and set its parameters:

· which background task to check (if a task with the same name is still active, we stop the work, but if not, we continue),

· which program and with which option to launch, if we have passed the check above about the absence of an active task, it is this program that will perform the operation we need.

This way you can avoid running the same program in parallel if you need to eliminate this risk.

Where can I track a background job?

For this, there is the transaction “SM37 Review of a selection of tasks”, which has simple and advanced selection modes (they differ in the number of search conditions). In addition to the job name and the login of the user on whose behalf the execution took place, you need to select the status of the background job. They are like this:

● Scheduled—the status of the background job after creation, when the launch condition has not yet been filled. Only federal laws with this status can be changed.

● Released—all data on the task has been specified, including the trigger condition. To edit such a task, you first need to change the status: in the context menu, select “Released → Scheduled”.

● Ready – all launch conditions have been met, the task is waiting for its turn (for example, a task with a higher priority has not yet completed). As a rule, this status does not last long and is soon replaced by the “active” status. If any problems arise and the status is frozen, you can double-check it through SM37: menu item “Task → Check status”.

● Active—background jobs have this status at the time of execution. They cannot be paused, they can only be interrupted.

The result of executing a background job will be one of two statuses:

● Finished—executed without errors.

● Canceled – if errors occurred (you can look at the log to see which ones).

After we have filled out the conditions for selecting tasks, we launch the search and see the log. In it, each task displays the status, start and end time, and by double clicking you can open a detailed view of this particular task:

Here you can see the message log (if errors occur, they will be there), the steps performed, and even the option to fill the screen, if there was one:

The system can send the result of a background job by email, save it in a spool, and, depending on the version, in a database.

So, in the article you learned general information about background jobs in SAP ERP, looked at several ways to create them, learned how you can track the results of background jobs, looked at examples of atypical job requirements and what can be done in such cases. I hope this information will be useful and you will now be able to automate more operations than before J

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *