‎2010 Jan 28 10:09 AM
Hello,
I have an ITS application on an ECC 6.0 unicode system, which allows users to upload txt files.
In the associated ABAP program, I recuperate the content of this txt file in the form of XSTRING. I manage to convert without problem the XSTRING to a normal STRING, but I lose every accented characters (like é) in the process. I use class cl_abap_conv_in_ce to do the conversion, with encode parameter set to 'UTF-8'.
Do someone know if it is possible to do it properly and get all special characters ?
Thank you.
Thomas
‎2010 Jan 28 10:34 AM
Hi,
Take a look at this code
DATA: file TYPE string VALUE `flights.dat`,
wa TYPE spfli.
FIELD-SYMBOLS <hex_container> TYPE x.
OPEN DATASET file FOR INPUT IN BINARY MODE.
ASSIGN wa TO <hex_container> CASTING.
DO.
READ DATASET file INTO <hex_container>.
IF sy-subrc = 0.
WRITE: / wa-carrid,
wa-connid,
wa-countryfr,
wa-cityfrom,
wa-cityto,
wa-fltime,
wa-distance.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
Thanks
Ahsan
‎2010 Jan 28 11:33 AM
Hello,
Can't do it like that. I receive the file as a table of raw data. Here is how it happens :
Get all data and concatenate converting to byte mode
LOOP AT lt_raw_data INTO ls_w3mime.
CONCATENATE lv_xstring ls_w3mime-line INTO lv_xstring IN BYTE MODE.
ENDLOOP.
Convert byte data to character data
TRY.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
encoding = 'UTF-8'
input = lv_xstring
RECEIVING
conv = lv_conv.
CATCH cx_parameter_invalid_range.
MESSAGE i059.
EXIT.
CATCH cx_sy_codepage_converter_init.
MESSAGE i059.
EXIT.
ENDTRY.
TRY.
CALL METHOD lv_conv->read
IMPORTING
data = lv_string.
CATCH cx_sy_conversion_codepage.
MESSAGE i059.
EXIT.
CATCH cx_sy_codepage_converter_init.
MESSAGE i059.
EXIT.
CATCH cx_parameter_invalid_type.
MESSAGE i059.
EXIT.
CATCH cx_parameter_invalid_range.
MESSAGE i059.
EXIT.
ENDTRY.
I have to start from my XSTRING.
‎2010 Jan 28 11:47 AM
hi thomas,
there is a function module 'SCMS_STRING_TO_XSTRING'..
U can try this..
‎2010 Jan 28 11:51 AM
I have to do it the other way around, convert XSTRING to STRING, and there are no equivalent of your function for this. All functions I found were doing the conversion in the same way I do.
‎2010 Sep 02 11:27 PM
Thomas,
Suggest you to look for and try FM 'HR_KR_XSTRING_TO_STRING'
Alternatively you can also try using FM 'SCMS_XSTRING_TO_BINARY' to convert Xstring to Binary and then
use FM 'SCMS_BINARY_TO_STRING' to get the binary table converted to string.
Regards,
Damian
‎2010 Sep 02 11:33 PM
Hi,
I suggest to use methods of class CL_BCS_CONVERT for conversions, FMs like SCMS_XSTRING_TO_STRING are going to become obsolete.
Regards,
Ivan