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 output TYPE TABLE OF string.
output = VALUE #(
( ` oo ` ) ).
output = VALUE #(
LET n = strlen( output[ 1 ] ) IN
BASE output
FOR j = 2 UNTIL j > n / 2
LET r = output[ j - 1 ] l = strlen( r ) / 2 IN
( shift_left( val = substring( val = r
len = l )
circular = 1 ) &&
shift_right( val = substring( val = r
off = l )
circular = 1 ) ) ).
output = VALUE #(
LET n = strlen( output[ 1 ] ) IN
BASE output
FOR j = n / 2 + 1 UNTIL j > n - 1
LET r = output[ j - 1 ] l = strlen( r ) / 2 IN
( shift_right( val = substring( val = r
len = l )
circular = 1 ) &&
shift_left( val = substring( val = r
off = l )
circular = 1 ) ) ).
cl_demo_output=>display( output ).
Description
This program creates a diamond shape in the display.