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 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?
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.
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.
Result is shown correct working, number of batches and wait time:
Background job analysis tool
Start transaction ST13 and start tool BACKGROUND_JOB_ANALYSIS. Or directly start program /SSA/BTC.
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
Batch job interception
For more information on batch job interception, please read this blog.
Ignoring large spool output of a batch job
In some cases a batch job will generate a large amount of spool output which is clogging the spool system, but is never used. In this case you can set up the job to put the output to output device NULL. For setup read this blog.
Archiving spool as print list
If you want to store the spool as print list in the archive, please read this blog.
Archiving job log
To archive the job log, insert the report BTCAUX03 as the last step of a job. See OSS note 1072621 – Archiving of job logs.
Check job step users
If you want to quickly check which user ID’s are use inside batch job steps, it is best to quickly go to table TBTCP. Here you can quickly see across many batch jobs which step users are used.
Check batch job headers
Sometimes you need to report and check data on batch job header level. This data is stored in table TBTCO. Example: if you have performance issues with jobs and you have multiple application servers, you can use table TBTCO to check on which application server the troublesome jobs are running.
Solving inconsistencies in batch job tables
In rare cases there might be inconsistencies in the batch job tables TBTCO and TBTCS. In this case you need to run program RSBTCCNS to check and delete the inconsistencies.
Bug fix OSS notes:
- 2890078 – Incorrect selection in consistency check
- 2934495 – Performance improvement SAP_BTC_TABLE_CONSISTENCY_CHECK
Mailing batch job results
You can mail the spool result of a batch job to one or more mail addresses. Also with newer SAP netweaver versions you can mail if job was successful or not. Read this blog in detail.
Debugging batch jobs
For debugging batch jobs, please read this dedicated blog.
Batch jobs full
If there are no batch processes free any more, you might see this screen in SM37:
When you face this situation check in SM66 if there are BTC processes available.
If you still face issues check OSS note 165084 – Why does my job not start?.
Deletion of batch jobs
Bug fix notes:
Finding out who deleted a batch job
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 goto 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.
Delay in batch jobs
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.
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:
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.
Data archiving batch jobs
Data archiving jobs can trigger too many jobs at the same time. Read this dedicated blog on how to reduce amount of parallel jobs for data archiving.
Time based jobs are not starting
For trouble shooting if time based jobs are not starting (batch scheduler SAPMSSY2 is not running): OSS note 2475466 – Time based jobs are not getting started although there are BTC WPs available.
Batch job statistics
Start transaction SM37C to go to the extended job selection. Now select menu option Goto / Job Statistics:
This gives statistical output:
Batch job delay
Batch job delay can be set with parameter rdisp/btctime. Default is 60 seconds.
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: