Batch jobs tips & tricks

This blog will give tips and tricks on batch jobs.

Questions that will be answered are:

  • How to check a job is not running already before starting new one?
  • How to build in a wait step into a batch job?
  • How to set the RV variables automatically in table TVARVC?
  • How to validate that the basic batch job system is working ok?
  • How to analyze the jobs running in my system?
  • How to mass stop and start batch jobs?
  • How to set up batch job interception?
  • How to ignore large spool output of batch jobs?
  • How to see the batch job delay timing?
  • How to plan standard jobs in S4HANA?
  • How do I set up batch job server groups?
  • How can I mail the spool of a batch job?
  • How can I mail if job was successful or not?
  • How to check the consistency of the batch job tables and how to repair?
  • How can I archive a print list?
  • How can I archive a job log?
  • How can I get job statistics?
  • How to read content from batch job variants?
  • How to find batch jobs with deleted or locked step users?
  • How to debug a batch job?
  • How to find who deleted a batch job?
  • How to check in case of batch job delay?
  • How to quickly check health of batch job scheduler?
  • How to trigger batch job event?

SAP FAQ note on background jobs

SAP has FAQ note on background jobs: 3008195 – FAQ: Background Processing BC-CCM-BTC-*.

Prevention of same job still running

If you want to prevent same job from starting, while a previous instance is still running, you need to add program RSBTONEJOB or RSBTONEJOB2 as first step in the batch job. This step will detect if the previous instance is still running and abort to avoid the next steps from being executed. More background in OSS note 557610. The scope of both programs is in principle limited to be used for idocs and CUA. To extend the scope or in case of issues, read the instructions in note 3225033 – Behavior of program RSBTONEJOB, RSBTONEJOB2 not as expected.

Forcing a batch program to wait

If for some reason you need a batch program to wait between steps, you can use program RSWAITSEC as a step. This program will only do a wait for x amount of seconds.

Setting current date in the TVARVC table for the RV variables

The RV variables for current date, month and year are often used in month end closing batch jobs. Running program RVSETDAT will set the current dates for RV TVARC variables.

Checking basis background job system settings and working

If you want to validate if the background job system function itself is working properly, start transaction SM65 background processing analysis tool.

SM65 start screen

Result is shown correct working, number of batches and wait time:

SM65 result screen

Bug fixes for SM65:

Background job analysis tool

Start transaction ST13 and start tool BACKGROUND_JOB_ANALYSIS. Or directly start program /SSA/BTC.

Batch job analysis tool

Pending on your selection you get a graphical overview or a full list for you to speed up your analysis.

Mass stop and start of batch jobs

Also check this note for clean up of BTCDELAY table: 3222291 – Superfluos Entries in BTCDELAY Table.

In some cases you might want to find out who manually deleted a batch job.

Unfortunately you first need to activate the logging via program BTCAUX06:

To view job deletions you need to go to transaction SM51, menu option Goto, Trace, Instance Trace, Search Trace. Then look for pattern BP_JOB_DELETE.

More information in OSS note 850885 – Logging the deletion of jobs and 3325374 – How to log job deleted in Background Processing.

A batch job is not started immediately, but with a delay. This delay is set via RZ11 parameter rdisp/btctime and default setting is 60 seconds. More information can be found in OSS note 923228 – Background job scheduler: Use of processes that have become free.

See new note 3236046 – Test report for immediate start for program BTCAUX25 that will test immediate start.

Standard batch jobs in S4HANA

Standard batch jobs in S4HANA are planned via transaction SJOBREPO. For more details read the dedicated blog.

Batch job server groups

If you have a large production system with many application servers you can setup batch job server groups to have batch jobs run on a set of dedicated application servers. To set up batch job server groups start transaction SM61 and click the button Job server groups:

Job server groups

Here you can define the job server group and assign application servers to them. Background is in OSS note 612838 – Administration of job server groups.

job statistics

This gives statistical output:

Job statistics output

Batch jobs with deleted or locked step users

If a batch job step user is locked or deleted, that step will fail. To find such batch jobs, follow the steps as described in this blog.

Batch job delay

Batch job delay can be set with parameter rdisp/btctime. Default is 60 seconds.

See also OSS notes 3080021 – Jobs are started with delay and 3148846 – Background Jobs with status “No free batch work processes available”.

And these notes:

3275278 – Background jobs are started with delay / 3355049 – Correction for Note 3275278.

How to read content from batch job variants

In quite some cases the basis team is asked: in which batch job variant is this company code XXXX used? Or we need to add another sales organization to all the batch jobs, can you provide us a list with jobs using sales organization YYYY? How to get this data is answered in this dedicated blog.

How to check health of batch job scheduler

Start transaction SM61. Now select the Time-Driven scheduler. Select the server and choose the health check tab. Now press the check button:

Batch job event triggers

Batch jobs can also be triggered using events. Read more in this blog on batch job event triggers.

Background OSS notes

3008195 – FAQ: Background Processing BC-CCM-BTC-*

12 thoughts on “Batch jobs tips & tricks”

  1. Dear Team,

    I wants to know that which user have deleted the back ground job which we put through SM36.
    Or
    Is there any table in which we can see the deleted background jobs.

    1. Hi Dharmendra,

      Good question on who deleted which batch job in SAP.
      See OSS note 850885 – Logging the deletion of jobs. This provides batch job deletion logging functionality. Unfortunately you need to activate it first, as it is not switched on by default.
      Alternatively you can check in the SAP audit log: https://www.saptechnicalguru.com/sap-audit-log/

    1. Can you clarify the question? Background jobs are running independent of users that are logged on.

  2. Is there a way to know who and what values of variant changed ? I tried SA38 it just says last changed user name, but I wanted to know what were the old values

    1. The data is stored in table VARI. But this is in unreadable format.
      Use function module RS_VARIANT_ADMIN_DATA to read the data. Input is program name. Output is all variant detailed admin data. The data you are looking for is in output table VARIANT_INFO, field AENAME and AEDAT. This user name of person who did last change, and date of last change.

  3. Hi,
    I used RBSTONEJOB2 to avoid multiple instances of the job.

    While debugging a finished job using jdbg, upon clicking f7 i get directed to RBSTONE report where in error message ‘No job is running ‘is displayed.

    in the variants-> report i have mentioned my report name as well, but the report does not get executed.

    Can some one tell me how to debug the job if such is the case? .

    thanks

    1. Hi,

      SAP recently release OSS note 3225033 – Behavior of program RSBTONEJOB, RSBTONEJOB2 not as expected. You can read here the background of your issue.

  4. While scheduling the background job using SAPPMBATCH.
    the program is report and that report is not executed as expected.

  5. Hello,
    We have a batch job running every 5 mins daily. This should skips one cycle. For e.g., the job at 18:35 skips and resumes as usual at 18:40. Do you have any inputs on why the 18:35 job skipped?

    Please note the there were no issues with background work process utilization when the job skips.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.