[ABAP] HTML-Templates verwenden

* Pflege der HTML-Templates erfolgt in der Transaktion SMW0
DATA: it_merge_table TYPE swww_t_merge_table.
DATA: it_html_table TYPE swww_t_html_table.

* !USERID! im Template mit Benutzernamen ersetzen
DATA(lv_merge_item1) = VALUE swww_t_merge_item( name = '!USERID!' command = 'R' html = VALUE #( ( |{ sy-uname }| ) ) ).
APPEND lv_merge_item1 TO it_merge_table.
* !DATE! im Template mit Systemdatum ersetzen
DATA(lv_merge_item2) = VALUE swww_t_merge_item( name = '!DATE!' command = 'R' html = VALUE #( ( |{ sy-datum }| ) ) ).
APPEND lv_merge_item2 TO it_merge_table.

CALL FUNCTION 'WWW_HTML_MERGER'
  EXPORTING
    template           = 'ZZ_HTML_TEMPLATE_TEST' " Name des Templates
  IMPORTING
    html_table         = it_html_table
  CHANGING
    merge_table        = it_merge_table
  EXCEPTIONS
    template_not_found = 1
    OTHERS             = 2.

IF sy-subrc = 0.
  LOOP AT it_html_table INTO DATA(lv_line).
    WRITE / lv_line-line.
  ENDLOOP.
ENDIF.

Links