We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-dev] xstring to string

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from mic-bv on Apr 25 at 5:12 AM
Hi HBK_SINGH,

I used ff. coding for reading the XML:

???
" create an instance of the Ixml Processor   lr-ixml = cl_ixml=>create( ).   " Create the Stream Factory   lr-Stream_Factory = lr-ixml->Create_Stream_Factory( ).   " Create an Encoding and Byte Orde   lr-Encoding = lr-ixml->create_encoding(   Character_Set = gc-Encoding   byte_order = 0 ).   " set encoding fr iStream   lr-iStream = lr-Stream_Factory->Create_iStream_CString(   string = Input ).      lr-iStream->set_encoding( encoding = lr-Encoding ).      clear: "INS SV150812   sy-SubRC. "INS SV150812   call transformation (xTransformation)  """ source XML input   source XML lr-iStream   result root = iSO. " SalesOrder  "" options xml_header = 'WITHOUT_ENCODING' .  "" catch xs_xslt_exception ino xslt_err.  "" lv-s = xslt_Err->get_Text( ).   catch cx_sy_Conversion_Data_Loss "INS SV150812   into lr-xslt_Err. "INS SV150812   lv-err_text = lr-xslt_Err->get_text( ). "INS SV150812   message i799(f9) "INS SV150812   with lv-err_text. "INS SV150812  * f?r Error-Mail vorbereiten "INS SV150812   clear: "INS SV150812   iError. "INS SV150812   iError-Port = xPortOrd. "INS SV150812   iError-Dir = xDirIn. "INS SV150812   iError-File = xFileIn. "INS SV150812   iError-Text = lv-err_text. "INS SV150812   iError-Purch_No_C = ''. "INS SV150812   iError-Datum = sy-Datum. "INS SV150812   iError-UZeit = sy-UZeit. "INS SV150812   append iError. "INS SV150812   sy-SubRC = 4. "INS SV150812   catch CX_ROOT "INS SV150812   into lr-CX_Root. "INS SV150812   lv-err_text = lr-CX_Root->get_text( ). "INS SV150812   message i799(f9) "INS SV150812   with lv-err_text. "INS SV150812  * f?r Error-Mail vorbereiten "INS SV150812   clear: "INS SV150812   iError. "INS SV150812   iError-Port = xPortOrd. "INS SV150812   iError-Dir = xDirIn. "INS SV150812   iError-File = xFileIn. "INS SV150812   iError-Text = lv-err_text. "INS SV150812   iError-Purch_No_C = ''. "INS SV150812   iError-Datum = sy-Datum. "INS SV150812   iError-UZeit = sy-UZeit. "INS SV150812   append iError. "INS SV150812   sy-SubRC = 4. "INS SV150812         endtry.


However, when I'm setting ?gc-Encoding to utf-8, it's working. When trying utf-16 (and handling over the data in "Input" as 2-Byte-Unicode), then I only get errors in conversion.

Neal: Thank you very much for the tip. What do you think, bytewise conversion in a way
char = charx
or do I need a conversion Function / Library?
Will prepare for bytewise translation now.

---------------Original Message---------------
From: Stefan Vermeulen
Sent: Wednesday, April 24, 2013 3:15 AM
Subject: xstring to string

I need to convert a xstring to a string, something without conversion.

Meaning, as an example,
xstring contains 3C3F786D6C2076657273696F
string should contain that value as hex, not as character-value.

When assigning
string = xstring

the value of string would be "3C3F786D6C2076657273696F"
instead of "<?xml version=" as unicode 8.

All the functions etc. I found so far, would convert it to an string with 2-byte-unicode, reads as hex 003C003F0078006D006C002000760065007200730069006F


Background:
For reading a xml structure from a file, I open that file in binary mode and append the contents to a string. That string is given into xml conversion, telling it is utf-8. However, in Debugger that string is displayed as some chinese characters, since interpreted as utf-16 (2 Byte Unicode), but the result is fine. However, now I get some XML Infiles with some smaller problems in the file, which I like to solve. I just can't change the 1-byte-unicode-string, since it is interpreted as it was 2-byte-unicode. So I translated it into 2-byte, made the necessary changes and converted it back. Unfortunally, the result is only possible as xstring / xchar-array, which I cannot convert in the desired way into a string.

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2013 Ziff Davis, Inc. and message author.
Ziff Davis, Inc. 28 E 28th Street New York, NY 10016
mic-bv  

What title?
achievements
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Have an SAP Question? Ask Your Peers at Toolbox for IT

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language