ABAP - Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for String Processing →  String Functions →  Processing Functions for Character-Like Arguments → 

shift_left, shift_right - Shift Functions

The shift functions shift the content of a character-like argument.

Syntax Forms

1. ... shift_left( [val =] text
                  [places = places]|[circular = places]|[ sub = substring] ) ...

2. ... shift_right( [val =] text
                   [places = places]|[circular = places]|[ sub = substring] ) ...

Effect

The functions shift_left and shift_right shift the character string text to the left or to the right and return the result. The shift depends on the parameter pass as follows:

places and circular are numeric expression positions of type i.

The return code has the type string accordingly.

Note

When places is specified, the function shift_right behaves differently from the statement SHIFT with the additions RIGHT and PLACES. The function shift_right reduces the length of the string, but the statement SHIFT makes the string longer or keeps it the same length.

Example

The following program line

txt = shift_right( txt ).

has the same meaning as

txt = shift_right( val = txt sub = ` ` ).

and removes the trailing blanks from a string txt.

Executable Example

String Functions, shift and substring

Exceptions

Handleable Exceptions

CX_SY_RANGE_OUT_OF_BOUNDS