SAP Background Jobs are used to execute long running or periodic transactions. Let’s discuss how to schedule them and monitor their execution using SM37 transaction.
SAP programs can be executed in foreground and background modes. In foreground mode, the program executes immediately, and it is visible for the user. In some complex programs, it is difficult to execute the program foreground because it takes time. While the program is running in foreground if there is an issue in the server connection, then there is a high chance of the program not being executed correctly.
In such instances, we can execute the program in a background mode. When a program executed in the background, program will be executed immediately, and the execution will not be visible for the user. If the user wants to check the status of the program execution, then they must use the transaction code SM37. The advantage of running a program in background is that, even if there are any connection issues with the server, the program will continue to execute because it is run from the server side. It is also possible to schedule a program to run in the background mode. This makes execution of programs easy. If the program must be run daily multiple times, we can schedule it and get the output when required.
How to Schedule SAP Background Jobs
We can schedule a program to run in the background mode easily. As an example, let’s take the COOIS report. To execute the program in the background, first enter the selection parameters. Then click on “Program” on top left corner of the screen. Next click on the “Execute in Background” option. Now a new screen will open with the scheduling details. We can select the “Immediate” option which will trigger the execution of the program immediately or we can give a date and time and save. Then the program will execute in the given exact date and time.
Some programs have their own transaction codes to execute the program in background mode. As example, if we take the MRP execution program, we can use the transaction code MDBT to execute the program in the background mode. We can save a variant and then schedule the MRP to be run in the background. Mass MRP runs are time consuming and by scheduling it in the background, it can be executed easily.
SAP also provides a generic transaction to schedule any background job – SM36. You can use SM36 to provide details of a background job (such as the program name and the variant) and request the server to execute it.
SM37 to View Background Jobs
If we have executed a program in the background and want to check the status of it, then we need to use the transaction SM37. SM37 is a BASIS related transaction code. Follow the below steps to check the status of a background job.
- Execute the transaction SM37.
- Enter the selection criteria.
- If the job name and username is known, we can give it directly in the selection screen. If those are unknown, we can input * for these fields and execute the transaction code.
- We can select a job status. SAP has provided job statuses such as scheduled, released, ready, active, finished and cancelled. This selection will narrow down the results of the program.
- Enter the date range. This is not mandatory, but it will help to narrow down the search.
- Now we will get the list programs which were scheduled for the given selection parameters. From here we can see the status of SAP background jobs.
- To view further information about the job, select a job and click on the “Job Log” button. If the job is cancelled, we can go to the job log and find out the reason for the cancellation of the job.
From the transaction code SM37, we can view the execution time of a program also. This is useful information to take decisions from SAP administration and optimization points of view. As an example, there might be jobs taking a long time to execute. These might be programs which have issues. If a program is regularly taking lot of time to execute, we can identify it from SM37 and then take necessary actions to rectify the issues.
Sometimes jobs are shown as active even if they are completed already. To rectify such job status issues, select the job, and then select “Job -> Check status”. This will correct the job status if there were any problems. Below functions are also available in the SM37 transaction:
- Find the program which is related with the background job.
- If the program is not known, first enter the background job name and execute the transaction.
- Background job will be listed. Select the job and click the “Step” button.
- When you click the “Step” button, a new screen will open and there we can see the program name in the first column. This function is useful when there are failures in the background jobs. We can quickly find out the program of such background jobs from this method.
- If we want to know the variant of the background job, it is also available in this screen.
- Find the job name when the program name is known.
- For the job name and username fields enter the * sign.
- Then enter the program name in the field “ABAP program name”.
- Execute the transaction.
- All the jobs related to the given program will be listed. We can use the job status selection to find the exact job that we are looking for.
- View the spool. SAP spool is an important function in SM37. SAP spool contains the results of the background job. As an example, if the background job was scheduled to transfer data between SAP and another external system, the spool will contain all the data which was transferred. This is an important tool specially for a functional consultant.
SAP Background Job Tables
Background jobs related information will be saved in TBTCO and TBTCP tables. TBTCO is the header table This has the job-related information such as job name, start and end dates and times, job scheduler etc. TBTCP is job step table. This has the individual processing steps of the job. If we want to take a dump of all the background job related information, we can get a download from these two tables. Also, these table are important if we are planning for system downtime. We can get a dump of all the program which are affected in such a situation.
This concludes the blog on SM37 transaction code and background jobs in SAP.