SHIFT - places

Syntax

... {BY num PLACES} | {UP TO sub_string} ... .

Variants:

1. ... BY num PLACES ... .

2. ... UP TO sub_string ... .

Variant 1

... BY num PLACES ... .


Effect

The content of dobj is shifted to the left or

right - depending on the specification in direction - by the positions specified in num. However, the data type i is expected for num. If the content of num is less than or the same as 0, the content of the data object dobj remains unchanged.

Example

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.

Variant 2

... UP TO sub_string ... .


Effect

In the data object dobj, the first subsequence is searched for whose contents match those of sub_string. However, uppercase/lowercase lettering is not taken into consideration. The content of the data object dobj will be shifted as far possible left or right - depending on the specification in direction - until the byte or character sequence contained in sub_string is at the position that is at the beginning or end of the data object dobj before the shift.

For sub_string, a byte or character-type data object is expected. Closing blanks in data ojects of fixed length are taken into consideration. If sub_string 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.

System Fields

sy-subrc Meaning
0 The subsequence in sub_string was found in the data object dobj and its contents were moved accordingly.
4 The subsequence in sub_string was not found in the data object dobj and its contents remain unchanged.

Note

If you have data objects of fixed length, the subsequence 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 subsequence is not at the right margin after the shift.

Example

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'.