Skip to Content

Display Base64 encoded files in cl_gui_html_viewer

Dear NG,

I'm searching for a possibility to display files in cl_gui_html_viewer which are Base64 encoded.

My scenario:

I'm calling a WebService via ABAP proxy using the PI infrastructure to receive a document from a remote system (non-SAP).

The document will be fetched, Base64 encoded and provided as XString by the ABAP proxy.

Having the document data as XString, I'd like to pass it to the cl_gui_html_viewer for display, the problem seems to be that the data are encoded and I need to decode them first, before I'm able to split it into smaller pieces, transfer them to an internal table an pass it to the viewer.

How do I decode the XString? I found options to decode a String, or a field type X, but nothing for XString.

Any suggestions?

Thanks a lot in advance.

Regards Harry

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 09, 2012 at 03:19 PM


    Check this link

    check FM - SSFC_BASE64_DECODE

    See below link for other set of FM

    best regards,


    Add a comment
    10|10000 characters needed characters exceeded

    • Well, then combine the two decodings: character encoded -> characters -> base64, like this:

      form test.

      data: lv_xbase64 type xstring,
      lv_base64 type string,
      lv_decoded type string,
      lo_conv type ref to cl_abap_conv_in_ce.

      lv_xbase64 = '534756736247386756323979624751684953453D'.

      lo_conv = cl_abap_conv_in_ce=>create( ).
      lo_conv->convert( exporting input = lv_xbase64
      importing data = lv_base64 ).
      lv_decoded = cl_http_utility=>decode_base64( lv_base64 ).
      write: / lv_decoded. " writes 'Hello World!!!


      The converter instance uses the default encoding of my SAP system, which is ISO-8859-1. It may as well be UTF-8, since the base64 character set has the same code values in these two encodings. If you are a some other encoding, you may pass encoding = 'UTF-8' in the create method of the converter.

      If you have many xstrings to decode this way, you may reuse the converter instance.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.