E-Mail is indispensable in business life, and automatic mail services can be used extensively at each job stage or for information purposes. SAP S/4 HANA introduced a brand-new feature with an easier, convenient and efficient e-mail template. We can use this e-mail template integrated with SAP Core Data Services (CDS).
- HTML and CSS codes are supported by the CDS E-Mail Template feature.
- The e-mail template can be easily used in any process / situation.
- The e-Mail template can be created in any language.
- With ABAP code, the e-mail template can be called very easily.
- All fields in CDS can be added dynamically and used in the e-mail template.
- The CDS e-mail template can only be called with primary keys, the table cannot be called. Only one line can be used.
- Basic level of CDS View creation knowledge
- Good level of ABAP knowledge
- Basic level of HTML and CSS knowledge
Let’s proceed with the example of sending e-mail header data by mail, such as the sales order number and the time it was created, right after the sales document is created.
First, the CDS View needs to be created with Eclipse ADT.
The following file path can be followed by selecting the package to be created with the E-Mail template ‘’se80’’ transaction code.
Se80->Z* Package->Create->More->E-Mail Template
Pre-created CDS View name and e-mail template name are defined.
English language definition is defaulted automatically. If you want to create a template in different languages the “Add” button in the box can be selected.
The short code of the language to be chosen can be selected in the pop-up window.
Double click on the relevant line for the language to be changed. Next, we can write our codes in the E-Mail header and body parts. In addition, since HTML and CSS codes are supported, different themes can be used.
The CDS View areas we have defined are shown at the bottom left. If a new field is to be added, the CDS view can be added, and the new field can be checked by opening the E-Mail Template screen again. Nothing needs to be done right after adding CDS View. The fields that appear at the bottom left of the E-Mail Template will automatically appear.
Immediately after the codes are written the changes can be saved and reproduced using the ‘Generate Text Body’ button.
The preview process can be done without sending an e-mail.
We can test our development by running the program (the code is shown subsequently below). We can use the mail template by entering the sales document, recipient mail address, and mail template language information on the selection screen of the program.
We can view the sending mail with the SOST transaction code.
CDS View Code
If it is desired to add a picture to the E-Mail Template, there are two options as follows.
- The picture is called by writing it in the Abap code. (html-> <img src = “cid: Solvia.png”> can be defined and called in HTML code.)
- It can be used directly between HTML lines by finding the encoded version of the related visual. We can use the site https://www.base64-image.de/ as an example.
<img src=”data:image/png;base64, iV…. “>
HTML Template Code