‎2009 Jan 20 5:21 AM
Hi Experts,
I am reading an XML file into a XSTRING variable and parsing the XSTRING to retrieve the data into Internal table.
What i want-
I want to replace all occurances of space in the file with some recognizable character ( say ~ ).
This i need to do once the file is read into XSTRING variable, in this xstring variable i want to replace all spaces with other character's value.
Is it feasible to replace like this in XSTRING variable for space?
In XSTRING , a space is stored '0D0A'
and i know 'replace all occurrences' works for Char type data object.
How to go about this?
Any help or clue is highly appreciated.
Regards,
‎2009 Jan 21 2:43 PM
I think your idea works.
Just am not sure how you refer to the Hexadecimal Codes. I do by a 2 bytes character, for instance - A is coded like 41. Space for me is 20, not 0DA0.
Try the following example.
DATA: x TYPE xstring,
y TYPE string.
x = '4156524148414D'. "AVRAHAM's literal hexadecimal coding
x = '4120562052204120482041204D'. "A V R A H A M
y = x.
REPLACE ALL OCCURRENCES OF '20' IN y WITH '78'. "requires a character type input paramater, can't pass XSTRING.
x = y.
CALL FUNCTION 'HR_RU_CONVERT_HEX_TO_STRING'
EXPORTING
xstring = x
IMPORTING
CSTRING = y.
WRITE: /, x, / ,y.I pass the following string to the function: 'A V R A H A M'
and I print in the screen the following one: 'AxVxRxAxHxAxM'. 78 is 'x' hexadecimal code.
Hope it helps.
Avraham
Edited by: Avraham Kahana on Jan 21, 2009 4:44 PM
‎2009 Jan 21 2:55 PM
Hi,
Convert the XSTRING ti String and replace the space woth '~' and then convert to xstring.
Check these FM
HR_KR_STRING_TO_XSTRING
HR_KR_XSTRING_TO_STRING
‎2009 Jan 21 3:00 PM
Have you tried below construct ?
REPLACE ......IN BYTE MODE ...
Thanks,
Tushar