Copyright 2024 - BV TallVision IT

Background jobs can be scheduled through SM36 - which is used in all SAP implementations. Alternatively a background job can be scheduled from a report or by an Abap report. Batch job scheduling has it's limitations. Hence: the Batchjob scheduler was introduced. 

The limitations - of the standard

Batch job scheduling is of paramount importance - as certain system steps need to be performed at certain preset times. From Abap development point of view, it's the outbound or inbound interfaces that will need to be "scheduled". This is done with a batch job definition that can be repeated. When the job is started, the next occurrence of the job is planned before the job is actually started. Very effective, but limited.

Consider an inbound interface, that should process it's data within 1 hour. A job is scheduled to be repeated every hour of every day. This implies that the interface is also triggered after office hours. If you would like to run this interface every hour during office hours, you would have to schedule 8 jobs, each covering 1 hour of the day, and repeat this job daily. If the interface should also not run in the weekend, the scheduling mission becomes an impossible task. 

This is often solved by triggering the interface report every hour of every day. The interface would not have any work to do on non-office hours, which would get the "job done" in a matter of seconds. This does lead to a potentially great number of "empty jobs". 

The scheduler - define a week

The scheduler is an application that schedules the batch jobs required as individual jobs, without repetition. A set of up to 8 execution instruction lines can be defined, in which the day of the week, a start time, end time and pause-period can be defined. An example:

We would like to run an outbound interface every half an hour, during office hours, every week day. The following execution instruction lines can be defined (by filling in checkboxes and time fields): 

  • For Monday, Tuesday, Thursday and Friday, starting at 08:00 ending at 17:30, the job should be scheduled every 00:20 minutes.
  • For Wednesday, starting and ending at the same times, the job should be scheduled every 02:00 minutes ( 2 hours).

With only 2 instruction lines, a full week schedule is set up. Whenever instructions indicate the same batch job execution time, the job will be scheduled only once. Add an instruction line without period and it will be executed (scheduled) only once.

But the possibilities don't stop there. The job could be scheduled more frequently during busy hours. Or the execution dates for the schedule could be limited (through a date select option field) to ensure the schedule off-line on Christmas day, or the last day of the month.   

How it works

The way the scheduler works - is as follows:

  1. A single step or dual step job can be defined in the selection screen of the scheduler report. The settings are stored in a variant. Before saving the variant, the settings should be activated, for which a button is available (right top).
  2. A typical "work week" is defined, where per day the repetition of jobs is defined.
  3. Through a select-option on the Run on date variable can be filled in, to ensure your schedule is only running for a month or is not issued for certain dates (Christmas, Halloween).
  4. The Batch Scheduler should be scheduled itself, with a predefined variant called MASTER. This makes the report look for active variants and this is what will implement the schedule of each of the available (active) variants.
  5. For each active variant - a schedule is composed for the current day (and only for the current day). The report will check whether the job is already scheduled - and schedule it if it is not already on the SM37 agenda.
  6. Only "future times" are scheduled. Which implies that if the scheduler job runs once a day at noon, no job will ever be started before noon. So the scheduler itself would need to be scheduled before the first actual job should start.
  7. The scheduler builds a list of jobs to schedule, and schedules them for the whole day. There is also a "retract" option, which will remove all scheduled jobs - for a certain variant.
  8. There really is little point in scheduling the scheduler several times a day. The second time it runs would effectively attempt to implement the same schedule as the first round. Only useful if a schedule is adjusted during the day.

Step-by-step getting started

You've installed the scheduler program (download at the end of this article) and you want to see it in action. Here's what you should do - in 4 steps:

  • Step 1.
    Fill in the control settings
  • Step 2.
    Supply the report name and variant of the report you want to schedule. Note that a second report and variant can be added (step 2) as well (button available).
  • Step 3.
    Fill in the week-time schedule. With up to 8 lines the week can be scheduled. Fill in the periods you need, repetitions where needed and all for the required days. Once that's aligned with requirements, you can supply the date field "Run on" with actual dates you would want this schedule to run.
  • Step 4.
    Activate your schedule (button on the top-right) and save the settings in a variant. Make sure the variant name reflects the function of the batch job, as the variant name will become part of the batch job name.

Getting to grips with the scheduler

This is quite a bit of machinery, that you will want to feel comfortable with before implementing it. Here's a few base concepts that should keep matters manageable:

    1. The scheduler only schedules jobs that are (1) in the future and (2) for today only (the current day).
    2. There are buttons to "Schedule" and "Retract" which work without the scheduler being active. Try these out and check the SM37 transaction in the process. It should be clear where jobs come from and how they can be added and removed (retracted) again.
    3. Run the report as a report to get a list of the batch job times - for inactive variants. Use the "Preview" button for stored variants. Example output of this report:

The most effective way to check whether this setup is feasible on your system is to try it out. The names of the batch jobs are set to only 1 possible prefix, so it should be easy to trace where a job came from. And the setup can also act as a "main switch", because cancelling the scheduler job effectively cancels everything on the schedule - which can be a great advantage. It can also be the reason not to use the scheduler for some of the jobs. You have a choice.

Get your free download here

The batch scheduler is a single-source solution, which can easily be implemented by anyone with a developer key.

Blink application

The batchjob scheduler can also operate as a Blink application, which is to be linked to the main report that would be scheduled. By pressing a button the Batch job scheduler would be called with the correct variant. Scheduling information would immediately be displayed. Here's a coding extract:

  case sscrfields-ucomm.
    when 'FC01'.
        using selection-set 'ANYPOINT-1' ".. your variant here
        via selection-screen
        and return.