Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
abhi2636
Participant
38,393

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.

                   

                  

    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'

             

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

                           

    Next follow the below steps,

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

             

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

             

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

             

     b. Go to ‘Delivery’ Tab

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

                                           

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

               

      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

                

    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.

    

    

     

   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. 


  

          


6 Comments
Labels in this area