Ansicht
Dokumentation

ABENIMMUTABLE_VARIABLES_GUIDL - IMMUTABLE VARIABLES GUIDL

ABENIMMUTABLE_VARIABLES_GUIDL - IMMUTABLE VARIABLES GUIDL

ABAP Short Reference   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

Immutable Variables

An immutable variable is a special variable that can be assigned a value at exactly one write position of a context which cannot be change at other write positions. Immutable variables can be declared inline with the declaration operator FINAL.

Consider using immutable variables

Whenever you intent that a variable is filled at exactly one write position and should be read only otherwise, use an immutable variable.

An immutable variable prevents unwanted changes to the value of a variable. It combines the robustness of a constant with the flexibility of filling it at arbitrary write positions. When reading the value of an immutable variable, it is guaranteed that it filled with the value assigned during the inline declaration and that no other write access can have happened in between. If you are declaring an immutable variable inside a loop, you can be sure that its value is stable for each loop pass.

An internal table is declared inline with the declaration operator DATA and filled with values that are not expected to be changed any more.

Using the declaration operator FINAL, an immutable table is created, where any a later of the content is prevented in the current context.






RFUMSV00 - Advance Return for Tax on Sales/Purchases   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 1684 Date: 20240511 Time: 154258     sap01-206 ( 33 ms )