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

Converting to XSTRING

Former Member
0 Likes
422

Hi everyone,

I have a structure.

BEGIN OF x,

firstname(20) TYPE c,

lastname(20) TYPE c,

age TYPE i,

END OF x.

I want to compile the data of the structure into a conatiner which is of type string or xstring. Is there any class that had this functionality.

Please revert.

Thanks and Regards,

Bhargav.Kavuri

1 REPLY 1
Read only

venkata_ramisetti
Active Contributor
0 Likes
311

Hi,

Check the below code...

*   Convert XString to String 
    data: loc_conv type ref to CL_ABAP_CONV_IN_CE, 
            loc_xstring type xstring, 
            loc_string type string. 
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE 
      EXPORTING 
        INPUT       = loc_xstring 
        ENCODING    = 'UTF-8' 
        REPLACEMENT = '?' 
        IGNORE_CERR = ABAP_TRUE 
      RECEIVING 
        CONV        = loc_CONV. 

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

Thanks,

ramakrishna