HTML Template in ABAP

HTML Template in ABAP is a powerfull to tool to save template for document, SAP long texts and email in HTML format in SAP.

The SAP HTML Template contains more than the content with layout and data reference to generate dynamic Email and/or rich text.

These fields will be replaced by the corresponding value.

SAP HTML Template Tcode

First, you have to implement the HTML template. Use WYSWYG tools or even a notepad editor.
Check here how to set ABAP Synthax in Notepad++.

Once the HMTL file is ready, run the tcode SMW0 to enter the SAP Web Repository.

The SMW0 Tcode can be used to store HMTL Template as well as to upload Binary data ( such as Picture, PDF … )

for HTML files, select the first option : HTML templates for WebRFC applications.

SAP Web Repository - html template

HTML Template Uploading

  1. Click to Create a new HTML file in SAP Web Repository.
  2. Fill a name and a description
  3. Upload the created HTML

Here a simple of HTML Template for an email

SAP Template Attributes

Once uploaded, the system generates some attributes for HTML such as:

  • fileextension .html
  • filename C:tempHTML_TEMPLATE.html
  • filesize 693
  • mimetype text/html
  • version 00001

You can add your own attributes ( to handle language for example )

Handling HTML Template in ABAP

SAP offers a function module to Merge two HTML.

The function Module WWW_HTML_MERGER can remplace the variables declared in the HTML template with their value.

The input:

  • TEMPLATE: the name of the Template in the SAP Web Repository
  • MERGE_TABLE: is the table containing the variables and their values:
    • name(30): The name of Variable : placeholder: ‘<!list!>’
    • html like w3html occurs 100, ” HTML code to be inserted ( it is a table ! )
    • command: the action to take place when merging.
      • ‘?’-replace placeholderline(default)
      • ‘b’ insert before placeholder line
      • a’ insert after placeholder line
      • ‘r’ replace placeholder only

The output:

  • HTML_TABLE: type SWWW_T_HTML_TABLE and containing HTML line (255)

ABAP Sample How to handle HTML Template in SAP

Here an ABAP Tutorial sample code, to retrieve a template and exchange the variables with the data.

SAP Transporting HTML Template

When aving a HTML template in the SAP Web Repository, you will be asked to select a Transport. You can also save them locally in you are making some ABAP testing.

In Transport, the line corresponding to the Template:

  • Description: Web Reporting/Internet Transaction Server HTML Templates
  • Program Id: R3TR
  • Object Type: W3HT

If you want to even deeper into HTML Template, visit the official documentaire at