Conversion of XSTRING to String is incomplete

Hi ,
I am trying to conver a Xstring to String. But the output string after conversion is incomplete.
Here is the code snippet-
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
      EXPORTING
        INPUT       = l_xstring
        ENCODING    = 'UTF-8'
        REPLACEMENT = '?'
        IGNORE_CERR = ABAP_TRUE
      RECEIVING
        CONV        = loc_CONV.
        length = xstrlen( l_xstring ).
        CALL METHOD loc_CONV->READ
        EXPORTING
        N = length
        IMPORTING
            DATA = loc_string
            LEN = length.
Can anyone please help?
Best Regards,
Lata

Hi,
http://www.sapfans.com/forums/viewtopic.php?p=403405&sid=e524cddae19e7ae48a12477e68c6032d
Regards,
Sravanthi

Similar Messages

  • Convert XString to String and String to IWDResource

    Hi everybody,
    we want to open a PDF-Document from Backend in Web Dynpro. For the communication we use a Web Service.
    In Backend we have a PDF-Document with data type XSTRING.
    1. In Backend we convert the PDF-Document from XSTRING to STRING in order to send it via Web Service
    2. Then we call the Web Service and pass by the STRING param
    3. In Web Dynpro we convert the value from STRING to Bytes, like below:
    IWDResource resource = WDResourceFactory.createResource( myPDFStringFromWS.getBytes(), "Doc1", WDWebResourceType.PDF);
    4. We bind the Resource to a FileDownload-UI.
    Unfortunately we get the error message: Document is not a valid PDF
    How can we convert a String to IWDResource? Could the problem be in our first step, where we convert the XSTRING into STRING?
    regards,
    Sid

    Hello Sid,
    IWDResource resource = WDResourceFactory.createCachedResource(new ByteArrayInputStream(wdContext.currentFileElement().getString()),"PDF",WDWebResourceType.PDF,true);
    IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(resource.toString(),"PDF");
    window.show();
    Can you try this and let us know.
    Regards
    Nizamudeen SM

  • Convert xstring to string

    Hi All,
    I need to convert the XSTRING to STRING and i need a FM or method which converts all the special characters like Å, ö, ä, å, ü as it is.
    Im getting the xstring value from excel sheet using file upload in WEB UI.
    The class used is CL_HTMLB_FILEUPLOAD and the attribute is FILE_CONTENT which is of type XSTRING.
    I have few special characters in the excel sheet which i need as string.
    I have modified this FM CRM_IC_XML_XSTRING2STRING to convert the Xstrin gto string... but stilll the replacement is not working.
    Can anyone suggest me...Any different solution i can use to get the file upload in string. Or get the characters from Xstring
    Useful answers are much apprieciated.
    Thanx in advance
    Siva.

    Hey,
    Why dont you check this method
    ECATT_CONV_STRING_TO_XSTRING. Not sure whether it supports special characters or not
    Regards,
    Vinay

  • Messy code problem while translating XString to String in OfficeControl

    Hi Expert,
        I have messy code problem while translating XString to String in XML-Format Word Doc in OfficeControl.
    I upload an XML-Format template Word Doc to server as a MIME Object.
    When OfficeControl is started in Web Dynpro, OfficeControl automatically open the XML-Format template.
    For the first time, I get the XString-type Context attribute bind to the content of the Word Doc,
    then translate it to string, I got the XML-format content, it's great!
    However, after the first time, when I input any new contents in MS Word in Web Dynpro,
    no matter I execute "Ctrl + S" or click the "savedocument" button,
    when I translate the XString Context attribute to String, I got messy code. (but the first time, it is good plain text)
    I use the function module: ECATT_CONV_XSTRING_TO_STRING (good for first time, dump after first time),
    SCMS_XSTRING_TO_BINARY, SCMS_BINARY_TO_STRING (good for first time, messy code after first time).
    My Demo source code is in: (system) SMV --> (local object) zhaode --> (Dynpro Component) ztest_office_control
    core source code is as:
    clear itab.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    BUFFER = lv_datas
    IMPORTING
    OUTPUT_LENGTH = lv_length
    TABLES
    binary_tab = itab.
    CALL FUNCTION 'SCMS_BINARY_TO_STRING'
    EXPORTING
    input_length = lv_length
    mimetype = 'text/plain; charset=utf-8'
    IMPORTING
    text_buffer = lv_datas_string
    output_length = lv_data_len
    TABLES
    binary_tab = itab.
    Can you give me some advice?
    Many thanks in advance.
    Best Regards,

    You have already posted this same question several times (and some very similiar questions) within the forum.  Please do NOT multiple post your questions. This is against the forum rules of engagement. SAP employee or not, you will find yourself banned from the forums if you don't follow the rules.

  • Xstring to string for ms_excel

    Hi ALL,
    I am using OFFICE CONTROL UI ELEMENT for displaying iternal table data into EXCEL  OFFICE CONTROL UI .
    i am displaying data into OFFICE CONTROL UI EXCEL, then i will update excel of office control and then i will save,when i save that updated data need to send one internal table .
    DATA :OUT_STRING1 TYPE STRING,
          CONTENTXMLSOURCE TYPE XSTRING.
    WD_CONTEXT->GET_ATTRIBUTE( EXPORTING NAME = 'DATAS' IMPORTING VALUE = CONTENTXMLSOURCE ).
    CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
      EXPORTING
      FROM_CODEPAGE       = '8500'
        IN_XSTRING          = CONTENTXMLSOURCE
      OUT_LEN             =
    IMPORTING
       OUT_STRING          = OUT_STRING1.
    data lr_conv       type ref to cl_abap_conv_in_ce.
    lr_conv = cl_abap_conv_in_ce=>create( ).
    lr_conv->convert( exporting input = xstring importing data = string ).
    NOT FOR LIKE Excel file (like Tab Delimited, CVS, XML, etc). Only for ms_excel.
    the above mention two concepts are not working to convert from xstring to string ,is there any concept ms_excel format xstring to string?
    THANKS,
    RAMA
    Edited by: Ramakullay Challa on Sep 25, 2009 2:03 PM
    Edited by: Ramakullay Challa on Sep 25, 2009 2:06 PM

    Hi Lekha,
    When i am activating one  method , insede this method i am calling one c lass.
    data: DATASOURCE type ref to CL_WD_OFFICE_CONTROL,
       content type xstring.
    TRY.
          DATASOURCE = cl_wd_office_control=>GET_DATA_SOURCE( VALUE = CONTENT ).
    CATCH CX_WD_ACF_EXCEPTION.
    ENDTRY.
    error .any idea lekha.
    *you can use only use "class=>method" with static methos.*
    data: DATASOURCE type ref to CL_WD_OFFICE_CONTROL,
       content type xstring.
    CONTENT  = DATASOURCE->GET_DATA_SOURCE( ).
    no error.
    thanks.
    thanks,
    rama
    Edited by: Ramakullay Challa on Sep 28, 2009 7:08 AM
    Edited by: Ramakullay Challa on Sep 28, 2009 7:09 AM
    Edited by: Ramakullay Challa on Sep 28, 2009 11:26 AM

  • Need a function module to convert xstring to string in web dynpro applicati

    hi,
       need a function module to convert xstring to string in web dynpro application other than HR_KR_XSTRING_TO_STRING.
    Moderator message: please (re)search yourself first.
    Edited by: Thomas Zloch on Nov 17, 2010 5:31 PM

    Hi,
    Check the following link:
    FM to convert XString to String
    Regards,
    Bhaskar

  • Conversion from document to string

    I want to perform conversion from document to string for tht purpose i m doing sax parser but in the end i m getting null.The same thing if i do with DOM parser its working fine but some problem with sax parser.
    I am attaching the code if anyone can find the problem it would be gr8.
    Thanks in advance.
    public String DocumentToString(Document doc) {
              StreamResult result = null;
              try {
              SAXParserFactory SAXpf = SAXParserFactory.newInstance();     
    SAXParser SAXparser = SAXpf.newSAXParser();
              XMLr = SAXparser.getXMLReader();
         Source sXML = new SAXSource((InputSource) doc);
    result = new StreamResult(new StringWriter());
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.transform(sXML, result);
    catch (TransformerConfigurationException e) {
    e.printStackTrace();
    catch (TransformerException e) {
    e.printStackTrace();
    catch(Exception e)
         System.out.println(e);
    return result.getWriter().toString();
    }

    Paddy,
    There are a couple of ways to create a Word file.  One is to use the Report Generation Toolkit which includes vi's to create and edit Word documents.  Since you are associated with a university you may already have the toolkit.  The other way is to use ActiveX.  You should be able to find examples of both in the forums.  There may also be an example that shipped with LV. 
    Here is one example to get you going http://zone.ni.com/devzone/cda/epd/p/id/992

  • German Special Characters in XSTRING to STRING conversion

    Hi Experts,
    I have a CSV file (created from a Windows Excel file) with German Special Characters (e.g. 'ä', 'Ä') and I am trying to read this into ABAP internal tables. By using the THTMLB tag 'thtmlb:fileUpload' I get an XSTRING and I am trying to convert this into STRING. However, wheny trying to do this I get an exception 'CX_SY_CONVERSION_CODEPAGE'.
    This is my coding:
      data: conv   type ref to cl_abap_conv_in_ce.
      conv = cl_abap_conv_in_ce=>create( input = lr_upload->file_content ).
      conv->read( importing data = lv_content ).
    Note: lr_upload is my XSTRING object from the file upload, lv_content is a STRING.
    In the CSV file the German special characters look fine and the SAP system is a Unicode system, but it seems like there are some problems with the conversions somehow. Any ideas from the experts?
    Thanks a lot and Regards,
    Jens

    As you mention a csv file I'm wondering if your encoding is wrong: I.e. when you create your instance of cl_abap_conv_in_ce you don't specify the encoding of your source hex string, so that means the default encoding is used, which should be UTF-8 in your case. So if your csv file is not encoded in UTF-8, specify the correct encoding in the create method and see if that helps.
    Depending on how you get the file contents you might actually be able to combine the file retrieval with the conversion in one step. E.g. if the file is read from the application server you could specify the used code page via [open dataset ... in legacy text mode ... code page|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm#&ABAP_ALTERNATIVE_4@4@]. Similarly method gui_upload of class cl_gui_frontend_services also allows you to specify a code page.
    If all of this doesn't help, post some further details on your file (e.g. sample content & encoding) and possibly add some further details from the exception you're getting. As you mention a Unicode system it basically means that we should be able to convert all characters without any problem as long as we specify the correct source code page.
    Cheers, harald

  • Error converting XSTRING to STRING (unicode, codepage)

    Hi all,
    I have a problem converting data from an external file into SAP.
    The file is uploaded via an application created in web dynpro, where I use the upload functionality. This returns the file in the XSTRING format, and  then use the following to convert (where l_xstring is the file and l_string is how I want the file):
      l_string TYPE string,
      l_xstring TYPE xstring,
      convt = cl_abap_conv_in_ce=>create( input = l_xstring ).
      convt->read( IMPORTING data = l_string ).
    This worked perfectly - until I recieved a file containing russian characters
    The SAP system (BI) is in Unicode, so this should be ok.
    I get a:
    CONVT_CODEPAGE
    CX_SY_CONVERSION_CODEPAGE
    Error, when trying to run it.
    Also the following migth be helpful:
    At the conversion of a text from codepage '4110' to codepage '4102':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    The running ABAP program 'CL_ABAP_CONV_IN_CE============CP' had to be
    terminated as the conversion
    would have produced incorrect data.
    The number of characters that could not be displayed (and therefore not
    be converted), is 18141. If this number is 0, the second error case, as
    mentioned above, has occurred.
    I have tried setting the codepage parameter of the READ method, but to no success.
    Anyone ??
    -Tonni

    Friend,
    Call the FM like below....
    CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
      EXPORTING
        IM_XSTRING        = x
       IM_ENCODING       = 'UTF-8'
    IMPORTING
       EX_STRING         = x.

  • Fm to convert XSTRING TO STRING in SRM 7.0

    HI All ,
                i have created a web dynpro application for Uploading excel . Now i am not getting any workaround to convert X STRING to STRING . In SAP there is a FM HR_KR_XSTRING_TO_STRING but its not there in SRM so when i tried to copy the same in SRM and try to convert its getting converted in Junk characters . Please help me out in this .
    Regards
    Shankar

    HI Nilema ,
                           I have tried ur code also but still the same result .
    METHOD onactionon_upload .
      TYPES :
          BEGIN OF str_itab,
          name(10) TYPE c,
          age(10) TYPE c,
          END OF str_itab.
      DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
             i_data TYPE STANDARD TABLE OF string,
             lo_nd_sflight TYPE REF TO if_wd_context_node,
             lo_el_sflight TYPE REF TO if_wd_context_element,
             l_string TYPE string,
             fs_table TYPE str_itab,
             l_xstring TYPE xstring,
             fields TYPE string_table,
             lv_field TYPE string,
             lv_codepage TYPE CPCODEPAGE.
      DATA : t_table TYPE if_main=>element_datatab,
             data_table TYPE if_main=>element_datatab.
    get single attribute
    break akedia.
      wd_context->get_attribute(
        EXPORTING
          name =  `DATASOURCE`
        IMPORTING
          value = l_xstring ).
    CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
      EXPORTING
        external_name       =  'ISO-8859-1'
       KIND                = 'H'
    IMPORTING
       SAP_CODEPAGE        = lv_codepage
    EXCEPTIONS
       NOT_FOUND           = 1
       OTHERS              = 2
    IF sy-subrc <> 0.
      lv_codepage = '1100'.
    ENDIF.
    CALL FUNCTION 'LXE_COMMON_XSTRING_TO_STRING'
      EXPORTING
        in_xstring        = l_xstring
       IN_CODEPAGE       = lv_codepage
      EX_CODEPAGE       = '0000'
      UNMASK_CRLF       = ''
    IMPORTING
       EX_STRING         = l_string
    EXCEPTIONS
       ERROR             = 1
       OTHERS            = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    Bind With table Element.
      LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
        READ TABLE fields INTO lv_field INDEX 1.
        fs_table-name = lv_field.
        READ TABLE fields INTO lv_field INDEX 2.
        fs_table-age = lv_field.
        APPEND fs_table TO t_table1.
      ENDLOOP.
      lo_nd_sflight = wd_context->get_child_node( 'DATATAB' ).
      lo_nd_sflight->bind_table( t_table1 ).
    ENDMETHOD.

  • FM to convert XString to String

    I am developing an simple application to upload an excel file and display its contents in a table in Solution manager using Web dynpro.
    But 'HR_KR_XSTRING_TO_STRING' is not avaiable in DS1.
    Can you help me find a replacement for this function module.
    TYPES :
           BEGIN OF str_itab,
           name(10) TYPE c,
           age(10) TYPE c,
           END OF str_itab.
           DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
             i_data TYPE STANDARD TABLE OF string,
             lo_nd_sflight TYPE REF TO if_wd_context_node,
             lo_el_sflight TYPE REF TO if_wd_context_element,
             l_string TYPE char200,
             fs_table TYPE str_itab,
             l_xstring TYPE char200,
             fields TYPE string_table,
             lv_field TYPE string.
           DATA : t_table TYPE if_main=>elements_data_tab,
             data_table TYPE if_main=>elements_data_tab.
    get single attribute
             wd_context->get_attribute(
             EXPORTING      name =  `DATASOURCE`
               IMPORTING      value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string.
      SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    Bind With table Element.
      LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.    READ TABLE fields INTO lv_field INDEX 1.
        fs_table-name = lv_field.    READ TABLE fields INTO lv_field INDEX 2.
        fs_table-age = lv_field.    APPEND fs_table TO t_table1.
      ENDLOOP.
      lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
      lo_nd_sflight->bind_table( t_table1 ).
    Thanks in advance
    Akshatha

    It is not appropriate to ask general ABAP questions such as this in the Web Dynpro ABAP Forum. As your punishment I will help with your question.
    In this sample buffer is the XSTRING, text_buffer is the string. You have to supply an encoding to tell the system what codepage/unicode type the XSTRING is.
    data: convin  type ref to cl_abap_conv_in_ce,
          call method cl_abap_conv_in_ce=>create
            exporting
               encoding    = encoding
               input       = buffer
            receiving
              conv        = convin.
          call method convin->read
            importing
              data = text_buffer.

  • Conversion of Double to String

    Is there any method in JAVA which can convert a double value to String (but expand it)
    for ex: I want to convert 1.2E7 to look like "12000000"
    I know an equal C conversion technique which is as follows => sprintf(strAmount, "%35.2lf", fAmount);
    Plz.. Reply to:
    [email protected]

    i have tried the DecimalFormat in the reply, but the d
    in the fd.format(d) is still in xxxxxxxxEx format. And
    i couldn't perform any calculation based on the
    converted value with this format after saving this
    value to may be database or some other files. Can you
    advice how to get 170000000.00 instead of
    1.70000000E8.Use the setMaximumIntegerDigits() method of the NumberFormat.
    Servus.

  • Conversion from int to String

    How can i convert an int to a String.
    There is no direct String constructor that take only an integer.
    Thanks

    int num = 1;
    String str = "" + num;
    or
    int num = 1;
    String str = Integer.toString(num);

  • Conversion of int to String

    hi,
    Do someone know which way of converting the int to String is better? In term of performance and other issues in the handset:
    1. int a = 5;
    String b = a + "";
    2. int a = 5;
    String b = String.valueOf(a);
    Thank you!

    Hi,
    The second method is better. Because for the first method 3 String objects will be created.

  • Conversion of Date to String in JSP..

    Please help....
    wat should i do to convert Date to String in my JSP Page?
    Thank you....

    SimpleDateFormat class

Maybe you are looking for