What is an SAP job for and how is it structured?
Background jobs are used in many areas where processes are executed automatically by the system at certain times without manual intervention. In the area of Unix systems, the concept of cron jobs is well known, and on Windows computers,background processes can be set up with the task scheduler. SAP also has appropriate background processing for processes – so-called SAP jobs.
SAP jobs can be executed once or recurrently – for example, every day at midnight. This allows, for example, resource-intensive processing to take place at night when few or no users are logged on to the system. Another application example is the recurring collection of new EDI messages from an external B2B Integration Hub, as in the case of ecosio.
In the following article we will introduce the most important features and show how to set them up. We then go into how to modify existing SAP jobs and how to read processing logs from SAP jobs.
Properties of SAP jobs
SAP jobs are set up using transaction SM36. The following graphic shows an example SAP job.
There are unique job names that can be freely assigned. For reasons of clarity, it is recommended that you adhere to a uniform system-wide naming convention.
SAP job classes
An SAP job must be assigned to a specific job class when it is created. Job classes define the priority with which a background job is executed. A distinction is made between the following three classes.
Class A – High priority
Urgent or critical background jobs can be planned with class A. These jobs are given priority before class B or C jobs are executed.
Class B – Medium priority
As soon as class A jobs are processed, class B jobs are started.
Class C – Low priority
Class C jobs have the lowest priority and are only started when class A and B jobs have been processed.
Besides the assigned priority class, there is a certain status. The possible statuses are as follows:
The job is only scheduled, but has no start condition, end date, execution frequency, and so on, and will never run.
The job has assigned process steps and all the parameters for execution are available. The job is waiting to be executed for the first time as soon as the start condition is fulfilled – e.g. a certain time.
The job is ready for execution and has been placed in the execution queue by the job scheduler. As soon as a background process is free, the job is executed.
The job runs in the background. The status of the job can no longer be changed during execution.
The job has been successfully completed.
The job has been canceled. The termination may have been caused manually by an administrator, or a problem may have occurred during the execution of the job. The exact details can be read in the job logs and in the spool (see description below).
Every SAP job consists of one or more processing steps – so-called steps. The following figure shows an example step.
A step in an SAP job can have three different characteristics:
- ABAP program
In this case, an ABAP program is started and a variant and the language can be passed. In the screenshot above, for example, the ABAP program /EPO1/EXC_ECOSIO_FETCH is executed with the variant FETCH, which periodically fetches messages from the ecosio Integration Hub.
- External command
With this function, a command predefined by the system administrator can be called up and parameters can also be transferred for the call.
- External program
In this case an external program is started, whereby parameters can also be transferred here.
In the first step, the job name and job class are defined in transaction SM36, as mentioned above. Then the individual steps of the job are defined, which are executed in sequence – from top to bottom.
The next step is to select the start condition of the job.
Usually you choose a certain time as start condition, from when the job should be executed, and a repeat interval – e.g. every 10 minutes. If no time is specified, the job remains in the “scheduled” state and is not executed.
After specifying a time and a repetition frequency, the job is saved. Afterwards the job changes to “released” and waits for its first execution. Alternatively, a job can be executed immediately by clicking on “Immediately”.
To change an SAP job, go to transaction SM37. There you can get an overview of all jobs in the different statuses. To change a job that has already been released, select it in the overview and then choose “Job > Released – Scheduled” from the menu bar.
The job can now be processed again and then released again.
As with a regularly executed process, an SAP job can also terminate unexpectedly. In this case, we recommend that you look at the logs. You can access this again using transaction SM37. In the first step, select one of the jobs already executed and then choose “Spool” or “Job log”.
These two functions provide an overview of the logs themselves and the individual process steps. A prerequisite is, of course, that the process steps also write processing logs.
With the introduction of SAP S/4HANA, the IDoc format will undergo some changes. You can find out what these changes are in detail in this article.
Do you have any questions?
Do you still have questions about SAP jobs or the connection of external systems to your SAP ERP or SAP S/4HANA system? Do not hesitate and contact us. We are always available to answer your questions.
© 2020. SAP SE or an SAP affiliate company. All rights reserved. Used with permission of SAP SE.