A background job can be used to cover many requirements. A practical mini-guide to the options (the power) available...
Batch jobs can be an interesting approach where the following features can be utilized:
- The TIME_OUT issue is no issue (see background jobs - lessons learned)
- Allowing a background job to perform a task for which authorization is an important issue: the user that schedules a background job can be a maintenance-type user, super-user or even non-dialog user. This means there is no need to authorize an end user for the tasks that can be performed in the background.
- When a certain look-out task is required, a batch job can be scheduled when the previous run finished. This way your program will be "on air" continuously - handle with care (!)
- Background jobs consist of steps which are effectively program calls. So when you have several programs preparing work for the next program, setting up a single job with the steps is an effective way to link them all together. The second step will start if (and when) the first step finishes. Need to interrupt the job ? Just throw an error message... (
MESSAGE E123(XX)
). - When a batch job is scheduled, the triggering can be done via a Batchjob trigger event. Thus: a call to function module
BP_EVENT_RAISE
from whichever program can trigger a background job instantly.- The event can have parameter field
EVENTPARM
which can hold information to be picked up - Events can be created via transaction
SM62
- "Maintain event" which can be found in Tools / CCMS / Jobs / Maintain event. - The actual events are either SAP predefined, or custom, each on their own table:
BTCSEV
- "Table for system event IDs for background processing"BTCUEV
- "User event IDs for background processing".
- The event can have parameter field
- The performance issue: when several users run the same reports for the same output, you may want to consider having a batch job run the report and making the output available to the users. Batch jobs store printed output in spool files, which can be made visible to the end user.