What is XSTRING data type and how to convert it to various formats

XSTRING is predefined byte-like ABAP type with variable length. This type ensures dynamic allocation of memory. Its value is a sequence of bytes that equals its hexadecimal value as shows screenshot from ABAP debugger.

xstring

Usage

XSTRING is used to send files to SAP from web applications using technologies such as BSP or SAP Gateway with OData service.

Conversions

Mostly, we need to convert XSTRING into different ABAP data types to use it as importing parameter to different function modules and methods.

a) XSTRING to SOLIX

This conversion is described in article How to store file incoming as XSTRING in SAP.

b) XSTRING to STRING

There are few ways how to convert xstring to string. This is most convenient way:

 

Second way is using class cl_abap_conv_in_ce.

 

Peter Marcely

ABAP, Python, JavaScript developer

  • Bohdan Petrushchak

    Hello Peter,

    Thank you for a helpful suggestion regards using class cl_abap_conv_in_ce.

    Regards,
    Bohdan

  • KarthiK E

    Dear Friends,
    how to convert xstring to JSON/ XML using java. please suggest me the best practice of implementation and what are the library required in java.

    Note : inside JSON / XML if coming Xstring then how to handle in java for eg : 3344SAX3343 json {firstname:”3344SAX3343″}.

  • özkan Yıldırım

    thank you very much PETER,