6 Replies Latest reply: Feb 19, 2015 1:09 PM by Remitus Elad RSS

String to Xstring

Nazneen Bangi
Currently Being Moderated

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.

  • Re: String to Xstring
    Micky Oestreich
    Currently Being Moderated

    possibly.....SCMS_STRING_TO_XSTRING

     

    Edited by: Micky Oestreich on May 29, 2008 2:48 PM

  • Re: String to Xstring
    Currently Being Moderated

    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

    • Re: String to Xstring
      Nazneen Bangi
      Currently Being Moderated

      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..?

      • Re: String to Xstring
        Ulrich Rechner
        Currently Being Moderated

        The following code only works if the unicode validation is switched off:

         

        dataa1(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



  • Re: String to Xstring
    Remitus Elad
    Currently Being Moderated

    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.



Actions