MIME repository is a safe solution in aspect, it is keeping the file as it is, without any transitions.

  • Create your text based file (HTML,txt etc.) with UTF-8 encoding
  • Launch transaction SE80 and choose MIME repository, and upload it to a desired folder, and remember the path
    (in new NW releases, you need to enable the button to display the MIME repository button under settings, because by default only the repository browser is displayed).
    Being an active ABAP Developer Tools user already, you can launch transaction SO2_MIME_REPOSITORY alternatively 😉
  • Use the code below to get it as string table
  lo_mr_api   TYPE REF TO if_mr_api,
  lv_text_x   TYPE xstring,
  lo_conv_in  TYPE REF TO cl_abap_conv_in_ce,
  lv_bom      TYPE x LENGTH 3,
  lv_string   TYPE string,
  lt_string   TYPE string_table.

lo_mr_api = cl_mime_repository_api=>get_api( ).

    i_url     = iv_mime_path
    e_content = lv_text_x
    parameter_missing  = 1
    error_occured      = 2
    not_found          = 3
    permission_failure = 4
    OTHERS             = 5

"Trick to Remove the BOM, when exists
lv_bom = lv_text_x.
IF lv_bom EQ cl_abap_char_utilities=>byte_order_mark_utf8.
  lv_text_x = lv_text_x+3.

lo_conv_in  = cl_abap_conv_in_ce=>create( encoding = 'UTF-8' ).

    input   = lv_text_x
    data    = lv_string
SPLIT lv_string AT cl_abap_char_utilities=>cr_lf INTO TABLE lt_string.

Do not forget to handle exceptions properly.

Hint: if you would like to use the files uploaded to MIME repository as eMail templates, you can pack them with Function Module WWW_PACK_TABLE. (One step more: you can use placeholders in your template and replace them with current values before packing )

Unfortunately merge functions are limited to line length 255 for the templates uploaded in tx. SMW0.  Other thing is, that however you upload content encoded with UTF-8 in SMW0, the emails sent out have encoding problems, and wrongly displayed characters, due SAP is managing there only ANSI properly, however the system is unicode…

Share this content: