Ansicht
Dokumentation

ABENSTRING_EXPR_PERFO - STRING EXPR PERFO

ABENSTRING_EXPR_PERFO - STRING EXPR PERFO

BAL Application Log Documentation   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

- Performance Note

If on the right side of an assignment strings in a string expression are appended 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 an interim result.

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

The appended strings cannot be dependent on str for 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 no other expressions or functions can be listed, even if they are not dependent on str.

Optimization is therefore deactivated in the following cases:

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

Deactivating optimization for assignments that are not used very often is usually uncritical, it is strongly recommend to only use optimizable forms within loops, because otherwise the runtime would increase quadratically with the number of iterations. Within 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.

Note

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

In the following example for generating an HTML file, there is no optimization. The runtime depends quadratically on the number of iterations n.

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

Concatenating Strings






TXBHW - Original Tax Base Amount in Local Currency   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 3112 Date: 20240425 Time: 160230     sap01-206 ( 37 ms )