05-29-2008 1:37 PM
Hello Experts,
Ca any one please suggest me some FM (SAP version in 4.6B) for converting String to Xstring..?
I have got the data in w_string in STRING format. The below FM is called in other FM which is created by me. But the requirement is to Export the data in Xstring format.
Convert table to to string
CALL FUNCTION 'CONVERT_TABLE_TO_STRING'
EXPORTING
i_tabline_length = '1024'
IMPORTING
e_string = w_string
TABLES
it_table = it_contents.
I will reward points points if helpful.
05-29-2008 1:48 PM
possibly.....SCMS_STRING_TO_XSTRING
Edited by: Micky Oestreich on May 29, 2008 2:48 PM
09-01-2014 2:02 PM
It's an answer useful even after years !
Thanks for sharing.
Best regards,
Paskalo.
05-29-2008 1:50 PM
Hi,
convert string to Xstring you can use the following FM
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output " variable type string
IMPORTING
buffer = outputx. " variable type xstring
Regards
Kiran Sure
05-29-2008 2:03 PM
Thanks to both of you.
But this FM does not exists in 4.6C...I work on this version..
Please tell me...if there is any other way..?
09-01-2014 3:25 PM
The following code only works if the unicode validation is switched off:
data: a1(100) type c,
a2(100) type x,
s1 type string, " source
s2 type xstring. " target
s1 = 'My string to convert'.
a1 = s1.
FIELD-SYMBOLS: <char_container> TYPE c.
ASSIGN a2 TO <char_container> CASTING.
<char_container> = a1.
s2 = a2.
Regards,
Ulrich
02-19-2015 12:09 PM
I tried this and it wroked well by me:
Data:
lv_xstring TYPE xstring,
lv_mes_str TYPE string,
lv_length TYPE i,
lv_conv TYPE REF TO cl_abap_conv_out_ce.
lv_mess_str = "This should be the message in the string too be converted to XSTRING"
** Call class method to convert data to compatible xstring
CLEAR: lv_length, lv_xstring, lv_conv.
TRY.
lv_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 lv_conv->write
EXPORTING
n = -1
data = lv_mes_str
* 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 lv_conv->get_buffer
RECEIVING
buffer = lv_xstring.
CATCH cx_root.
* error handling
ENDTRY.