2011 Apr 19 1:07 AM
Hello,
I need to read data from SAP 710 and save it in the server as a XML utf-8 file. Then this file is going to be read in a non SAP system.
I am reading data in a simple transformation to a STRING, but it come as UTF-16.
Then I call method CL_RSWAD_CONVERT=>STRING_TO_TABLE where I Import a binary table TYPE STANDARD TABLE OF char255.
So when I do 'OPEN DATASET lv_temp_unix_filen in BINARY MODE for OUTPUT.' the file is in UTF-16 format.
I tried to replace UTF-16 for UTF-8 (using: REPLACE FIRST OCCURRENCE OF 'utf-16' in lv_xml_string with 'utf-8'.)
but then the NON SAP system doesn't recognize the file.
I also tried to read the simple transformation data into a XSTRING.
Then I used CL_RSWAD_CONVERT=>XSTRING_TO_TABLE where I get the content in a binary table TYPE SOLIX_TAB.
If I use method cl_gui_frontend_services=>gui_download this works fine, but for the server, the file shows an error:
"The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
----
Invalid at the top level of the document. Error processing resource 'file:///C:/test.xml'. "
Can anyone help me?
Thanks and Kind regards!
2011 Apr 19 2:06 AM
Hi,
you can use FM SCMS_STRING_TO_XSTRING which takes a string and returns a string of bytes in encoding defined in paramter ENCODING. For UTF-8 you need to enter 4110. You should also check what encoding is mentioned in XML file. If it's UTF-16 you need to change it to UTF-8.
Cheers
Hello,
I need to read data from SAP 710 and save it in the server as a XML utf-8 file. Then this file is going to be read in a non SAP system.
I am reading data in a simple transformation to a STRING, but it come as UTF-16.
Then I call method CL_RSWAD_CONVERT=>STRING_TO_TABLE where I Import a binary table TYPE STANDARD TABLE OF char255.
So when I do 'OPEN DATASET lv_temp_unix_filen in BINARY MODE for OUTPUT.' the file is in UTF-16 format.
I tried to replace UTF-16 for UTF-8 (using: REPLACE FIRST OCCURRENCE OF 'utf-16' in lv_xml_string with 'utf-8'.)
but then the NON SAP system doesn't recognize the file.
I also tried to read the simple transformation data into a XSTRING.
Then I used CL_RSWAD_CONVERT=>XSTRING_TO_TABLE where I get the content in a binary table TYPE SOLIX_TAB.
If I use method cl_gui_frontend_services=>gui_download this works fine, but for the server, the file shows an error:
"The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
----
Invalid at the top level of the document. Error processing resource 'file:///C:/test.xml'. "
Can anyone help me?
Thanks and Kind regards!
2011 Apr 19 2:06 AM
Hi,
you can use FM SCMS_STRING_TO_XSTRING which takes a string and returns a string of bytes in encoding defined in paramter ENCODING. For UTF-8 you need to enter 4110. You should also check what encoding is mentioned in XML file. If it's UTF-16 you need to change it to UTF-8.
Cheers
2011 Apr 19 11:12 PM
Hello Martin,
Thanks for your answer.
So, after I have all the date in a XSTRING as utf-8, how can I create a file in the server?
I do it like this:
OPEN DATASET lv_temp_unix_filen in BINARY MODE for OUTPUT.
But the output file has at the end the error described in last post.
Kind regards.
2011 Apr 20 5:54 AM
Hello Luis,
Which release of ABAP are you using? You can use the addition [ENCODING UTF-8|http://help.sap.com/abapdocu_702/en/abapopen_dataset_encoding.htm#!ABAP_ALTERNATIVE_2@2@] provided you open the file in [TEXT MODE|http://help.sap.com/abapdocu_702/en/abapopen_dataset_mode.htm#!ABAP_ALTERNATIVE_2@2@].
If you're opening the file in BINARY MODE, you don't have to worry about the encoding!
BR,
Suhas
2011 Apr 20 7:18 AM
Hi,
are you sure that XML is valid. Have you tried to open that file in text editor and check if that XML is valid. For example what encoding is set there.
Cheers
2011 Apr 26 1:30 PM
Sorry for taking so long to answer.
I am using Abap 710.
What do you mean with valid XML?
I can have a valid one in my pc (frontend) using method "CALL METHOD cl_gui_frontend_services=>gui_download",
but if I try to download it to the server using "OPEN DATASET lv_temp_unix_filen in BINARY MODE for OUTPUT." it gives me the error I described on my first post.
Is it possible to add in the simple transformation the enconding? Then I could load that transformed data to a STRING as UTF-8. Because right now from the simple transformation I get it as UTF-16. That's why I am reading it to a XSTRING to be UTF-8 (I read it in another topic from this forum).
Does anyone have a solution?
Thanks for helping me.
Kind regards.
2011 Apr 28 11:59 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |