SAP STRING CONCATENATION ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_STRINGEXP - Concatenating Strings
This example demonstrates how string concatenations can be optimized.

ABAP_SOURCE_CODE
DEMO CL_DEMO_STR_CONCATENATION

ABAP_DESCRIPTION
This example demonstrates the optimization of a string concatenation, if a string is lengthened on the right side by appending content during an assignment to a string. In this case, the strings are processed in a loop using a REDUCE expression.
There is no optimization in the first REDUCE expression since an expression is appended to the string s.
In the second REDUCE expression, the expression is assigned to a helper variable num using LET. This variable can be appended to s directly without an interim result needing to be produced.
Without optimization, the runtime increases quadratically with the number of iterations, which has a noticeable effect for large numbers n.