Skip to Content
Technical Articles
Author's profile photo Nazia Khatoon

Email template in S/4 HANA using OOPs concept


Email template feature explained in very simple way using OOPs concept.

Very often we get a business requirement to send email with table format. Before S/4 HANA we use to design the table using HTML <table> <th> <td> tags which is tedious  and then use the conventional way of calling FM to send the mail but after S/4 HANA release SAP has ease by providing email template feature which can be send by calling methods.

Before S/4 HANA:

We first use to declare variables like shown below


Variable Declaration

we use to fill Subject detail and mail body content using html tags and append it to Internal table as shown below


Subject and Mail body content

to design table we use below HTML tags for header section and append to internal table


HTML table tags for Header section

Loop through internal table to populate the table data using concatenate function as shown below


Table data

then conventional way of using FM to send the mail to the recipients as shown below


Calling FM to send mail


After S/4 HANA:

With basic HTML knowledge we can easily design the email templates with one or more table content in it.

  1. Go to transaction SE80 and select your package, right click on it and select the Email template and give any Z name as shown below


Email template

2. Under text tab then design the subject line and email body content

to add any dynamic text without using CDS views in either subject line or email body we have to give the placeholder variable names in {{ }} as highlighted in below image i.e., SID, NOTE


Dynamic text


3. Simply add the html tags to design table header in the already generated BODY HTML section  as shown below


Table header


4. To fill the table data we need to insert the placeholder name in {{ }} which can have logic in our ABAP code i.e., TabContent


Table data

one of the coolest feature, it allow you to preview your email content


Email content preview


4. ABAP code to fill the dynamic variables declared in the email content and to send the mail to the recipients



5. Simple REPLACE statement to pass the required data to the placeholders declared in the email template


Placeholder data

6. Filling the table data with LV_CONTENT and calling methods to build the HTML for sending


Methods to build HTML

7. Finally adding the mail recipients and calling send mail method


Send mail method call

Sample mail preview


Mail sample


I hope this blog will be useful to technical consultants who are looking to start using Email template feature with table format without using CDS views. 🙂

For more info on this topic please follow the below link


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Alex Necula
      Alex Necula

      Didn't know this feature exists, thank you for taking the time to show us. 🙂

      Author's profile photo Varun Varshney
      Varun Varshney

      Hello @Nazia Khatoon ,

      Thanks for the nice blog.
      Is it possible to convert all the body(html) of an email template to pdf(without smartform appraoch) as we need to show this body of email which is email template in our case as pdf attachment.
      I tried converting this htlm body - xstring-binary and pass it to add attachment of class bcs. PDF got generated but unable to open , probably due to incorrect conversion ?

      Author's profile photo Nazia Khatoon
      Nazia Khatoon
      Blog Post Author

      Hello Varun Varshney,

      Thanks for the comment.

      Even I tried the possibility but PDF file is not supporting as the data has HTML tags in it so its not possible to display.