When a batch job finishes, there are use cases where you want to be informed on the results.
Questions that will be answered in this blog are:
How can I mail the spool result of a batch job?
How can I mail if the job went ok or not?
Mailing job status
As of version S4HANA 1709 (basis version 7.52), you can mail the batch job result for cancelled jobs, or in all cases when it finishes. In SM37 after job is planned goto change mode of the job and push the E-mail Notification button:
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
Programs BTCTRNS1 and BTCTRNS2 can be used for mass forced stop and start of batch jobs. See this blog for more details.
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.
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.
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:
This blog will explain how to setup SAP batch job interception.
Questions that will be answered in this blog are:
How to activate SAP batch job interception?
How does an intercepted job look like?
Activating SAP batch job interception
Before you can begin the setup of the batch job interception you must run program INITXBP2 in SE38:
Next you have to start transaction CRIT and create the profiles.
First create the default SAP profile by clicking on the SAP logo. Activate it. Next step is to create the profile in which you want to do the interception. In the screen above click on the create profile button. Now enter a criteria. For simplicity we have called it interception. In our case we intercept all except a list of authorized users. In the user list we include the basis users and the background users (in this example WF-BATCH). Save the data.
Next step is to activate this profile:
Working of interception
When a batch job is planned the interception checks if the job should be intercepted or not. As a test logon as end user and launch a job. In our case the user ENDUSER tries to launch a job from SLG2 transaction to delete application logs. This jobs is intercepted ans shows like this in SM37:
The job does not start immediately, but shows in intercepted state. If user with release rights now goes to SM37 for this job, he can release the intercepted job.
This blog explains how to mass stop and mass start batch jobs as admin. This especially useful putting the SAP system in maintenance mode. Maintenance mode can be needed for upgrade, support package patching or data conversion.
Questions that will be answered are:
How to mass stop batch jobs?
Can I plan new jobs I need during the suspend mode?
How to mass start batch jobs again?
Stopping all batch jobs for maintenance mode
Stop all batch jobs: start transaction SE38 and start program BTCTRNS1.
All currently planned jobs will be put into a Released/Suspended mode:
This means the already planned jobs (periodically or not) will not be started.
During this suspend mode new jobs can be planned by admin. These new jobs will be executed.
Starting all batch jobs after end of maintenance
Start all batch jobs again: start transaction SE38 and start program BTCTRNS2.
For more background information read OSS note 79424 – How do BTCTRNS1 / BTCTRNS2 work?.