Skip to Content
author's profile photo Former Member
Former Member

purpose of describe distance between ??

Can anyone tell me when this option must be used in abap program ? what is the neccessity to know the distance ?


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 10, 2007 at 06:35 PM






    This statement assigns the distance between the starting positions of the data objects dobj1 and dobj2 to the data object dst, for which the data type i is expected. In case of deeper data types, the referenced data object is not relevant but the position of the internal reference (for strings and internal tables) or the reference variables. It is not important, in which order dobj1 and dobj2 are specified.

    In Unicode programs, the addition MODE must be specified. The variant with the addition IN BYTE MODE determines the distance in bytes. The variant with the addition IN CHARACTER MODE converts the distance into characters that can be stored in this length according to the current character presentation. In non-Unicode programs and in releases prior to 6.10, the addition MODE can be omitted. In this case, the addition IN BYTE MODE is used implicitly. When you use this addition in IN CHARACTER MODE and the determined distance cannot be converted into a number of characters, an exception that cannot be handled is triggered.


    The distance between data objects should only be determined within the same structure and only the structure's components should be used because only they are always in a successive order in the memory. Note that the alignment gaps are counted as well. Therefore, use the addition IN BYTE MODE to avoid an exception that cannot be handled.


    Determination of the offset and length of a character-type fragment within the structure struc in bytes, access to the fragment using an offset / length access und an assignment to a field symbol of the type c. Since the structure is not purely character-type, a field symbol is used for the offset / length access. Otherwise, a syntax error occurs in a Unicode program. The field symbol is of the type x, because offset and length are determined in bytes. Due to the alignment gap before comp3, a different value is determined for off in Unicode system as in non-Unicode systems. In both cases, the field symbol <result> has the same content "Hey you!".

    DATA: BEGIN OF struc,

    comp1 TYPE i,

    comp2 TYPE x LENGTH 1,

    comp3 TYPE c LENGTH 4 VALUE 'Hey',

    comp4 TYPE c LENGTH 4 VALUE 'you!',

    comp5 TYPE x,

    END OF struc.

    DATA: off TYPE i,

    len TYPE i.

    FIELD-SYMBOLS: <hex> TYPE x,

    <result> TYPE c.


    struc AND struc-comp3 INTO off IN BYTE MODE,

    struc-comp3 AND struc-comp5 INTO len IN BYTE MODE.

    ASSIGN: struc TO <hex> CASTING,

    <hex>+off(len) TO <result> CASTING.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.