<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: xml send to application server null character issue in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695900#M2017992</link>
    <description>&lt;P&gt;Be careful, your code was full of &amp;lt;br&amp;gt; so people might not do the effort of reading it. Your question, formatted correctly:&lt;/P&gt;&lt;P&gt;i started building my file :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lo_ixml = cl_ixml=&amp;gt;create( ).
lo_document = lo_ixml-&amp;gt;create_document( ).
lo_header = lo_document-&amp;gt;create_simple_element(
                 name   = 'DHL-SHIPMENT-IMPORT'
                 parent = lo_document ).
lo_auth_data = lo_document-&amp;gt;create_simple_element(
                 name   = 'AUTH_DATA'
                 parent = lo_header ).
lo_auth_group_id = lo_document-&amp;gt;create_simple_element(
                 name   = 'AUTH_GROUP_ID'
                 parent = lo_auth_data
                 value  = 'Default group' ).
...&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then i make the transformation and transfert&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  lo_stream_factory = lo_ixml-&amp;gt;create_stream_factory( ).
  lo_encoding = lo_ixml-&amp;gt;create_encoding( byte_order = 0
                                         character_set = 'UTF-8' ).
*document
  DATA b_xml TYPE xstring.
  DATA lo_ostream TYPE REF TO if_ixml_ostream.
  lo_ostream = lo_stream_factory-&amp;gt;create_ostream_xstring( b_xml ).
  CALL METHOD lo_ostream-&amp;gt;set_encoding
    EXPORTING
      encoding = lo_encoding.
  CALL METHOD lo_document-&amp;gt;render
    EXPORTING
      ostream   = lo_ostream
      recursive = 'X'.
  DATA g_resize TYPE i.
  g_resize = lo_ostream-&amp;gt;get_num_written_raw( ).
  DATA: ex_tab TYPE TABLE OF x255,
        ls_tab TYPE x255.
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = b_xml
    TABLES
      binary_tab = ex_tab.
*transfer file on the application server.
  READ TABLE a_lt_seg ASSIGNING &amp;lt;fs_seg&amp;gt; INDEX 1.
  CONCATENATE dset &amp;lt;fs_seg&amp;gt;-tknum '.xml' INTO dset.
  TRY.
      OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
      LOOP AT ex_tab INTO ls_tab.
        g_resize = xSTRLEN( ls_tab ).
        TRANSFER ls_tab TO dset LENGTH g_resize.
      ENDLOOP.
    CATCH cx_root INTO lo_exception.
*     Gets error message
      CALL METHOD lo_exception-&amp;gt;if_message~get_text
        RECEIVING
          result = l_message.
      MESSAGE l_message
         TYPE c_error.
  ENDTRY.
  CLOSE DATASET dset.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 07 May 2023 13:04:50 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-05-07T13:04:50Z</dc:date>
    <item>
      <title>xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695896#M2017988</link>
      <description>&lt;P&gt;Hello expert, i'm facing an issue with xml file download on an application server and i went threw many threads such like &lt;A href="https://answers.sap.com/questions/6618466/abap-send-xml-to-application-server.html"&gt;like this one&lt;/A&gt; but i can't figure what i'am missing and why my file doesn't end with the last row.&lt;/P&gt;
  &lt;P&gt;i started building my file :&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt; lo_ixml = cl_ixml=&amp;gt;create( ).&amp;lt;br&amp;gt; lo_document = lo_ixml-&amp;gt;create_document( ).&amp;lt;br&amp;gt;lo_header = lo_document-&amp;gt;create_simple_element(&amp;lt;br&amp;gt; name = 'DHL-SHIPMENT-IMPORT'&amp;lt;br&amp;gt; parent = lo_document ).&amp;lt;br&amp;gt;*auth data&amp;lt;br&amp;gt; lo_auth_data = lo_document-&amp;gt;create_simple_element(&amp;lt;br&amp;gt; name = 'AUTH_DATA'&amp;lt;br&amp;gt; parent = lo_header ).&amp;lt;br&amp;gt;lo_auth_group_id = lo_document-&amp;gt;create_simple_element(&amp;lt;br&amp;gt; name = 'AUTH_GROUP_ID'&amp;lt;br&amp;gt; parent = lo_auth_data&amp;lt;br&amp;gt; value = 'Default group' ). etc...&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;then i make the transformation and transfert&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;  lo_stream_factory = lo_ixml-&amp;gt;create_stream_factory( ).&amp;lt;br&amp;gt;  lo_encoding = lo_ixml-&amp;gt;create_encoding( byte_order = 0&amp;lt;br&amp;gt;                                         character_set = 'UTF-8' ).&amp;lt;br&amp;gt;*document&amp;lt;br&amp;gt;  DATA b_xml TYPE xstring.&amp;lt;br&amp;gt;  DATA lo_ostream TYPE REF TO if_ixml_ostream.&amp;lt;br&amp;gt;  lo_ostream = lo_stream_factory-&amp;gt;create_ostream_xstring( b_xml ).&amp;lt;br&amp;gt;  CALL METHOD lo_ostream-&amp;gt;set_encoding&amp;lt;br&amp;gt;    EXPORTING&amp;lt;br&amp;gt;      encoding = lo_encoding.&amp;lt;br&amp;gt;  CALL METHOD lo_document-&amp;gt;render&amp;lt;br&amp;gt;    EXPORTING&amp;lt;br&amp;gt;      ostream   = lo_ostream&amp;lt;br&amp;gt;      recursive = 'X'.&amp;lt;br&amp;gt;  DATA g_resize TYPE i.&amp;lt;br&amp;gt;  g_resize = lo_ostream-&amp;gt;get_num_written_raw( ).&amp;lt;br&amp;gt;  DATA: ex_tab TYPE TABLE OF x255,&amp;lt;br&amp;gt;        ls_tab TYPE x255.&amp;lt;br&amp;gt;  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'&amp;lt;br&amp;gt;    EXPORTING&amp;lt;br&amp;gt;      buffer     = b_xml&amp;lt;br&amp;gt;    TABLES&amp;lt;br&amp;gt;      binary_tab = ex_tab.&amp;lt;br&amp;gt;*transfer file on the application server.&amp;lt;br&amp;gt;  READ TABLE a_lt_seg ASSIGNING &amp;lt;fs_seg&amp;gt; INDEX 1.&amp;lt;br&amp;gt;  CONCATENATE dset &amp;lt;fs_seg&amp;gt;-tknum '.xml' INTO dset.&amp;lt;br&amp;gt;  TRY.&amp;lt;br&amp;gt;      OPEN DATASET dset FOR OUTPUT IN BINARY MODE.&amp;lt;br&amp;gt;      LOOP AT ex_tab INTO ls_tab.&amp;lt;br&amp;gt;        g_resize = xSTRLEN( ls_tab ).&amp;lt;br&amp;gt;        TRANSFER ls_tab TO dset LENGTH g_resize.&amp;lt;br&amp;gt;      ENDLOOP.&amp;lt;br&amp;gt;    CATCH cx_root INTO lo_exception.&amp;lt;br&amp;gt;*     Gets error message&amp;lt;br&amp;gt;      CALL METHOD lo_exception-&amp;gt;if_message~get_text&amp;lt;br&amp;gt;        RECEIVING&amp;lt;br&amp;gt;          result = l_message.&amp;lt;br&amp;gt;      MESSAGE l_message&amp;lt;br&amp;gt;         TYPE c_error.&amp;lt;br&amp;gt;  ENDTRY.&amp;lt;br&amp;gt;  CLOSE DATASET dset.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 May 2023 15:10:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695896#M2017988</guid>
      <dc:creator>crepmaster</dc:creator>
      <dc:date>2023-05-04T15:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695897#M2017989</link>
      <description>&lt;P&gt;Hello  &lt;SPAN class="mention-scrubbed"&gt;marco_sposa&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;The null character issue may occur while transferring the XML file to the application server. To avoid this issue, you can convert the XML string to a binary string using the SCMS_XSTRING_TO_BINARY function. This function converts a string of type XSTRING to a table of type X255, which can be transferred to the application server without any null character issues.&lt;/P&gt;&lt;P&gt;In the code provided, this conversion is done using the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'&lt;BR /&gt;EXPORTING&lt;BR /&gt;buffer     = b_xml&lt;BR /&gt;TABLES&lt;BR /&gt;binary_tab = ex_tab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After the conversion, the binary data can be transferred to the application server using the TRANSFER statement with the LENGTH parameter to ensure that the entire binary string is transferred.&lt;/P&gt;&lt;P&gt;TRANSFER ls_tab TO dset LENGTH g_resize.&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 18:11:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695897#M2017989</guid>
      <dc:creator>Harish_Vatsa</dc:creator>
      <dc:date>2023-05-04T18:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695898#M2017990</link>
      <description>&lt;P&gt;sorry may be i'm getting you wrong but i'm already using it's why i'm wondering why i have the issue&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'&lt;BR /&gt;    EXPORTING&lt;BR /&gt;      buffer     = b_xml&lt;BR /&gt;    TABLES&lt;BR /&gt;      binary_tab = ex_tab.&lt;BR /&gt;*transfer file on the application server.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  READ TABLE a_lt_seg ASSIGNING &amp;lt;fs_seg&amp;gt; INDEX 1.&lt;BR /&gt;  CONCATENATE dset &amp;lt;fs_seg&amp;gt;-tknum '.xml' INTO dset.&lt;BR /&gt;  TRY.&lt;BR /&gt;      OPEN DATASET dset FOR OUTPUT IN BINARY MODE.&lt;BR /&gt;      LOOP AT ex_tab INTO ls_tab.&lt;BR /&gt;        g_resize = xSTRLEN( ls_tab ).&lt;BR /&gt;        TRANSFER ls_tab TO dset LENGTH g_resize.&lt;BR /&gt;      ENDLOOP.&lt;BR /&gt;    CATCH cx_root INTO lo_exception.&lt;BR /&gt;*     Gets error message&lt;BR /&gt;      CALL METHOD lo_exception-&amp;gt;if_message~get_text&lt;BR /&gt;        RECEIVING&lt;BR /&gt;          result = l_message.&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;I</description>
      <pubDate>Thu, 04 May 2023 19:39:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695898#M2017990</guid>
      <dc:creator>crepmaster</dc:creator>
      <dc:date>2023-05-04T19:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695899#M2017991</link>
      <description>&lt;P&gt;i solved the issue by using FTP transfert&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2023 23:41:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695899#M2017991</guid>
      <dc:creator>crepmaster</dc:creator>
      <dc:date>2023-05-06T23:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695900#M2017992</link>
      <description>&lt;P&gt;Be careful, your code was full of &amp;lt;br&amp;gt; so people might not do the effort of reading it. Your question, formatted correctly:&lt;/P&gt;&lt;P&gt;i started building my file :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lo_ixml = cl_ixml=&amp;gt;create( ).
lo_document = lo_ixml-&amp;gt;create_document( ).
lo_header = lo_document-&amp;gt;create_simple_element(
                 name   = 'DHL-SHIPMENT-IMPORT'
                 parent = lo_document ).
lo_auth_data = lo_document-&amp;gt;create_simple_element(
                 name   = 'AUTH_DATA'
                 parent = lo_header ).
lo_auth_group_id = lo_document-&amp;gt;create_simple_element(
                 name   = 'AUTH_GROUP_ID'
                 parent = lo_auth_data
                 value  = 'Default group' ).
...&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then i make the transformation and transfert&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  lo_stream_factory = lo_ixml-&amp;gt;create_stream_factory( ).
  lo_encoding = lo_ixml-&amp;gt;create_encoding( byte_order = 0
                                         character_set = 'UTF-8' ).
*document
  DATA b_xml TYPE xstring.
  DATA lo_ostream TYPE REF TO if_ixml_ostream.
  lo_ostream = lo_stream_factory-&amp;gt;create_ostream_xstring( b_xml ).
  CALL METHOD lo_ostream-&amp;gt;set_encoding
    EXPORTING
      encoding = lo_encoding.
  CALL METHOD lo_document-&amp;gt;render
    EXPORTING
      ostream   = lo_ostream
      recursive = 'X'.
  DATA g_resize TYPE i.
  g_resize = lo_ostream-&amp;gt;get_num_written_raw( ).
  DATA: ex_tab TYPE TABLE OF x255,
        ls_tab TYPE x255.
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = b_xml
    TABLES
      binary_tab = ex_tab.
*transfer file on the application server.
  READ TABLE a_lt_seg ASSIGNING &amp;lt;fs_seg&amp;gt; INDEX 1.
  CONCATENATE dset &amp;lt;fs_seg&amp;gt;-tknum '.xml' INTO dset.
  TRY.
      OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
      LOOP AT ex_tab INTO ls_tab.
        g_resize = xSTRLEN( ls_tab ).
        TRANSFER ls_tab TO dset LENGTH g_resize.
      ENDLOOP.
    CATCH cx_root INTO lo_exception.
*     Gets error message
      CALL METHOD lo_exception-&amp;gt;if_message~get_text
        RECEIVING
          result = l_message.
      MESSAGE l_message
         TYPE c_error.
  ENDTRY.
  CLOSE DATASET dset.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 May 2023 13:04:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695900#M2017992</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-07T13:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695901#M2017993</link>
      <description>&lt;P&gt;When it's about writing an XSTRING variable to a file on the application server, as BINARY MODE, you can simply do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  TRY.
      OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
      IF sy-subrc = 0.
        TRANSFER b_xml TO dset.
        CLOSE DATASET dset.&lt;/CODE&gt;&lt;/PRE&gt;NB: the error in your original code is in the 2 lines below, you use XSTRLEN on an X variable of length 255 bytes, which always return 255, even for the last line of EX_TAB, and consequently you write extra null bytes:&lt;PRE&gt;&lt;CODE&gt;      LOOP AT ex_tab INTO ls_tab.
        g_resize = xSTRLEN( ls_tab ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 May 2023 13:20:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695901#M2017993</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-07T13:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: xml send to application server null character issue</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695902#M2017994</link>
      <description>&lt;P&gt; Thank you Sandra for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 21:44:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-send-to-application-server-null-character-issue/m-p/12695902#M2017994</guid>
      <dc:creator>crepmaster</dc:creator>
      <dc:date>2023-05-10T21:44:11Z</dc:date>
    </item>
  </channel>
</rss>

