Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

XML STRING TO XML UTF-8

0 Kudos

Hello,

I have an xml string variable like that contains spcecial characteres like "ñ" i try to to convert to UTF-8 and save it but when I do that I cannot see the values of the XML. please see my example code:

DATA: lv_e_utf8                 TYPE xstring,
      lv_i_keep_trailing_blanks TYPE xfeld,
      lv_i_xml                  TYPE string,
      lv_other                  TYPE c.
<br>
  DATA: v_length TYPE i,
        v_base64 TYPE string. DATA: it_xml_tempo TYPE string       OCCURS 0 WITH HEADER LINE,
       it_temporal TYPE string OCCURS 0 WITH HEADER LINE.
lv_i_xml = '<inicio><nombre>Luis Ñañamito</nombre></inicio>'.
  DATA: lv_ruta TYPE string.
CONCATENATE 'c:/complemento/'
               'PRUEBA.xml' INTO lv_ruta.
  CLEAR: it_xml_tempo.  REFRESH: it_xml_tempo.  FREE: it_xml_tempo.  APPEND lv_i_xml TO it_xml_tempo.  DATA: V_UTF8 TYPE XSTRING.
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text           = lv_i_xml
*     MIMETYPE       = ' '
     ENCODING       = '4110'
   IMPORTING<br>
     BUFFER         = V_UTF8
            .
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

  APPEND  V_UTF8 TO it_temporal.
CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING<br>
      filename = lv_ruta
      filetype = 'ASC'
    TABLES<br>
      data_tab = it_temporal. "it_xml_tempo.

When I save my field and open I only see:

What I need to do to convert my xml file into UTF-8 format to d

2 REPLIES 2

Sandra_Rossi
Active Contributor

Function module GUI_DOWNLOAD is obsolete.

Replaced with method GUI_DOWNLOAD of CL_GUI_FRONTEND_SERVICES.

About the parameter FILETYPE, keep consistency, you should never mix characters with bytes, and bytes with characters (except when encoding/decoding):

XSTRING = bytes = BINary

STRING = characters = ASCii

Melina404
Newcomer
0 Kudos

Hi @luisrobertofrancomx 

I'll appreciate you can share the solution you found, as we are facing same issue. 

Thank you !