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

Convert string to xstring in release 640

Former Member
0 Likes
1,681

Hi!

How I can convert string to xstring in release 640? because the function SCMS_STRING_TO_XSTRING return the error CMS196 'Error occurred during character conversion'.

Hi!

How I can convert string to xstring in release 640? because the function SCMS_STRING_TO_XSTRING return the error CMS196 'Error occurred during character conversion'.

3 REPLIES 3
Read only

thomas_jung
Developer Advocate
Developer Advocate
0 Likes
812

I use SCMS_STRING_TO_XSTRING quite often on 640 without any problems. Perhaps you post your code sample here, we might be able to find a problem.

Read only

Former Member
0 Likes
812

Hi,

maybe you want to try the classes

CL_ABAP_CONV_OUT_CE (string to xstring)

and

CL_ABAP_CONV_IN_CE (xstring to string)

* Sample coding
data:    string        type string,
         xstring       type xstring,
         lv_length     type i,
         lorv_conv     type ref to cl_abap_conv_out_ce.

string = 'this is a test.'.


clear: lv_length, xstring, lorv_conv.
try.
    lorv_conv = cl_abap_conv_out_ce=>create( ).
  catch cx_parameter_invalid_range .
* error handling
  catch cx_sy_codepage_converter_init .
* error handling
endtry.

try.
    call method lorv_conv->write
      exporting
*    N                             = -1
        data                          = string
*    VIEW                          =
      importing
        len                           = lv_length.
  catch cx_sy_codepage_converter_init .
* error handling
  catch cx_sy_conversion_codepage .
* error handling
  catch cx_parameter_invalid_type .
* error handling
  catch cx_parameter_invalid_range .
* error handling
endtry.

try.
    call method lorv_conv->get_buffer
      receiving
        buffer = xstring.
  catch cx_root.
* error handling
endtry.

Read only

0 Likes
812

the function SCMS_STRING_TO_XSTRING uses the same class

(cl_abap_conv_out_ce)

Regards

Raja