ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Statements for Character String and Byte String Processing → SHIFT
SHIFT - deleting
Other versions: 7.31 | 7.40 | 7.54
Syntax
... { {LEFT DELETING LEADING}
| {RIGHT DELETING TRAILING} } mask ...
Effect
If these additions are used, the statement SHIFT
shifts the content of
dobj by one place to the left or the right until the content of the first or last place in dobj
is displayed in mask
.
If the data object dobj
is a string, it is shortened when it is shifted to
the left but not lengthened when it is shifted to the right. This means the content of mask
can also be moved out of a string to the right.
In character string processing, mask
is a
character-like expression
position. It is case-sensitive and any trailing blanks in mask
are respected.
If the content of the first or last place in dobj
is not in mask
,
the content of text
remains unchanged. More specifically, nothing is shifted if mask
is an empty string.
Example
After it has been shifted to the right, text
contains the value "_______I know you" and has a length of 15 characters.
DATA text TYPE string VALUE `I know you know `.
SHIFT text RIGHT DELETING TRAILING 'no kw'.
Example
The following example removes first the trailing blank and then the leading blanks from a string. For strings without leading blanks, this sequence of statements can be used to remove trailing blanks.
DATA txt TYPE string VALUE `XXXXX `.
SHIFT txt RIGHT DELETING TRAILING ` `.
SHIFT txt LEFT DELETING LEADING ` `.