SAP SHIFT PLACES ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• UP TO SHIFT
• BY PLACES SHIFT

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 by the positions specified in num, depending on the specification in direction. num is a numeric 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.

ABAP_EXAMPLE_VX5
The statement FIND determines the offset of the word you in text and shifts its content by this length to the left or right. After the shift, text contains you know and is eight characters long.
ABEXA 00671
ABAP_EXAMPLE_END

ABAP_VARIANT_2 ... UP TO substring ...

What does it do?
In the data object dobj, the first substring is searched for whose content matches that of substring. The search is case-sensitive. Depending on the specification in direction, the content of the data object dobj is shifted to the left or right until the byte string or character string contained in substring is left-aligned or right-aligned 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 place in front of the first character or byte is found. There is no shift to the left but a shift by the entire length of dobj to the right.
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-subrcMeaning 0The substring in substring was found in the data object dobj and its content was moved accordingly. 4The substring in substring was not found in the data object dobj and its content remain unchanged.



Latest notes:

For data objects of fixed length, the substring searched for after the shift is either left-aligned at the beginning or right-aligned at the end of the data object, depending on the direction. In the case of strings, the shift makes the data object longer on the right, which means that the substring is not at the right margin after the shift.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
This example has the same result as the previous example. However, here the search for you is not performed in the statement SHIFT itself.
ABEXA 00672
ABAP_EXAMPLE_END

Return to menu