‎2009 May 14 4:56 PM
Hi,
I need to convert a hexadecimal value to String. Then, I used the following function module HR_KR_XSTRING_TO_STRING. However, what I get as result is: ###.
DATA:
in_xstring TYPE xstring,
out_string TYPE string.
in_xstring = '00020C'.
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
FROM_CODEPAGE = '8500'
in_xstring = in_xstring
OUT_LEN =
importing
out_string = out_string.
write out_string. " Result: ###
Anyone knows, how can I do to se correctly this result?
Thanks in advance,
Regards,
Leo
Leitooo
‎2009 May 14 7:13 PM
Hi Leonardo,
This is because your hex value contains only special characters. As SAP uses unicode UTF-16 so in your byte sequence 00020C each "character" is stored in two bytes.
First: '00', second '02', third '0C'. These are all special ASCII characters, that's why they appear as ### after conversion.
Put correct byte value in xstring and you will get desired results. Example:
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = '302E3230' "0.20"
IMPORTING
out_string = out_string.
write: out_string.
Regards
Marcin
‎2009 May 14 5:01 PM
Hi,
* Convert XString to String
data: loc_conv type ref to CL_ABAP_CONV_IN_CE,
loc_xstring type xstring,
loc_string type string.
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = loc_xstring
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = loc_CONV.
TRY.
CALL METHOD loc_CONV->READ
IMPORTING
DATA = loc_string.
CATCH CX_SY_CONVERSION_CODEPAGE.
*-- Should ignore errors in code conversions
CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
*-- Should ignore errors in code conversions
CATCH CX_PARAMETER_INVALID_TYPE.
CATCH CX_PARAMETER_INVALID_RANGE.
ENDTRY.Regards,
Sudheer
‎2009 May 14 6:54 PM
Hi Sudheer Junnuthula,
I tried with CL_ABAP_CONV_IN_CE but I still having same problem. I mean, value of LOC_STRING is equal than ###.
I can't fnd the way to see ### as decimal value. For example: 0.20
Do you have any idea about what can I do?
Thanks in advance for your help
Best Regards,
Leo
‎2009 May 14 5:02 PM
‎2009 May 14 6:57 PM
Hi Avinash Kodarapu,
I tried to solve my problem with your suggestion but it didn't work. I mean, it continues showing ### instead 0.20.
Do you have any idea about what can I do?
Thanks in advance.
Best Regards,
Leo
‎2009 May 14 7:13 PM
Hi Leonardo,
This is because your hex value contains only special characters. As SAP uses unicode UTF-16 so in your byte sequence 00020C each "character" is stored in two bytes.
First: '00', second '02', third '0C'. These are all special ASCII characters, that's why they appear as ### after conversion.
Put correct byte value in xstring and you will get desired results. Example:
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = '302E3230' "0.20"
IMPORTING
out_string = out_string.
write: out_string.
Regards
Marcin
‎2009 May 14 8:23 PM
Hi Marcin,
Thanks for your answer. In fact, you are right. However, my main problem is that I receive a file created in 4.6c version, which include these characters ### (00020C).
In this version (4.6c), I can move these characters to a dec field without problems. In fact, I see then its value like 0.20.
On the other hand, if I use the same file in ECC 6.0, I can't assign these characters to a dec field. Even by using functions/methods.
Is there any way to convert these character to dec value?
Anyways, thanks for your help. It has been quite useful.
Regards,
Leo
‎2009 May 15 3:40 AM
Hi,
The Value of 00020C is
00 - Null
02 - Start of text
0C - Form Feed .. so it is converting these values as #..
You need to use the FM and get the char value of these hexa values and using this replace the values with space.
‎2013 Jan 02 8:45 AM
Can you please explain how do I replace these 00 (Nulls) which has automatically been inserted after each and every character for a working 4.5B file which fails in ECC6?
Thanks in advance.
Regards,
BGaurav