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.
Result is shown correct working, number of batches and wait time:
Bug fixes for SM65:
- 3054357 – SM65: Consistency check does not delete all BTCEVTJOB inconsistencies
- 3099113 – Inconsistent entries in table TBTCS are not deleted
- 3169179 – High memory consumption during run of SAP_BTC_TABLE_CONSISTENCY_CHECK
- 3258672 – SM65 reports incorrect inconsistencies for table BTCJOBEPP
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
Deletion of batch jobs is done via standard SAP program RSBTCDEL2.
Bug fix notes:
- 2224521 – Problems with RSBTCCNS (SM65) (2)
- 2622066 – RSBTCDEL2 deletes jobs in other clients
- 3249422 – RSBTCDEL2: Performance Problems after Note 2622066
Also check this note for clean up of BTCDELAY table: 3222291 – Superfluos Entries in BTCDELAY Table.
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 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.
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.
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:
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.
Also check OSS note 1902003 – Many ARFC* jobs in SM37 and many “Error when opening an RFC connection” in SM58 at the same time.
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 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.
Batch job monitoring
Batch job monitoring can be done with SAP Focused Run. Read more in this blog.
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.
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/
Can I Log off, while Background job is Active ?
Can you clarify the question? Background jobs are running independent of users that are logged on.
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
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.
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
Hi,
SAP recently release OSS note 3225033 – Behavior of program RSBTONEJOB, RSBTONEJOB2 not as expected. You can read here the background of your issue.
While scheduling the background job using SAPPMBATCH.
the program is report and that report is not executed as expected.
SAPPMBATCH is unknown. Can you elaborate your issue?
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!
Can you check SAP profile parameter rdisp/btctime?
Out of the box it is 60 seconds. New job starts are then triggered every minute.
If yours is set to 600 seconds, only every 10 minutes job gets triggered. Hence you skip the 5 min job.
See also SAP help file on job start management:
https://help.sap.com/doc/saphelp_nw73ehp1/7.31.19/en-us/4b/2bc0094c594ba2e10000000a42189c/content.htm?no_cache=true