Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Conversion xstring to string

Former Member
0 Likes
7,927

Hi all,

I have a problem with the conversion xstring to string.

I have a CSV file in upload, I use this method:

data lr_conv type ref to cl_abap_conv_in_ce.

clear lr_conv.

lr_conv = cl_abap_conv_in_ce=>create( ).

lr_conv->convert( exporting input = l_xstring importing data = l_string ).

but I have an error when I execute this:

lr_conv->convert( exporting input = l_xstring importing data = l_string ).

the error is: Character set conversion is not possible.

How can I do for to solve?

Tks a lot.

1 ACCEPTED SOLUTION
Read only

Former Member
2,489

hi ,

u may do it like this :



  data: lr_conv type ref to CL_ABAP_CONV_IN_CE,
            lr_xstring type xstring,
            lr_string type string.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
      EXPORTING
        INPUT       = lr_xstring
        ENCODING    = 'UTF-8'
        REPLACEMENT = '?'
        IGNORE_CERR = ABAP_TRUE
      RECEIVING
        CONV        = lr_CONV.

   
        CALL METHOD lr_CONV->READ
          IMPORTING
            DATA = lr_string.
    

refer the SAP online help

http://help.sap.com/saphelp_nw70/helpdata/en/ba/78d3c747b24546ab1c1499a054d8a5/content.htm

5 REPLIES 5
Read only

Former Member
0 Likes
2,489

Hi,

You have to do it this way -

DATA lv_cvw_data   TYPE xstring.
  DATA s_cont        TYPE string.
  DATA lref_convt    TYPE REF TO cl_abap_conv_in_ce.
  DATA lv_string     TYPE string.


  lref_convt = cl_abap_conv_in_ce=>create( input = lv_cvw_data ).
  lref_convt->read( IMPORTING data = s_cont ).
  lref_convt->convert( EXPORTING input = lv_cvw_data     IMPORTING data  = lv_string ).

Regards,

Lekha.

Edited by: Lekha on Nov 5, 2009 4:48 PM

Read only

0 Likes
2,489

I have the same error at the line:

lref_convt->read( IMPORTING data = s_cont ).

???

Read only

Former Member
0 Likes
2,489

hi ,

u may do it like this :



  data: lr_conv type ref to CL_ABAP_CONV_IN_CE,
            lr_xstring type xstring,
            lr_string type string.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
      EXPORTING
        INPUT       = lr_xstring
        ENCODING    = 'UTF-8'
        REPLACEMENT = '?'
        IGNORE_CERR = ABAP_TRUE
      RECEIVING
        CONV        = lr_CONV.

    TRY.
        CALL METHOD lr_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.

refer the SAP online help

http://help.sap.com/saphelp_nw70/helpdata/en/ba/78d3c747b24546ab1c1499a054d8a5/content.htm

Read only

Former Member
2,490

hi ,

u may do it like this :



  data: lr_conv type ref to CL_ABAP_CONV_IN_CE,
            lr_xstring type xstring,
            lr_string type string.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
      EXPORTING
        INPUT       = lr_xstring
        ENCODING    = 'UTF-8'
        REPLACEMENT = '?'
        IGNORE_CERR = ABAP_TRUE
      RECEIVING
        CONV        = lr_CONV.

   
        CALL METHOD lr_CONV->READ
          IMPORTING
            DATA = lr_string.
    

refer the SAP online help

http://help.sap.com/saphelp_nw70/helpdata/en/ba/78d3c747b24546ab1c1499a054d8a5/content.htm

Read only

0 Likes
2,489

tks, I solved with this code...

Bye