Skip to content

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

string_exp - Performance Note

If the right side of an assignment appends strings in a string expression to a variable str with the type string specified on the left side of the assignment, the variable is used directly in the following cases without producing a subtotal.

  • str &&= dobj1 && dobj2 && ... .
  • str = |{ str }...{ dobj1 [format_options] }...{ dobj2 [format_options] }...|.

The appended strings cannot be dependent on str (as known by the compiler):

  • The target field str can occur only once in the string expression, and only at the very beginning.
  • Only directly specified data objects dobj1, dobj2, and so on can be used, even if they are not dependent on str. No other expressions or functions can be used.

Optimization is therefore deactivated in the following cases:

  • str &&= ... && meth( ... ) && ... .
  • str &&= ... && str && ... .
  • str = |{ str }...{ expr( ... ) }...|.
  • str = |{ str format_options }...|.
  • str = |{ str }...{ str }...|.

Although it is not usually a problem to deactivate optimization for assignments that are not used very often, we strongly recommend only using optimizable forms within loops, because otherwise the runtime would increase quadratically with the number of iterations. In loops, the results of expressions and functions that can only be determined there should be assigned to helper variables dobj1, dobj2, and so on, and these should be used.

Other versions: 7.31 | 7.40 | 7.54


If optimization is deactivated, the runtime is related quadratically to the number of iterations, since the length of the string in the subtotal increases in proportion with the number of iterations and has to be copied to the result in every loop pass.


In the following example, where an HTML file is generated, there is no optimization. The runtime is quadratically related to the number of iterations n.

DATA(n) = 10000. 

DATA(html) = `<html><body><table border=1>`. 
  html = |{ html }<tr><td>{ 
            CONV string( ipow( base = sy-index exp = 2 ) ) 
html = html && `</table></body></html>`.

The following example shows how the runtime can be optimized by using a helper variable. The bigger n is, the greater the difference is from the runtime in the previous example.

DATA(n) = 10000. 

DATA(html) = `<html><body><table border=1>`. 
DATA square type string. 
  square = ipow( base = sy-index exp = 2 ). 
  html = |{ html }<tr><td>{ square }</td></tr>|. 
html = html && `</table></body></html>`.

Executable Example

Chaining Strings


Chaining Strings