cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Xstring to string

0 Kudos

Hi All,

I need to convert the XSTRING to STRING and i need a FM which converts all the special characters as it is.

Im getting the xstring value from excel sheet using file upload.

The FM used is CL_HTMLB_FILEUPLOAD and the attribute is FILE_CONTENT which is of type XSTRING.

I have few special characters in the excel sheet which i need as string.

Can anyone suggest me...

Thanx in advance

Siva.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member

Try this function module ECATT_CONV_XSTRING_TO_STRING.

0 Kudos

Thanx for ur reply, I tried the FM earlier but this gives a dump in the WEB UI that it cannot be used in http services

Thanx,

Siva.

Former Member
0 Kudos

Try with this FM CRM_IC_XML_XSTRING2STRING

Regards,

Shiva Kumar

0 Kudos

Hi Shiva,

Thank you for ur reply. Im currentlu using this FM and all special characters are replaced by ?. How to aviod or get the special characters.

Useful answers are appreciated.

Thanx

Siva.

Former Member
0 Kudos

Hi Siva,

Write your own own method or function module like this:

Input : input_rawstr

Output : output_str

        • start of code ****

DATA: obj TYPE REF TO cl_abap_conv_in_ce,

len type int4.

TRY.

CALL METHOD cl_abap_conv_in_ce=>create

EXPORTING

input = input_rawstr

encoding = 'UTF-8'

replacement = ''

RECEIVING

conv = obj.

CATCH cx_parameter_invalid_range .

CATCH cx_sy_codepage_converter_init .

ENDTRY.

len = xstrlen( input_rawstr ).

TRY.

CALL METHOD obj->read

EXPORTING

n = len

IMPORTING

data = output_str.

CATCH cx_sy_conversion_codepage .

CATCH cx_sy_codepage_converter_init .

CATCH cx_parameter_invalid_type .

CATCH cx_parameter_invalid_range .

ENDTRY.

              • end of code ******

Best Regards,

Siva.

Edited by: Siva Rama Krishna J on Oct 23, 2008 11:21 AM

0 Kudos

Hi Siva

Thank you so much.

But still i have the same issue. The special characters like Å, ö, ä, å, ü are replaced by space.

I need these characters as it is.. Any different soluton i can use to get the file upload in string.

Or get the characters from Xstring

Thanx,

Siva.

Former Member
0 Kudos

Hi,

Just give a try with different type like UTF-16 in the method. Not sure but might help in your case.

Best Regards,

Siva.

0 Kudos

Hi all,

Thanx for all ur replies.

I have solved the issue.

First convert the xstring to binary. SCMS_XSTRING_TO_BINARY

Then binary to string.

SCMS_BINARY_TO_STRING

It works fine.

Thank u.

Siva.

Former Member
0 Kudos

Thanks, I could solve my code's problem too

CL_BCS_CONVERT=>xstring_to_string(
    EXPORTING
      iv_xstr   = lv_xstring_var
      iv_cp     =  1100                " SAP character set identification
    RECEIVING
      rv_string = DATA(lv_string)
  ).
  IF sy-subrc = 0.
  ENDIF.

Hi all,

Thanx for all ur replies.

I have solved the issue.

First convert the xstring to binary. SCMS_XSTRING_TO_BINARY

Then binary to string.

SCMS_BINARY_TO_STRING

It works fine.

Thank u.

Siva.

Former Member
0 Kudos

Hello Sivasankar,

I am facing a similar issue hence I tried using FM's SCMS_XSTRING_TO_BINARY and SCMS_BINARY_TO_STRING but it does not work. Special characters are still not shown correctly. Did you use any other FM or class ?

Thank you,

Regards,

Mukul Kulkarni

michael_janello
Employee
Employee
0 Kudos

Hi Mukul, did you check which encoding the original chars are ? - that might be the problem.