07-06-2005 3:54 PM
Dear All,
I have an issue with a string and I would like to parse it to get the hexadecimal value of every character of the string.
Does anybody know how to do this?
Any help highly appreciated
Thanks
Ioan
07-06-2005 4:42 PM
07-06-2005 4:42 PM
07-06-2005 4:43 PM
Here is a sample program. This will convert one character at a time.
report zrich_0001.
data: s type string.
data: h(1) type x.
data: c(1) type c.
data: byte(2) type c.
data: length type i.
FIELD-SYMBOLS: <DUMMY>.
s = 'ThisIsAString'.
length = strlen( s ).
do length times.
byte = ( sy-index - 1 ).
c = s+byte(1).
* You can do this
ASSIGN h TO <DUMMY> TYPE 'X'.
WRITE c TO <DUMMY>.
* or you can do this
* call function 'CHAR_HEX_CONVERSION'
* exporting
* input = c
* importing
* hexstring = h.
write:/ h.
enddo.
Regards,
Rich Heilman
Message was edited by: Rich Heilman
Message was edited by: Rich Heilman
07-06-2005 4:45 PM
Hi Ioan,
pls check this code:
data: d_string_char(50),
d_string_hex(100).
field-symbols: <fs1>.
start-of-selection.
*** populate d_string_char with the string...
assign d_string_char to <fs1> type 'X'.
write <fs1> to d_string_hex.
*** now in d_string_hex you have the hex-conversion
I hope it helps. BR,
Alvaro
07-06-2005 4:56 PM
Hi Ioan,
Sorry, but that function module is not supported after a certain SAP version. OSS Note 394935 describes this.
If you are on 4.6D you can use the following code.
Also you'll need to loop through all of the single characters of the string for the following code, minus the data declaration.
data wa_input(1) type c value 'M'.
data: wa_hex type x.
FIELD-SYMBOLS: <DUMMY>.
ASSIGN wa_input TO <DUMMY> TYPE 'X'.
wa_hex = <dummy>.
I hope this helps.
Mike V.
07-06-2005 5:01 PM
07-06-2005 5:05 PM
Thank you guys, you all got the answer to my question. I am assigning the point to the first answer, sorry for the other ones ...
Ioan
07-06-2005 5:07 PM
07-06-2005 5:10 PM
I gave 10 to Mike (first answer). I would like to give you a 10, but I could not, so I gave you a 6. This is cool, isn't it?
Thanks again, this is saving my life (for a BW data load)
Ioan
07-06-2005 5:12 PM