ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Statements for Character String and Byte String Processing
SHIFT
Other versions: 7.31 | 7.40 | 7.54
Syntax
SHIFT dobj [ {[
places][
direction]} | deleting ]
[IN {CHARACTER|BYTE} MODE].
Addition
Effect
This statement shifts the content of a variable dobj
. In
places
, the number of places to be shifted can be specified and in
direction
, the direction of the shift. In
deleting
, the characters to be deleted from the data object by the shift can be specified. If no additions are specified, the content is shifted to the left by one place.
By default, free places created by the shift are filled with blanks or hexadecimal 0 for data objects
of fixed length, depending on the processing method. Data objects of type string
or xstring
are shortened by the number of shifted places when shifted to the left, and lengthened by the number of shifted places when shifted to the right.
When the character string is processed, the trailing blanks are respected for data objects dobj
of fixed length.
Note
To shift a string in an operand position, shift functions that cover some of the functions of the statement SHIFT
can be used.
Example
The shortest form of statement SHIFT
. The content of str
is moved one place to the left.
DATA(str) = `0123456789`.
SHIFT str.
cl_demo_output=>display( str ).
Addition
... IN {CHARACTER|BYTE} MODE
Effect
The optional addition IN {CHARACTER|BYTE} MODE
determines whether
character string or byte string processing
is performed. If the addition is not specified, character string processing is carried out. Depending
on the processing method, dobj
,
substring and mask
must be character-like or byte-like.
Example
Moving a byte string one byte to the left.
DATA(xstr) = CONV xstring( `AABBCCDDEEFF` ).
SHIFT xstr IN BYTE MODE.
cl_demo_output=>display( xstr ).