How to schedule background jobs in SM36 (Easiest way to schedule job using Wizard)
Background job in SAP
First thing first, lets understand what background job is and use cases of it (few can skip to next heading).
How I come to know about background jobs first time? SAP forced to use it. At the time of executing depreciation program, got an error that live depreciation run cannot be executed online, and it should be posted through background job. So I executed background job from AFAB transaction. From Menu – Program – Execute in background.
So 1st use case – It saves end user time. Many times if we execute any transaction which take several minutes to complete, background job can save you that time. Also think about risks involved in doing online run. If you are executing complex transactions which involves critical subsequent activities and if the running server were not able finish that activity within 15-20 minutes, you will get ABAP run time error. Many times your connection might get down, due to VPN connectivity issues or internet connectivity.
On the other hand if you schedule that activity in backend, SAP will allocate one separate server for the program to run and it will not be dependent on user connectivity or activity. User can log out and log off their system. The job will do their work.
2nd use case – Automation. Background jobs are nothing but bots that are helping to automate small to long processes. Because it gives the flexibility of schedule time. You can schedule job whenever you want at whatever frequency you need. Within job you can set different set of programs to run after another. You can trigger job based on various events.
In large organizations 70-80% processes run through background jobs. Background jobs are very crucial part of SAP, one should know in and out of background jobs.
You can read this SAP help documentation to know everything about background jobs
Schedule jobs using job wizard
There are two ways to schedule job, one is where you enter details in multiple fields in multiple places and another is through wizard, where SAP walk you through whole process. Job Wizard is very useful and handy tool and still very underrated. Whenever there will be any need to schedule job in production server, you will have to schedule it through SM36 transaction only. Lets say you have run depreciation run in production system, but most of the cases you will not have authorization to AFAB transaction, so in this case you need to schedule one job in SM36 with depreciation run program and appropriate variant.
Go to SM36

You will find the Job wizard icon in Menu (highlighted above)
Click it to launch the wizard
You will be prompted with the below screen

It says everything about itself on first screen – “The Job Wizard quickly guides you step-by-step through the process of creating a job, allowing you to move back and forth between steps in the process and to confirm the details of the job you’ve just defined.”
Click on continue to proceed

Give some meaningful name to Job (unlike given above)
Job class should be as per job priority. System will allocate appropriate space from the server based on job priority.
Job status will be grayed out with default status
In Target field, there is option to select in which server you want run the job. Usually there is dedicated server created for each modules and some additional servers for big activities. Although it is a optional field, so if kept blank it will determine server itself. It does not matter much for small jobs. But for huge activities where processing data is large and for complex activities, it needs to run on separate servers so that other processes don’t get disturb.
Press continue to move on
Get S4 HANA Server Access: S4HANA 1909 – Functional Server
On the next screen, select ABAP Program step (Never used other radio buttons)

Press continue
Here you have provide ABAP Program Name and Variant for the program.
There is one program available for every transaction in SAP to run it in background (with selection screen). There are many ways to get program name. Simplest one, just Google it.
Variant – Create one variant for program with the selection criteria you want. (In my experience there will always be a variant available which can suite your requirement)
Not going into details about how to create variant, assuming everyone aware of it.

After entering program and variant name, press continue
If you notice closely in each screen of the wizard, there is explanation given on top for every field and why it is require/ what does it do.
In below screen, it is asking if you need multi step job. Explanation is given in upper side of screen. So multi step jobs mostly used to automate multi step processes. If you select add additional step option, then you will have option to add another program and its variant details. You can add as many program as you want, as per the running sequence.
So system will execute another program once first program is over.

We don’t need this option in our scenario, so just press continue
Here you will get to select schedule time and frequency of job. There are multiple option to trigger the job and each one is equally important. We need to release job immediately, so we will select Immediately option.

Press continue
On the next screen system will tell you, what is the current occupancy of servers and how feasible is it to run job immediately. This is very useful, when you will run the job in busy timeframe / busy system. Many time heavy job release can lead to other job failures and impact system performance.

Press continue
Last screen will give you all the details overview, you so far entered and ask for final confirmation.

Click on complete to release the job

And the job is scheduled. Very easy ah? Once you use it, you will get addicted to this wizard. Since I come across it, never scheduled job without wizard in SM36.
Read eBook: SAP DME – A Simplified Guide
How to monitor background jobs?
Scheduling job is one thing and monitoring it is another skill, if you know the key point one should check.
In SM36 jobs are scheduled and in SM37 jobs are monitored.
So without further ado, lets go to SM37

I will not bore you with the basic details of this screen. So we will enter the job name that we entered in wizard (ZSAMPLE).
You can also search job based on program name. In the last field of above screen you can enter the program name which is running underneath of job, in our case it is RAPOST2000.
So if you don’t know the job name and want to check what are the jobs that are running for specific program, this will be useful feature.
There are very important job selection criteria’s available in ‘extended job selection’ tab. You can visit it, everything is self-explanatory no need to mention here.
Press F8 to search job for given selection criteria.

So our job is in finished stage. You can also notice the start date and time plus duration of how long job was running.
Further in menu, we have option of Job log, where we can get the details of step job performed. Job logs are useful when job fails. Like in our example we have executed depreciation run program. So if the depreciation run got failed due to not maintenance of document number ranges or due to cost center block issue then these details will be printed in job log to analyze and take corrective actions.
In spool the result screen is printed with the information that are requested through program. If you are running reports in background, then report result will be available in spool. In our depreciation case, in spool we can see the assets with posted depreciation values.
Next we have ‘Steps’ option where we will get to know the underling programs of job. There we can also see the program variant that is executed for selected job.

This is the program running under ZSAMPLE job. If you want to check variant values then go to Menu – Goto – Variant

Here you can confirm for which company code and for which FY, period this job was scheduled/run.
Read Blog: How to use user exit in substitution and validation rules?
Come back to job overview screen

and double click on job

Here you have multiple option to know more about job.
On top right hand side, Start condition will tell you what triggered this job.
‘Job details’ will help you understand, job priority and execution server details.
‘Predecessor job’ option will tell you what are the job that run before this job and after completion that job will trigger this job.
‘Successor Job’ will tell you which job will be triggered after this job is completed. These two options are very useful to know more about dependent jobs.
Our ZSAMPLE was standalone job. It neither get triggered by any job nor it triggers another job.
This is all about job monitoring and job schedule. You can bookmark this post for future reference.
Thanks for reading. Do subscribe to our newsletter below to receive notification of new blogpost.