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:
In case of issues check OSS note 2951767 – E-mail notifications are not sent.
Mailing spool result
For mailing spool results use the Spool List Recipient button:
On older systems there might be a cutoff after 1000 lines in the mail. See OSS note 329537 – Spool cut off at 1000 lines when sent to recipient. In case of issues, you can check OSS note 760838 – Spool lists are not sent and 930570 – Problems with sent OTF documents.
Mailing spool result to multiple mail addresses
In transaction SO15 create a distribution list:
Hit the create button to create a distribution list:
Goto the tab Dist. list content to enter the e-mail addresses:
Save the list.
Now you can go to SM37 and change the job:
In the recipient field hit F4 or the selection button and switch to the distribution list. Search the correct one and press ok:
In case somebody by accident deleted a shared distribution list, check OSS note 2477819 – Distribution Lists have been deleted for recovery options.
In S4HANA standard jobs are scheduled in a different way.
This wblog will answer the following questions:
- How to see then new standard jobs via transaction SJOBREPO?
- Where to find more information on more advanced functions?
- Which background OSS notes can I read on the S4HANA stand batch job repository?
Viewing the job repository
Start transaction SJOBREPO to view the job repository:
Use transaction SWF_JOBREPO_SLG1 to see logs of potential job issues.
To assign a standard user to job steps use transaction SJOBREPO_STEPUSER to set standard job step user:
Checking the activation status of SJOBREPO
With program R_JR_UTIL_1 you can check the current status of SJOBREPO or activate it:
See OSS note 2790150 – Automatic Job Scheduling is switched off.
Advanced functions in SJOBREPO
All the advanced configuration functions of the S4HANA job repository can be found as PDF attachment to OSS note 2190119 – Background information about S/4HANA technical job repository.
Background OSS notes
Useful background OSS notes:
This blog will explain how to debug a background batch program with real background mode (SY-BATCH is X).
Questions that will be answered are:
- How to debug a running job?
- How to debug a completed job?
Starting the debug mode for batch job
First we plan a single run of the batch job. In our example we run program RSWAITSEC which does nothing more than wait.
In SM37 show the job run:
Select the job and in the command line enter the background debug command JDBG:
Now the debugger starts first in the batch job part. Hit F7 a few time (F7 = jump back out of routine) until you reach the real program:
As you can see here the SY-BATCH variable is X, which means you are debugging with real background mode on.
SM50 background debugging
If you want to debug a running job, you have to goto SM50 and select the background process. Then choose the menu option Administration / Program / Debugging. Confirm the prompt:
Wait until the running SQL statement has completed and debug mode will start.
Please be very careful with this kind of debugging in a productive system.If you cancel the debug session there might be a rollback work statement triggered, which can cause database inconsistencies.
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 get job statistics?
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
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.
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:
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
Deletion of batch jobs
Deletion of batch jobs is done via standard SAP program RSBTCDEL2.
Bug fix notes:
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
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.
Batch job statistics
Start transaction SM37C to go to the extended job selection. Now select menu option Goto / Job Statistics:
This gives statistical output:
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