# SAP Batch Job Restart on Error

IT-Conductor offers an automation solution for handling the restart of SAP batch jobs when they fail. This covers the detection of aborted batch jobs, automatic restart of the failed jobs, and notification of the appropriate job owner, including the delivery of the job log as an attachment. In advanced cases, IT-Conductor can also restart the job with a specific variant and/or from a specific step. Depending on the complexity of the conditions on how you want to restart a particular job, IT-Conductor can be configured to execute this process to reduce the MTTR (Mean Time to Repair).

### **Prerequisites** <a href="#prerequisite-requirements" id="prerequisite-requirements"></a>

1. In your SAP environment, create a dedicated SAP service user to monitor and execute the jobs.
2. In the IT-Conductor main menu, navigate to **Support → Downloads → SAP Security Downloads**, and download the **SAP NW Batch Scheduling Role Import** file.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FbAkzEEICG3souq8uQuxt%2FSAP%20Security%20Downloads.png?alt=media&#x26;token=d173764a-87f8-42f8-bc10-7613a4593562" alt=""><figcaption><p>Figure 1: SAP Security Downloads</p></figcaption></figure>

3. Assign this role to the recently created job monitoring SAP user using the PFCG transaction code.
4. Navigate to a system in the IT-Conductor Service Grid where you’ll be creating batch jobs and select **Accounts**.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FnnFZBQd3H805inJT5zf9%2FSelecting%20Accounts%20in%20IT-Conductor%20Service%20Grid.png?alt=media&#x26;token=39a473ef-1fdf-44d6-86fd-d4ac2c238397" alt=""><figcaption><p>Figure 2: Selecting Accounts in IT-Conductor Service Grid</p></figcaption></figure>

5. Create a [robot user](https://docs.itconductor.com/users-guide/account-administration/robot-user-creation) in IT-Conductor and associate it with the previously created SAP account. Give the user a descriptive name.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FAoTptg96Mb9iwKNLiUMG%2FApplication%20Accounts.png?alt=media&#x26;token=3b716703-c00c-46a3-91f9-20032d5e6ffa" alt=""><figcaption><p>Figure 3: Application’s Accounts</p></figcaption></figure>

### **Create Threshold Override for Job Restart**

You may [create a threshold override](https://docs.itconductor.com/users-guide/notifications/creating-threshold-overrides) from a template. IT-Conductor has templates for all metrics. In this case, since we want to restart a job after it’s failed or it’s been aborted, we’re going to navigate to the existing overrides for this metric.

1. Navigate to **System → Background jobs → Aborted → Threshold** override.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FOcTU4LxBaPK5fM1lZZc2%2FSystem%20Aborted%20Jobs.png?alt=media&#x26;token=6ba83dac-101c-4528-9ab8-b2f1be2853a8" alt=""><figcaption><p>Figure 4: System Aborted Jobs</p></figcaption></figure>

2. Click the **Create Override from the Templates** icon.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FrGRVp2QwMneRCZ6f7jI4%2FList%20of%20Overrides.png?alt=media&#x26;token=f9e4b6de-9400-4fb3-9c55-44dff0cb6606" alt=""><figcaption><p>Figure 5: List of Overrides</p></figcaption></figure>

3. Click the template to create a new override.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2F91BykwBAbWuppG2q7rP0%2FList%20of%20Aborted%20Jobs%20Templates.png?alt=media&#x26;token=7792c6c2-9475-4935-bf43-560a50c122a7" alt=""><figcaption><p>Figure 6: List of Aborted Jobs Templates</p></figcaption></figure>

4. Click **Save** to complete the override configuration.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FJ6uI8hTrgrTd1vq7TCu0%2FAborted%20Jobs%20Template.png?alt=media&#x26;token=46c45fa1-b079-44d9-b566-df4a7079f673" alt=""><figcaption><p>Figure 7: Aborted Jobs Template</p></figcaption></figure>

### **Create a Recovery Activity to Restart the Job**

1. Click back to the recently created Threshold Override and scroll down to the “Recovery” section.
2. To turn on the recovery activity, select “Warning”, or “Alarm” on the “Recovery on” option.
   1. If you select “Warning”, the recovery activity will run when the Warning threshold is exceeded.
   2. If you select “Alarm”, the recovery activity will run when the defined Alarm threshold is breached.

A recovery activity is an option that allows you to automatically take action whenever an incident occurs in IT-Conductor. Recovery activities are predefined by IT-Conductor Support based on the required automation process or scenario.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FmTWqmUOsmBC9lquUg090%2FRecovery%20Options.png?alt=media&#x26;token=85652b15-b170-43ff-87bf-d476500c6b8a" alt=""><figcaption><p>Figure 8: Recovery Options</p></figcaption></figure>

3. Select a recovery activity from the “Recovery” list. In this case, we’re going to select the activity for Copy and Start Job.

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FESeFiu00EyAUMIdxlTim%2FList%20of%20Recovery%20Activities.png?alt=media&#x26;token=a7e7d7ea-3756-45d0-888c-1699971e5a23" alt=""><figcaption><p>Figure 9: List of Recovery Activities</p></figcaption></figure>

4. Select the previously created automation user as “Owner”.
5. Check the “Alert” box to be alerted whenever this recovery activity occurs.
6. Save Recovery Activity.

If you wish to be notified when a job has failed, select either “Warning” or “Alarm” in the “Alert On” option. (Optional)

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2F4zhZNb0EO0yOuL3gJUbC%2FTurning%20on%20Alerts%20on%20Threshold%20Overrides.png?alt=media&#x26;token=bfce4b0d-92e7-488e-bdd1-86658093c726" alt=""><figcaption><p>Figure 10: Turning on Alerts on Threshold Overrides</p></figcaption></figure>

### **Batch Job Recovery Activity in IT-Conductor**

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FMtF7BZ9cXNLCZGZk2Snp%2FStatus%20of%20Background%20Jobs.png?alt=media&#x26;token=a37ff4c2-549e-43f8-bf8a-6bae89147985" alt=""><figcaption><p>Figure 11: Status of Background Jobs</p></figcaption></figure>

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FUmooPN333TEBIHMukTgt%2FAlerts%20Generated%20from%20the%20Failed%20Jobs.png?alt=media&#x26;token=bba1fd22-d05e-46d1-bc11-9e0e129c340b" alt=""><figcaption><p>Figure 12: Alerts Generated from the Failed Jobs</p></figcaption></figure>

<figure><img src="https://377464071-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXhp08OmU8050PePmMgDt%2Fuploads%2FuwQjIdR9f8vEdoLmuba2%2FRecovery%20Activity%20Execution%20Log.png?alt=media&#x26;token=4fd87de9-3921-49dd-affb-a22a7ded73ca" alt=""><figcaption><p>Figure 13: Recovery Activity Execution Log</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.itconductor.com/user-guide/automation/sap-batch-job-restart-on-error.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
