Skip to Content
Author's profile photo Abhilash A

SAP Data Services – Mailing Functionality

This document describes the inbuilt capability of SAP Data Services(DS) to send emails to the support user or user group. SMTP_To() function or MAIL_To() inbuilt functions help SAP DS application to send email across recipient support user(s). This document exposes the SMTP configurations and  working functionality of SMTP_To() function.


     SMTP_To() Function:

SMTP_To() function helps to send the job information through an e-mail to the recipient(s) via an SMTP server. It also captures the specified number of lines in the trace and error logs. This function is typically used in a script, for example in a conditional clause, while loop, or try-catch block.


Syntax:

smtp_to(<recipients_list>, <subject>, <message>, <number_of_trace_log_lines>, <number_of_error_log_lines>)


Parameter’s description:

Parameter

Description

Recipients List

Recipient mail or mail list should be provided in this parameter.

Subject

Subject of the email should be mentioned in this parameter.

Message

Message body with the complete job information should be framed and provided in this parameter.

Number of Trace log lines

Non negative integer value should be specified. Those number of last lines of the trace log will be printed in the email.

Number of Error log lines

Non negative integer value should be specified. Those number of last lines of the error log will be printed in the email.

Pre-requisties to use SMTP_To() function,

    • SMTP server should be configured on the server machine and
    • Host server and Sender email address should be maintained in SAP BODS Server Manager.


SMTP Server Configurations:

     1.Installing SMTP Tools in Server:

To configure SMTP server on the machine, the server machine should have SMTP tools installed on it.

For this, Launch Server Manager, under Features Summary:

    1. Select “Add Features” option available at the right.
    2. Select SMTP Server feature.
    3. Click ‘Install’ as in below figures and follow the required steps.

                    /wp-content/uploads/2015/10/1_818120.png

                   /wp-content/uploads/2015/10/2_818124.png

    2. Adding SMTP Server:

           To add SMTP server on the machine,

               Go to Adminstrative Tools >> Internet Information Services (IIS) >> Expand ‘Server’>> Right click on ‘SMTP Virtual Sever’ >> Select ‘Properties’

              /wp-content/uploads/2015/10/3_818125.png

         When you select properties following properties Screen opens. Provide the IP address in ‘General’ tab.

              /wp-content/uploads/2015/10/4_818130.png             

    Next follow the below steps,

        a. Go to ‘Access’ tab >> Select ‘Authentication’ box >> Check ‘Anonymous access’ option >> Select ‘Ok’

              /wp-content/uploads/2015/10/5_818129.png

        Select ‘Connection’ box >> Check ‘All except the list below’ >> Select ‘Ok’

              /wp-content/uploads/2015/10/6_818131.png

         Select ‘Relay’ box >> Check ‘All except the list below’ >> Select ‘Ok’

              /wp-content/uploads/2015/10/6_1_818137.png

     b. Go to ‘Delivery’ Tab

            Select ‘Outbound Security’ >> Check ‘Anonymous access’ >> Select ‘Ok’

               /wp-content/uploads/2015/10/7_818135.png                            

        Select ‘Advanced’ box >> Provide the server domain or IP address(same as provided‘General’ Tab) >> Select ‘Ok’

                /wp-content/uploads/2015/10/8_818147.png

      That’s all in the IIS. Now we have to jump to SAP BODS Server Manager to configure smtp settings for smtp_to() function.

  3.Adding sender email id in SAP DS Server Manager:

            Go to SAP DS Server Manger >> “Miscellaneous” Tab >> Proved Server and Sender Email Id >> Select ‘Apply’ >> Restart the Server Manager

                 /wp-content/uploads/2015/10/9__818149.png

    4. SAP BODS sample Batch Job:

Below figure shows the data flow designed in a batch job which captures the error details when the job got terminated and sends email.

To log an error wrong path is given to the source file and Try-Catch block is used to capture this exceptional error of the job and used a Script inside to send the email containing all the error job information.

     /wp-content/uploads/2015/10/10_818159.png

     /wp-content/uploads/2015/10/11_818160.png

     

   Above script is having two examples,

    1.Provided ‘Message body for email’ manually as ‘Job Stopped due to Error’:

       Code:

               smtp_to( ‘abc123@gmail.com ,xyz999@gmail.com‘,’JOB ERROR STATUS1’, ‘Job stopped due to Error’, 10, 10);

     2. Passed ‘error_message()’ function to a variable and used this variable in the ‘Message’ parameter dynamically.

       Code:

smtp_to(‘abc123@gmail.com ,xyz999@gmail.com,pqr111@yahoo.com‘,’JOB ERROR STATUS2’, ‘{$G_ErrorMessage}’, 10, 10);


An email will be sent to all the recipients mentioning the  Error Message and Last 10 lines of Trace and Monitor logs of the job. 


  

          


Assigned tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Really helpful. Thanks for this.

      Author's profile photo abhi a
      abhi a
      Blog Post Author

      Welcome Deepak 🙂 . Thanks!

      Author's profile photo Brijesh Miglani
      Brijesh Miglani

      Very useful inforamtion. can you help me to make authentication smtp call.

      How to send password while calling smtp_to function ?

      Thanks, Brijesh

      Author's profile photo Ravi kiran Pagidi
      Ravi kiran Pagidi

      Very useful information explained step by step.

      Author's profile photo Francisco Gaitan
      Francisco Gaitan

      Hello, do you know how it works with smtp.office365.com?, because you said " When you select properties following properties Screen opens. Provide the IP address in ‘General’ tab.", but wht IP address?, I think this explanation works with a local smtp server , but it is not the reality in companies, now most of them use cloud mail service.

      Thank you

      Author's profile photo Prateek Jain
      Prateek Jain

      Wonder how can we get the execution time of the job?

      I know that its stored in AL_HISTORY

      SELECT EXECUTION_TIME  FROM AL_HISTORY