SHIFT - places
Short Reference
ABAP Syntax ... {BY num PLACES} | {UP TO substring} ... .
ABAP_VARIANTS:
1 ... BY num PLACES ... .
2 ... UP TO substring ... .
ABAP_VARIANT_1 ... BY num PLACES ... .
What does it do? The content of dobj is shifted to the left or
right (as specified by direction ) by
the positions specified in num . num is a
numerical expression position
of operand type i . If the content of num is less than or
equal to 0, the content of the data object dobj remains
unchanged.
Example ABAP Coding Using the statement FIND , the offset of the word
"you" in text is determined and its content is shifted by this
length to the left or right. After the shift, text contains "you
know" and is eight characters long.
DATA: text TYPE string VALUE `I know you know`,
off TYPE i.
FIND 'you' IN text MATCH OFFSET off.
SHIFT text BY off PLACES.
ABAP_VARIANT_2 ... UP TO substring ... .
What does it do? In the data object dobj , the first substring is
searched for whose contents match those of substring . This is
case-sensitive. The content of the data object dobj will be
shifted as far possible left or right (as specified in
direction ) until the byte or
character string contained in substring is at the position that
is at the beginning or end of the data object dobj before the
shift.
substring expects a character-like or byte-like data object. If
substring is an empty string, the position in front of the first
character or byte is found. To the left, no shift will take place, and
to the right there will be a shift by the entire length of dobj .
In character string processing, substring is a
character-like expression
position ; in data objects, substring with a fixed length
respects the trailing blanks.
System fields
sy-subrc Meaning
0The substring in substring was found in the data object
dobj and its contents were moved accordingly.
4The substring in substring was not found in the data object
dobj and its contents remain unchanged.
Latest notes: If you have data objects of fixed length, the substring
searched for after the shift is either (depending on the direction)
flush left at the beginning or flush right at the end of the data
object. If you have strings, the data object is lengthened to the right
through the shift. Therefore, the substring is not at the right margin
after the shift.
Example ABAP Coding This example has the same result as the previous
example. However, here the search for "you" is not performed in the
statement SHIFT itself.
DATA text TYPE string VALUE `I know you know `.
SHIFT text UP TO 'you'.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved