on 06-20-2012 5:18 PM
Hi,
I'm using SAP.Middleware.Connector and call rfc function.
Export table contains field 'GUID' which I receive in .net as Byte[] and in SAP it's defined as RAW.
Now I try to convert Byte() to String.
With my byte varialbe(bytes) I tried already:
System.Text.Encoding.ASCII.GetString(bytes)
System.Text.Encoding.BigEndianUnicode.GetString(bytes)
System.Text.Encoding.Default.GetString(bytes)
System.Text.Encoding.Unicode.GetString(bytes)
System.Text.Encoding.UTF32.GetString(bytes)
System.Text.Encoding.UTF7.GetString(bytes)
System.Text.Encoding.UTF8.GetString(bytes)
no encoding delivers expected result. I expect e.g "E61F13B1A8EB1ED1ADCFF99E54EA0905". This value I'm able to see if I display field GUID in transaction se16 in SAP GUI.
Any idea ?
Thanks in advance.
Ro
Try passing the byte array back into a GUID constructor.
Dim changeBack As String = New Guid(incomingByteArray).ToString
If it comes back with hyphens in it, just get rid of them.
Dim expectedFormat As String = changeBack.Replace("-", "")
Hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The bytes are reversed in the first three segments. Strange. But you might be able to parse it.
9F7D2FE0-C490-F12F-80A6-00145E577788
E02F7D9F-90C4-2FF1-80A6-00145E577788
UPDATED:
Here is the parsing code... not too clunky, I hope.
Dim incomingDataArray() As Byte = g.ToByteArray
Dim newArray(15) As Byte
Dim reverseOne(3) As Byte
Dim reverseTwo(1) As Byte
Dim reverseThree(1) As Byte
Array.Copy(incomingDataArray, 0, reverseOne, 0, reverseOne.Length)
Array.Copy(incomingDataArray, 4, reverseTwo, 0, reverseTwo.Length)
Array.Copy(incomingDataArray, 6, reverseThree, 0, reverseThree.Length)
Array.Reverse(reverseOne)
Array.Reverse(reverseTwo)
Array.Reverse(reverseThree)
Array.Copy(reverseOne, 0, newArray, 0, reverseOne.Length)
Array.Copy(reverseTwo, 0, newArray, 4, reverseTwo.Length)
Array.Copy(reverseThree, 0, newArray, 6, reverseThree.Length)
Array.Copy(incomingDataArray, 8, newArray, 8, 😎
Dim changeBack As String = New Guid(newArray).ToString
Dim expectedFormat As String = changeBack.Replace("-", "")
Message was edited by: Case Ahr
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.