Application Development 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: 

purpose of describe distance between ??

Former Member
0 Kudos

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

thanks

1 REPLY 1

Former Member
0 Kudos

DESCRIBE DISTANCE

Syntax

DESCRIBE DISTANCE BETWEEN dobj1 AND dobj2 INTO dst

IN {BYTE|CHARACTER} MODE.

Effect

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.

Note

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.

Example

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.

DESCRIBE DISTANCE BETWEEN:

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.