Skip to Content

what is the logic of xstring?

Jun 02, 2017 at 09:03 PM


avatar image
Former Member

hi experts

i am very new in abap and i am trying to understand what is xstring by myself. i wrote

REPORT zexercise.
y TYPE i VALUE 40,
z TYPE xstring.
z = y / x.

and result is 14 when z is xstring, 20 when z is string. I couldn't find any logic about 14. Can you please explain what is the logic of xstring.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sandra Rossi Jun 02, 2017 at 09:27 PM

Did you read the ABAP documentation? (what is XSTRING, what is implicit conversion between data types)

XSTRING is a string of bytes.

y / x gives a I-type (integer 4 bytes) result, and this value needs to be converted to type XSTRING, with rules explained in the ABAP documentation (excerpt below).

As an XSTRING data object is displayed in hexadecimal, you see 14 in hexadecimal which means 20 in decimal representation.


Excerpt from ABAP Documentation Conversion Rules for Elementary Data Types :

  • Data objects of the types b or s are converted in the internal representation from data type i. The 4 bytes of the data type i are positioned in the target field so that they are in big endian sequence. In this representation, positive values occupy 1, 2, 3, 4, or 8 bytes. Negative values always require 4 or 8 bytes. For positive values, the leading zeros before the fourth or eighth byte are not transported. Therefore, the resulting length of the target field is 1 byte for data type b, 1, 2, or 4 bytes for data type s, and 1, 2, 3, or 4 bytes for data type i.
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you for the explanation Sandra. This become very good for me to understand conversation logics of data types