E-Mail Template with CDS in SAP S/4HANA

Share
Share on facebook
Share on twitter
Share on linkedin
Share on pocket

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 also use CDS, which is the technology of SAP, and the e-mail template integrated.

Advantages

  • HTML and CSS codes are supported for CDS E-Mail Template feature.
  • The e-mail template can be easily used in any process / situation.
  • E-Mail template can be created in any language.
  • With the ABAP code, the E-Mail template can be called very easily.
  • Just all fields belong to CDS can be added dynamically and use in e-mail template.

Disadvantages

  • CDS e-mail template can only be called with primary keys, the table cannot be called. Only one line can be used.

 Prerequisites:

  • 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 of all, 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 comes 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 with the help of the box.

It will be sufficient to double click on the relevant line for the language to be changed. Following it, we can write our codes in the E-Mail header and body parts. In addition, since HTML and CSS codes are supported, we can use different themes.

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, changes can be saved and reproduced using the ‘Generate Text Body’ button.

The preview process can be done without sending an e-mail.

In English,

In Turkish,

We can test our development by running the program with the codes at the bottom. We can use the mail template by giving 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

Report Code

 If it is desired to add a picture to the E-Mail Template, there are two options as follows.

  • The relevant 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

Supporting your business processes with emerging technologies is the main goal of our business.

exp head deco 3
icon our expertise

Thank you

You’ll receive an email with download link shortly.

If not, reach us on solviamarketing@solviads.com

Created by icon 54from the Noun Project

Thank you

You’ll receive an email shortly.

If not, reach us on solviamarketing@solviads.com