Email Notifications in SAP Data Services

Utilizing email notifications in SAP Data Services jobs is a great way to inform users when a job finishes successfully or fails.  Setting up email notifications is relatively straightforward and involves some simple configuration on the job server and inserting Try/Catch blocks and Script objects in the Designer along with the smtp_to function.  Below describes the process to use the SMTP email function.

The first step is to log into the server hosting the job server and launch the Data Services Server Manager.  Select the Miscellaneous tab and enter the email server in the Server field and an email address you would like to appear as the sender in the Sender field.  Click the Close and Restart button to enable the changes.

2015-10-12_7-50-20

Once the job server is configured we can setup the Data Services job in Designer.   Log into the Designer and insert a Try object before the work flow or data flow to be checked, and insert a Catch object block after the object being checked.  In the example below I also inserted a Script object called Success_Email which will send an email notification if the job passes successfully.

2015-10-12_7-45-11

The Catch object is editable and has a number of different exceptions which it can handle.  Open the Catch object and drag the Script object into the workspace below.  Open the Script object to begin creating a script to send emails.

2015-10-12_8-20-34

In the Script Editor window click the functions button, then click System Functions and select the smtp_to function and click next.

2015-10-12_8-22-38

The Define Input Parameter(s) window opens where you can enter the necessary information for the email message.

2015-10-12_8-23-47

I typically include the job name, error name, and error message in email notifications for failed jobs.  Below is an example of a smtp_to function used for jobs at my current company.

smtp_to('emailaddress@email.com', 'Data Services Job Failed: ' || job_name() || ' Error Number: ' || error_number(), 'Error Message: ' || error_message(), 20, 20);

Below is a screenshot of an email notification informing the user the Data Services job has failed.  The email includes the name of the job in the subject line and also contains detailed information from the job log and error log.  The error below reveals there was a primary key constraint on a target table and users can easily determine this from the email message without needing to log into the Data Services Management Console.

2015-10-12_11-22-01

Leave a comment