Conversion between RAW and Strings
Hey all,
Im accessing some RFC functions from SAP XI which return and take parameters in the RAW format.
From http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f2e5446011d189700000e8322d00/content.htm:
RAW: Uninterpreted byte string. Fields of type RAW may have only a maximum length of 255 in tables. If longer raw fields are required in tables, you should select data type LRAW.
If I for example execute a RFC from the abap system (using transaction se37), one of the results is "5ECD6F4D6C6E3242921025FE74AC5153" while when i call the RFC from XI the result with the same input parameters is "Xs1vTWxuMkKSECX+dKxRUw==".
Is it possible to convert these (in both directions) between strings and raw format using Java ?
Greetings,
Hannes
[786 byte] By [
hannesda] at [2007-10-2 14:35:11]

ok, im sorry for the SAP specific terms here, i posted but i cant edit my post.
Ive been messing around a bit but my knowledge of these bytes is really too limited to get anywhere.
i managed to get this compiled (but ofcourse it didnt work):
String raw_input = "Xs1vTWxuMkKSECX+dKxRUw==";
byte[] block = new byte[255];
for (int i = 0; i < raw_input.length(); i++){
char c = raw_input.charAt(i);
byte [] twoBytes = { (byte)(c & 0xff), (byte)(c >> 8 & 0xff) };
block[i*2] = twoBytes[0];
block[i*2+1] = twoBytes[1];
}
try{
String raw_string = new String(block,"utf-8");
System.out.println("raw_string = " + raw_string );
}
catch(Exception e){}
anyone here who can do better ? Ive found the
byte [] twoBytes = { (byte)(c & 0xff), (byte)(c >> 8 & 0xff) };
line googling but realy nog sure if thats correct..