Skip to content

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

String Functions, shift and substring

This example demonstrates the string functions shift and substring.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA result TYPE string VALUE `            oo            `.

    WRITE result.
    DO strlen( result ) / 2 - 1 TIMES.
      result =
        shift_left(  val = substring( val = result
                                     len = strlen( result  ) / 2 )
                     circular = 1 ) &&
        shift_right( val = substring( val = result
                                     off = strlen( result  ) / 2 )
                     circular = 1 ).
      WRITE / result.
    ENDDO.
    DO strlen( result ) / 2 - 1 TIMES.
      result =
        shift_right( val = substring( val = result
                                     len = strlen( result  ) / 2 )
                     circular = 1 ) &&
        shift_left(  val = substring( val = result
                                     off = strlen( result  ) / 2 )
                     circular = 1 ).
      WRITE / result.
    ENDDO.

Description

The program creates a diamond in a classical list.